Skip to main content

Segment

Struct Segment 

Source
pub struct Segment<P: PointTrait> { /* private fields */ }
Expand description

Two-point segment.

Mirrors boost::geometry::model::segment<P> from boost/geometry/geometries/segment.hpp:55-71. The two endpoints are addressed by index 0 (start) and 1 (end), matching the traits::indexed_access<segment, 0|1, D> specialisations at boost/geometry/geometries/segment.hpp:136-169.

Implementations§

Source§

impl<P: PointTrait> Segment<P>

Source

pub const fn new(start: P, end: P) -> Self

Construct a segment from its two endpoints.

Mirrors the segment(Point const& p1, Point const& p2) constructor at boost/geometry/geometries/segment.hpp:67-70.

Source

pub const fn start(&self) -> &P

Borrow the start endpoint (I = 0).

Mirrors reading s.first on model::segment — the Boost traits::indexed_access<segment, 0, D>::get(...) accessor at boost/geometry/geometries/segment.hpp:142-150 returns a coordinate of that endpoint; this method returns the whole point.

Source

pub const fn end(&self) -> &P

Borrow the end endpoint (I = 1).

Mirrors reading s.second on model::segment — the Boost traits::indexed_access<segment, 1, D>::get(...) accessor at boost/geometry/geometries/segment.hpp:160-168.

Trait Implementations§

Source§

impl<P: Clone + PointTrait> Clone for Segment<P>

Source§

fn clone(&self) -> Segment<P>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Copy + PointTrait> Copy for Segment<P>

Source§

impl<P: Debug + PointTrait> Debug for Segment<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: Default + PointTrait> Default for Segment<P>

Source§

fn default() -> Segment<P>

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

impl<P: PointTrait> Geometry for Segment<P>

Tag this concrete type as a Segment. Mirrors the traits::tag<model::segment<...>> specialisation at boost/geometry/geometries/segment.hpp:121-124.

Source§

type Kind = SegmentTag

One of the *Tag types from geometry_tag. Read more
Source§

type Point = P

The point type this geometry is built from. For a value modelling Point, this is Self. Read more
Source§

impl<P: PointMut> IndexedAccess for Segment<P>

Two-axis access on the segment. Collapses the traits::indexed_access<segment, 0|1, D> specialisations at boost/geometry/geometries/segment.hpp:136-169 into one Rust impl: the I axis selects the endpoint, D then dispatches to Point::get / Point::set on that endpoint.

Source§

fn get_indexed<const I: usize, const D: usize>(&self) -> P::Scalar

Read coordinate D of corner I. Read more
Source§

fn set_indexed<const I: usize, const D: usize>(&mut self, value: P::Scalar)

Write coordinate D of corner I. Read more
Source§

impl<P: PartialEq + PointTrait> PartialEq for Segment<P>

Source§

fn eq(&self, other: &Segment<P>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Segment<Point<A, D, OldCs>>

Source§

type Output = Segment<Point<T, D, Cs>>

The corresponding rebound stock model.
Source§

impl<P: PointMut> Segment for Segment<P>

Wire the Segment concept up. The trait body is empty — the concept is satisfied by the two super-bounds Geometry and IndexedAccess already proven above.

Source§

impl<P: PartialEq + PointTrait> StructuralPartialEq for Segment<P>

Auto Trait Implementations§

§

impl<P> Freeze for Segment<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for Segment<P>
where P: RefUnwindSafe,

§

impl<P> Send for Segment<P>
where P: Send,

§

impl<P> Sync for Segment<P>
where P: Sync,

§

impl<P> Unpin for Segment<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for Segment<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for Segment<P>
where P: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> SameAs<T> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.