pub struct Edge { /* private fields */ }
Expand description
An edge of a rectangle.
Implementations§
source§impl Edge
impl Edge
sourcepub fn side(&self) -> Side
pub fn side(&self) -> Side
The side (of a rectangle) to which this edge corresponds.
§Example
let edge = Edge::new(Side::Left, 20, Span::new(40, 100));
assert_eq!(edge.side(), Side::Left);
sourcepub fn coord(&self) -> i64
pub fn coord(&self) -> i64
The coordinate of the edge.
For left/right edges, this will be the x coordinate of the edge. For top/bottom edges, this will be the y coordinate of the edge.
§Example
let edge = Edge::new(Side::Left, 20, Span::new(40, 100));
assert_eq!(edge.coord(), 20);
sourcepub fn span(&self) -> Span
pub fn span(&self) -> Span
The span of the edge.
For left/right edges, this will be the range of y-coordinates encompassed by the edge. For top/bottom edges, this will be the range of x-coordinates encompassed by the edge.
§Example
let edge = Edge::new(Side::Left, 20, Span::new(40, 100));
assert_eq!(edge.span(), Span::new(40, 100));
sourcepub fn with_span(&self, span: Span) -> Edge
pub fn with_span(&self, span: Span) -> Edge
Returns an Edge
with the same properties as the provided Edge
but with a new span.
§Example
let edge = Edge::new(Side::Left, 20, Span::new(40, 100));
assert_eq!(edge.span(), Span::new(40, 100));
let edge_new = edge.with_span(Span::new(20, 100));
assert_eq!(edge_new.span(), Span::new(20, 100));
sourcepub fn norm_dir(&self) -> Dir
pub fn norm_dir(&self) -> Dir
The direction perpendicular to the edge.
For left/right edges, this will be Dir::Horiz
.
For top/bottom edges, this will be Dir::Vert
.
§Example
let edge = Edge::new(Side::Left, 20, Span::new(40, 100));
assert_eq!(edge.norm_dir(), Dir::Horiz);
let edge = Edge::new(Side::Right, 20, Span::new(40, 100));
assert_eq!(edge.norm_dir(), Dir::Horiz);
let edge = Edge::new(Side::Top, 20, Span::new(40, 100));
assert_eq!(edge.norm_dir(), Dir::Vert);
let edge = Edge::new(Side::Bot, 20, Span::new(40, 100));
assert_eq!(edge.norm_dir(), Dir::Vert);
sourcepub fn edge_dir(&self) -> Dir
pub fn edge_dir(&self) -> Dir
The direction parallel to the edge.
For left/right edges, this will be Dir::Vert
.
For top/bottom edges, this will be Dir::Horiz
.
§Example
let edge = Edge::new(Side::Left, 20, Span::new(40, 100));
assert_eq!(edge.edge_dir(), Dir::Vert);
let edge = Edge::new(Side::Right, 20, Span::new(40, 100));
assert_eq!(edge.edge_dir(), Dir::Vert);
let edge = Edge::new(Side::Top, 20, Span::new(40, 100));
assert_eq!(edge.edge_dir(), Dir::Horiz);
let edge = Edge::new(Side::Bot, 20, Span::new(40, 100));
assert_eq!(edge.edge_dir(), Dir::Horiz);
sourcepub fn offset(&self, offset: i64) -> Edge
pub fn offset(&self, offset: i64) -> Edge
Returns a new Edge
offset some amount away from this edge.
Left edges will be offset to the left; right edges will be offset to the right. Top edges will be offset upwards; bottom edges will be offset downwards.
§Example
let edge = Edge::new(Side::Left, 20, Span::new(40, 100));
assert_eq!(edge.offset(10), Edge::new(Side::Left, 10, Span::new(40, 100)));
let edge = Edge::new(Side::Top, 20, Span::new(40, 100));
assert_eq!(edge.offset(10), Edge::new(Side::Top, 30, Span::new(40, 100)));
Trait Implementations§
source§impl<'de> Deserialize<'de> for Edge
impl<'de> Deserialize<'de> for Edge
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Edge, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Edge, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Edge
impl PartialEq for Edge
source§impl Serialize for Edge
impl Serialize for Edge
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Edge
impl Eq for Edge
impl StructuralPartialEq for Edge
Auto Trait Implementations§
impl RefUnwindSafe for Edge
impl Send for Edge
impl Sync for Edge
impl Unpin for Edge
impl UnwindSafe for Edge
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
source§impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Flipped<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Flipped<T>) -> U
fn from_layout_type(other: &Flipped<T>) -> U
source§impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<InOut<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &InOut<T>) -> U
fn from_layout_type(other: &InOut<T>) -> U
source§impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Input<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Input<T>) -> U
fn from_layout_type(other: &Input<T>) -> U
source§impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
impl<T, U> CustomHardwareType<Output<T>> for Uwhere
U: CustomHardwareType<T>,
T: HardwareType,
source§fn from_layout_type(other: &Output<T>) -> U
fn from_layout_type(other: &Output<T>) -> U
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request