pub struct SegmentGeometry { /* private fields */ }Expand description
Immutable strip descriptor; results use caller-owned storage.
use ferravex_play::ui::{Rect, meters::*};
let r = Rect { min: [0.; 2], size: [118., 10.] };
let strip = SegmentGeometry::new(r,
SegmentValue::Known { filled: 2, capacity: 6 }, 2.)?;
let mut cells = [SegmentRect { bounds: r, filled: false }; MAX_METER_SEGMENTS];
assert_eq!(strip.write_into(&mut cells)?, 6);
assert_eq!(cells[..6].iter().filter(|c| c.filled).count(), 2);
assert_eq!(cells[5].bounds.min[0] + cells[5].bounds.size[0], 118.);Implementations§
Source§impl SegmentGeometry
impl SegmentGeometry
pub fn new( bounds: Rect, value: SegmentValue, gap: f32, ) -> Result<SegmentGeometry, MeterError>
pub fn bounds(self) -> Rect
pub fn value(self) -> SegmentValue
pub fn count(self) -> usize
Sourcepub fn write_into(self, output: &mut [SegmentRect]) -> Result<usize, MeterError>
pub fn write_into(self, output: &mut [SegmentRect]) -> Result<usize, MeterError>
Full prevalidation and output-length check precede writes. The output tail is unchanged on success, and the entire slice is unchanged on error.
Trait Implementations§
Source§impl Clone for SegmentGeometry
impl Clone for SegmentGeometry
Source§fn clone(&self) -> SegmentGeometry
fn clone(&self) -> SegmentGeometry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SegmentGeometry
impl Debug for SegmentGeometry
Source§impl PartialEq for SegmentGeometry
impl PartialEq for SegmentGeometry
impl Copy for SegmentGeometry
impl StructuralPartialEq for SegmentGeometry
Auto Trait Implementations§
impl Freeze for SegmentGeometry
impl RefUnwindSafe for SegmentGeometry
impl Send for SegmentGeometry
impl Sync for SegmentGeometry
impl Unpin for SegmentGeometry
impl UnwindSafe for SegmentGeometry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more