Skip to main content

FixedLineString

Struct FixedLineString 

Source
pub struct FixedLineString<const N: usize> { /* private fields */ }
Expand description

A fixed-capacity polyline (open line string) backed by an inline array.

Stores up to N Point2D vertices with no heap allocation.

Implementations§

Source§

impl<const N: usize> FixedLineString<N>

Source

pub fn new() -> Self

Creates an empty FixedLineString.

Source

pub fn push(&mut self, p: Point2D) -> Result<(), NoAllocError>

Attempts to append a point. Returns Ok(()) on success or Err(NoAllocError::CapacityExceeded) if full.

Source

pub fn len(&self) -> usize

Returns the number of points in the line string.

Source

pub fn is_empty(&self) -> bool

Returns true if the line string contains no points.

Source

pub fn get(&self, index: usize) -> Option<&Point2D>

Returns the point at the given index, or None if out of bounds.

Source

pub fn as_slice(&self) -> &[Point2D]

Returns a slice of the current points.

Source

pub fn total_length(&self) -> f64

Computes the total length of the polyline (sum of segment lengths).

Returns 0.0 for line strings with fewer than 2 points.

Source

pub fn bbox(&self) -> Option<BBox2D>

Returns the axis-aligned bounding box, or None if empty.

Source

pub fn iter(&self) -> Iter<'_, Point2D>

Returns an iterator over the points.

Source

pub const fn capacity(&self) -> usize

Returns the capacity of this line string.

Source

pub fn clear(&mut self)

Clears all points, resetting the length to zero.

Source

pub fn first(&self) -> Option<&Point2D>

Returns the first point, or None if empty.

Source

pub fn last(&self) -> Option<&Point2D>

Returns the last point, or None if empty.

Trait Implementations§

Source§

impl<const N: usize> Default for FixedLineString<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for FixedLineString<N>

§

impl<const N: usize> RefUnwindSafe for FixedLineString<N>

§

impl<const N: usize> Send for FixedLineString<N>

§

impl<const N: usize> Sync for FixedLineString<N>

§

impl<const N: usize> Unpin for FixedLineString<N>

§

impl<const N: usize> UnsafeUnpin for FixedLineString<N>

§

impl<const N: usize> UnwindSafe for FixedLineString<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.