pub struct Line<T = i32, const N: usize = 2>(/* private fields */);
Expand description
A Line
with start and end Points.
Please see the module-level documentation for examples.
Implementations§
Source§impl<T: Copy, const N: usize> Line<T, N>
impl<T: Copy, const N: usize> Line<T, N>
Sourcepub fn set_start<P: Into<Point<T, N>>>(&mut self, start: P)
pub fn set_start<P: Into<Point<T, N>>>(&mut self, start: P)
Sets the starting point of the line.
Sourcepub fn points(&self) -> [Point<T, N>; 2]
pub fn points(&self) -> [Point<T, N>; 2]
Returns Line
points as [Point<T, N>; 3]
.
§Example
let p1 = point!(5, 10);
let p2 = point!(100, 100);
let l = Line::new(p1, p2);
assert_eq!(l.points(), [point!(5, 10), point!(100, 100)]);
Sourcepub fn points_mut(&mut self) -> &mut [Point<T, N>; 2]
pub fn points_mut(&mut self) -> &mut [Point<T, N>; 2]
Returns Line
points as a mutable slice &mut [Point<T, N>; 3]
.
§Example
let p1 = point!(5, 10);
let p2 = point!(100, 100);
let mut l = Line::new(p1, p2);
for p in l.points_mut() {
*p += 5;
}
assert_eq!(l.points(), [point!(10, 15), point!(105, 105)]);
Source§impl<T, const N: usize> Line<T, N>
impl<T, const N: usize> Line<T, N>
Sourcepub fn as_<U>(&self) -> Line<U, N>where
U: 'static + Copy,
T: AsPrimitive<U>,
pub fn as_<U>(&self) -> Line<U, N>where
U: 'static + Copy,
T: AsPrimitive<U>,
Returns Self
with the numbers cast using as
operator.
Converts Line < T, N > to Line < U, N >.
Trait Implementations§
Source§impl<'de, T, const N: usize> Deserialize<'de> for Line<T, N>where
T: Serialize + DeserializeOwned,
impl<'de, T, const N: usize> Deserialize<'de> for Line<T, N>where
T: Serialize + DeserializeOwned,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a, T, const N: usize> IntoIterator for &'a Line<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a Line<T, N>
Source§impl<'a, T, const N: usize> IntoIterator for &'a mut Line<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a mut Line<T, N>
Source§impl<T, const N: usize> IntoIterator for Line<T, N>
impl<T, const N: usize> IntoIterator for Line<T, N>
impl<T: Copy, const N: usize> Copy for Line<T, N>
impl<T: Eq, const N: usize> Eq for Line<T, N>
impl<T, const N: usize> StructuralPartialEq for Line<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for Line<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for Line<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for Line<T, N>where
T: Send,
impl<T, const N: usize> Sync for Line<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for Line<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for Line<T, N>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.