#[repr(C)]pub struct Rect {
pub x0: f64,
pub y0: f64,
pub x1: f64,
pub y1: f64,
}
Expand description
A rectangle. Derived from kurbo.
Fields§
§x0: f64
The minimum x coordinate (left edge).
y0: f64
The minimum y coordinate (top edge in y-down spaces).
x1: f64
The maximum x coordinate (right edge).
y1: f64
The maximum y coordinate (bottom edge in y-down spaces).
Implementations§
§impl Rect
impl Rect
pub const fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect
pub const fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect
A new rectangle from minimum and maximum coordinates.
pub fn from_points(p0: impl Into<Point>, p1: impl Into<Point>) -> Rect
pub fn from_points(p0: impl Into<Point>, p1: impl Into<Point>) -> Rect
A new rectangle from two points.
The result will have non-negative width and height.
pub fn from_origin_size(origin: impl Into<Point>, size: impl Into<Size>) -> Rect
pub fn from_origin_size(origin: impl Into<Point>, size: impl Into<Size>) -> Rect
A new rectangle from origin and size.
The result will have non-negative width and height.
pub fn with_origin(self, origin: impl Into<Point>) -> Rect
pub fn with_origin(self, origin: impl Into<Point>) -> Rect
Create a new Rect
with the same size as self
and a new origin.
pub fn with_size(self, size: impl Into<Size>) -> Rect
pub fn with_size(self, size: impl Into<Size>) -> Rect
Create a new Rect
with the same origin as self
and a new size.
pub fn origin(&self) -> Point
pub fn origin(&self) -> Point
The origin of the rectangle.
This is the top left corner in a y-down space and with non-negative width and height.
pub fn abs(&self) -> Rect
pub fn abs(&self) -> Rect
Take absolute value of width and height.
The resulting rect has the same extents as the original, but is guaranteed to have non-negative width and height.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this rectangle has zero area.
Note: a rectangle with negative area is not considered empty.
pub fn union(&self, other: Rect) -> Rect
pub fn union(&self, other: Rect) -> Rect
The smallest rectangle enclosing two rectangles.
Results are valid only if width and height are non-negative.
Trait Implementations§
§impl<'de> Deserialize<'de> for Rect
impl<'de> Deserialize<'de> for Rect
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Rect, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Rect, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Rect
impl Serialize for Rect
§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 Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§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
§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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§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