Bounds

Struct Bounds 

Source
#[repr(C)]
pub struct Bounds<T: Clone + Debug + Default + PartialEq> { pub origin: Point<T>, pub size: Size<T>, }
Expand description

Represents a rectangular area in a 2D space with an origin point and a size.

The Bounds struct is generic over a type T which represents the type of the coordinate system. The origin is represented as a Point<T> which defines the top left corner of the rectangle, and the size is represented as a Size<T> which defines the width and height of the rectangle.

§Examples

let origin = Point { x: 0, y: 0 };
let size = Size { width: 10, height: 20 };
let bounds = Bounds::new(origin, size);

assert_eq!(bounds.origin, origin);
assert_eq!(bounds.size, size);

Fields§

§origin: Point<T>

The origin point of this area.

§size: Size<T>

The size of the rectangle.

Implementations§

Source§

impl Bounds<Pixels>

Source

pub fn centered( display_id: Option<DisplayId>, size: Size<Pixels>, cx: &App, ) -> Self

Generate a centered bounds for the given display or primary display if none is provided

Source

pub fn maximized(display_id: Option<DisplayId>, cx: &App) -> Self

Generate maximized bounds for the given display or primary display if none is provided

Source§

impl<T> Bounds<T>
where T: Clone + Debug + Default + PartialEq,

Source

pub fn new(origin: Point<T>, size: Size<T>) -> Self

Creates a new Bounds with the specified origin and size.

§Arguments
  • origin - A Point<T> representing the origin of the bounds.
  • size - A Size<T> representing the size of the bounds.
§Returns

Returns a Bounds<T> that has the given origin and size.

Source§

impl<T> Bounds<T>
where T: Sub<Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn from_corners(top_left: Point<T>, bottom_right: Point<T>) -> Self

Constructs a Bounds from two corner points: the top left and bottom right corners.

This function calculates the origin and size of the Bounds based on the provided corner points. The origin is set to the top left corner, and the size is determined by the difference between the x and y coordinates of the bottom right and top left points.

§Arguments
  • top_left - A Point<T> representing the top left corner of the rectangle.
  • bottom_right - A Point<T> representing the bottom right corner of the rectangle.
§Returns

Returns a Bounds<T> that encompasses the area defined by the two corner points.

§Examples
let top_left = Point { x: 0, y: 0 };
let bottom_right = Point { x: 10, y: 10 };
let bounds = Bounds::from_corners(top_left, bottom_right);

assert_eq!(bounds.origin, top_left);
assert_eq!(bounds.size.width, 10);
assert_eq!(bounds.size.height, 10);
Source

pub fn from_corner_and_size( corner: Corner, origin: Point<T>, size: Size<T>, ) -> Bounds<T>

Constructs a Bounds from a corner point and size. The specified corner will be placed at the specified origin.

Source§

impl<T> Bounds<T>
where T: Sub<T, Output = T> + Half + Clone + Debug + Default + PartialEq,

Source

pub fn centered_at(center: Point<T>, size: Size<T>) -> Self

Creates a new bounds centered at the given point.

Source§

impl<T> Bounds<T>
where T: PartialOrd + Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn intersects(&self, other: &Bounds<T>) -> bool

Checks if this Bounds intersects with another Bounds.

Two Bounds instances intersect if they overlap in the 2D space they occupy. This method checks if there is any overlapping area between the two bounds.

§Arguments
  • other - A reference to another Bounds to check for intersection with.
§Returns

Returns true if there is any intersection between the two bounds, false otherwise.

§Examples
let bounds1 = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
let bounds2 = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 10, height: 10 },
};
let bounds3 = Bounds {
    origin: Point { x: 20, y: 20 },
    size: Size { width: 10, height: 10 },
};

assert_eq!(bounds1.intersects(&bounds2), true); // Overlapping bounds
assert_eq!(bounds1.intersects(&bounds3), false); // Non-overlapping bounds
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Half + Clone + Debug + Default + PartialEq,

Source

pub fn center(&self) -> Point<T>

Returns the center point of the bounds.

Calculates the center by taking the origin’s x and y coordinates and adding half the width and height of the bounds, respectively. The center is represented as a Point<T> where T is the type of the coordinate system.

§Returns

A Point<T> representing the center of the bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
let center = bounds.center();
assert_eq!(center, Point { x: 5, y: 10 });
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn half_perimeter(&self) -> T

Calculates the half perimeter of a rectangle defined by the bounds.

The half perimeter is calculated as the sum of the width and the height of the rectangle. This method is generic over the type T which must implement the Sub trait to allow calculation of the width and height from the bounds’ origin and size, as well as the Add trait to sum the width and height for the half perimeter.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
let half_perimeter = bounds.half_perimeter();
assert_eq!(half_perimeter, 30);
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn dilate(&self, amount: T) -> Bounds<T>

Dilates the bounds by a specified amount in all directions.

This method expands the bounds by the given amount, increasing the size and adjusting the origin so that the bounds grow outwards equally in all directions. The resulting bounds will have its width and height increased by twice the amount (since it grows in both directions), and the origin will be moved by -amount in both the x and y directions.

§Arguments
  • amount - The amount by which to dilate the bounds.
§Examples
let mut bounds = Bounds {
    origin: Point { x: 10, y: 10 },
    size: Size { width: 10, height: 10 },
};
let expanded_bounds = bounds.dilate(5);
assert_eq!(expanded_bounds, Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 20, height: 20 },
});
Source

pub fn extend(&self, amount: Edges<T>) -> Bounds<T>

Extends the bounds different amounts in each direction.

Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + Neg<Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn inset(&self, amount: T) -> Self

Inset the bounds by a specified amount. Equivalent to dilate with the amount negated.

Note that this may panic if T does not support negative values.

Source§

impl<T: PartialOrd + Add<T, Output = T> + Sub<Output = T> + Clone + Debug + Default + PartialEq> Bounds<T>

Source

pub fn intersect(&self, other: &Self) -> Self

Calculates the intersection of two Bounds objects.

This method computes the overlapping region of two Bounds. If the bounds do not intersect, the resulting Bounds will have a size with width and height of zero.

§Arguments
  • other - A reference to another Bounds to intersect with.
§Returns

Returns a Bounds representing the intersection area. If there is no intersection, the returned Bounds will have a size with width and height of zero.

§Examples
let bounds1 = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
let bounds2 = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 10, height: 10 },
};
let intersection = bounds1.intersect(&bounds2);

assert_eq!(intersection, Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 5, height: 5 },
});
Source

pub fn union(&self, other: &Self) -> Self

Computes the union of two Bounds.

This method calculates the smallest Bounds that contains both the current Bounds and the other Bounds. The resulting Bounds will have an origin that is the minimum of the origins of the two Bounds, and a size that encompasses the furthest extents of both Bounds.

§Arguments
  • other - A reference to another Bounds to create a union with.
§Returns

Returns a Bounds representing the union of the two Bounds.

§Examples
let bounds1 = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
let bounds2 = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 15, height: 15 },
};
let union_bounds = bounds1.union(&bounds2);

assert_eq!(union_bounds, Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 20, height: 20 },
});
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn space_within(&self, outer: &Self) -> Edges<T>

Computes the space available within outer bounds.

Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn top(&self) -> T

Returns the top edge of the bounds.

§Returns

A value of type T representing the y-coordinate of the top edge of the bounds.

Source

pub fn bottom(&self) -> T

Returns the bottom edge of the bounds.

§Returns

A value of type T representing the y-coordinate of the bottom edge of the bounds.

Source

pub fn left(&self) -> T

Returns the left edge of the bounds.

§Returns

A value of type T representing the x-coordinate of the left edge of the bounds.

Source

pub fn right(&self) -> T

Returns the right edge of the bounds.

§Returns

A value of type T representing the x-coordinate of the right edge of the bounds.

Source

pub fn top_right(&self) -> Point<T>

Returns the top right corner point of the bounds.

§Returns

A Point<T> representing the top right corner of the bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
let top_right = bounds.top_right();
assert_eq!(top_right, Point { x: 10, y: 0 });
Source

pub fn bottom_right(&self) -> Point<T>

Returns the bottom right corner point of the bounds.

§Returns

A Point<T> representing the bottom right corner of the bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
let bottom_right = bounds.bottom_right();
assert_eq!(bottom_right, Point { x: 10, y: 20 });
Source

pub fn bottom_left(&self) -> Point<T>

Returns the bottom left corner point of the bounds.

§Returns

A Point<T> representing the bottom left corner of the bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
let bottom_left = bounds.bottom_left();
assert_eq!(bottom_left, Point { x: 0, y: 20 });
Source

pub fn corner(&self, corner: Corner) -> Point<T>

Returns the requested corner point of the bounds.

§Returns

A Point<T> representing the corner of the bounds requested by the parameter.

§Examples
use gpui::{Bounds, Corner, Point, Size};
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
let bottom_left = bounds.corner(Corner::BottomLeft);
assert_eq!(bottom_left, Point { x: 0, y: 20 });
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + PartialOrd + Clone + Debug + Default + PartialEq,

Source

pub fn contains(&self, point: &Point<T>) -> bool

Checks if the given point is within the bounds.

This method determines whether a point lies inside the rectangle defined by the bounds, including the edges. The point is considered inside if its x-coordinate is greater than or equal to the left edge and less than or equal to the right edge, and its y-coordinate is greater than or equal to the top edge and less than or equal to the bottom edge of the bounds.

§Arguments
  • point - A reference to a Point<T> that represents the point to check.
§Returns

Returns true if the point is within the bounds, false otherwise.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
let inside_point = Point { x: 5, y: 5 };
let outside_point = Point { x: 15, y: 15 };

assert!(bounds.contains(&inside_point));
assert!(!bounds.contains(&outside_point));
Source

pub fn is_contained_within(&self, other: &Self) -> bool

Checks if this bounds is completely contained within another bounds.

This method determines whether the current bounds is entirely enclosed by the given bounds. A bounds is considered to be contained within another if its origin (top-left corner) and its bottom-right corner are both contained within the other bounds.

§Arguments
  • other - A reference to another Bounds that might contain this bounds.
§Returns

Returns true if this bounds is completely inside the other bounds, false otherwise.

§Examples
let outer_bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 20, height: 20 },
};
let inner_bounds = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 10, height: 10 },
};
let overlapping_bounds = Bounds {
    origin: Point { x: 15, y: 15 },
    size: Size { width: 10, height: 10 },
};

assert!(inner_bounds.is_contained_within(&outer_bounds));
assert!(!overlapping_bounds.is_contained_within(&outer_bounds));
Source

pub fn map<U>(&self, f: impl Fn(T) -> U) -> Bounds<U>
where U: Clone + Debug + Default + PartialEq,

Applies a function to the origin and size of the bounds, producing a new Bounds<U>.

This method allows for converting a Bounds<T> to a Bounds<U> by specifying a closure that defines how to convert between the two types. The closure is applied to the origin and size fields, resulting in new bounds of the desired type.

§Arguments
  • f - A closure that takes a value of type T and returns a value of type U.
§Returns

Returns a new Bounds<U> with the origin and size mapped by the provided function.

§Examples
let bounds = Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 10.0, height: 20.0 },
};
let new_bounds = bounds.map(|value| value as f64 * 1.5);

assert_eq!(new_bounds, Bounds {
    origin: Point { x: 15.0, y: 15.0 },
    size: Size { width: 15.0, height: 30.0 },
});
Source

pub fn map_origin(self, f: impl Fn(T) -> T) -> Bounds<T>

Applies a function to the origin of the bounds, producing a new Bounds with the new origin

§Examples
let bounds = Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 10.0, height: 20.0 },
};
let new_bounds = bounds.map_origin(|value| value * 1.5);

assert_eq!(new_bounds, Bounds {
    origin: Point { x: 15.0, y: 15.0 },
    size: Size { width: 10.0, height: 20.0 },
});
Source

pub fn map_size(self, f: impl Fn(T) -> T) -> Bounds<T>

Applies a function to the origin of the bounds, producing a new Bounds with the new origin

§Examples
let bounds = Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 10.0, height: 20.0 },
};
let new_bounds = bounds.map_size(|value| value * 1.5);

assert_eq!(new_bounds, Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 15.0, height: 30.0 },
});
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + PartialOrd + Clone + Debug + Default + PartialEq,

Source

pub fn localize(&self, point: &Point<T>) -> Option<Point<T>>

Convert a point to the coordinate space defined by this Bounds

Source§

impl<T: PartialOrd + Clone + Debug + Default + PartialEq> Bounds<T>

Checks if the bounds represent an empty area.

§Returns

Returns true if either the width or the height of the bounds is less than or equal to zero, indicating an empty area.

Source

pub fn is_empty(&self) -> bool

Checks if the bounds represent an empty area.

§Returns

Returns true if either the width or the height of the bounds is less than or equal to zero, indicating an empty area.

Source§

impl Bounds<Pixels>

Source

pub fn scale(&self, factor: f32) -> Bounds<ScaledPixels>

Scales the bounds by a given factor, typically used to adjust for display scaling.

This method multiplies the origin and size of the bounds by the provided scaling factor, resulting in a new Bounds<ScaledPixels> that is proportionally larger or smaller depending on the scaling factor. This can be used to ensure that the bounds are properly scaled for different display densities.

§Arguments
  • factor - The scaling factor to apply to the origin and size, typically the display’s scaling factor.
§Returns

Returns a new Bounds<ScaledPixels> that represents the scaled bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: Pixels::from(10.0), y: Pixels::from(20.0) },
    size: Size { width: Pixels::from(30.0), height: Pixels::from(40.0) },
};
let display_scale_factor = 2.0;
let scaled_bounds = bounds.scale(display_scale_factor);
assert_eq!(scaled_bounds, Bounds {
    origin: Point {
        x: ScaledPixels::from(20.0),
        y: ScaledPixels::from(40.0),
    },
    size: Size {
        width: ScaledPixels::from(60.0),
        height: ScaledPixels::from(80.0)
    },
});
Source

pub fn to_device_pixels(self, factor: f32) -> Bounds<DevicePixels>

Convert the bounds from logical pixels to physical pixels

Source§

impl Bounds<DevicePixels>

Source

pub fn to_pixels(self, scale_factor: f32) -> Bounds<Pixels>

Convert the bounds from physical pixels to logical pixels

Trait Implementations§

Source§

impl<T> Add<Point<T>> for Bounds<T>
where T: Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source§

type Output = Bounds<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Point<T>) -> Self

Performs the + operation. Read more
Source§

impl<T: Clone + Clone + Debug + Default + PartialEq> Clone for Bounds<T>

Source§

fn clone(&self) -> Bounds<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Clone + Debug + Default + PartialEq> Debug for Bounds<T>

Source§

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

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

impl<T: Default + Clone + Debug + Default + PartialEq> Default for Bounds<T>

Source§

fn default() -> Bounds<T>

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

impl<'de, T> Deserialize<'de> for Bounds<T>
where T: Deserialize<'de> + Clone + Debug + Default + PartialEq,

Source§

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<T: Clone + Debug + Default + PartialEq + Display + Add<T, Output = T>> Display for Bounds<T>

Source§

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

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

impl<T, S> Div<S> for Bounds<T>
where Size<T>: Div<S, Output = Size<T>>, T: Div<S, Output = T> + Clone + Debug + Default + PartialEq, S: Clone,

Source§

type Output = Bounds<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: S) -> Self

Performs the / operation. Read more
Source§

impl<T: Clone + Debug + Default + PartialEq> From<BoundsRefinement<T>> for Bounds<T>
where Option<Point<T>>: Clone, Option<Size<T>>: Clone,

Source§

fn from(value: BoundsRefinement<T>) -> Self

Converts to this type from the input type.
Source§

impl From<Box2D<i32, UnknownUnit>> for Bounds<DevicePixels>

Source§

fn from(rectangle: Rectangle) -> Self

Converts to this type from the input type.
Source§

impl From<RectF> for Bounds<f32>

Source§

fn from(rect: RectF) -> Self

Converts to this type from the input type.
Source§

impl From<RectI> for Bounds<DevicePixels>

Source§

fn from(rect: RectI) -> Self

Converts to this type from the input type.
Source§

impl From<RectI> for Bounds<i32>

Source§

fn from(rect: RectI) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash + Clone + Debug + Default + PartialEq> Hash for Bounds<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: IsZero + Clone + Debug + Default + PartialEq> IsZero for Bounds<T>

Source§

fn is_zero(&self) -> bool

Determines if the value is zero. Read more
Source§

impl<T, Rhs> Mul<Rhs> for Bounds<T>
where T: Mul<Rhs, Output = Rhs> + Clone + Debug + Default + PartialEq, Point<T>: Mul<Rhs, Output = Point<Rhs>>, Rhs: Clone + Debug + Default + PartialEq,

Source§

type Output = Bounds<Rhs>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rhs) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, S> MulAssign<S> for Bounds<T>
where T: Mul<S, Output = T> + Clone + Debug + Default + PartialEq, S: Clone,

Source§

fn mul_assign(&mut self, rhs: S)

Performs the *= operation. Read more
Source§

impl<T: PartialEq + Clone + Debug + Default + PartialEq> PartialEq for Bounds<T>

Source§

fn eq(&self, other: &Bounds<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Clone + Debug + Default + PartialEq> Refineable for Bounds<T>
where Option<Point<T>>: Clone, Option<Size<T>>: Clone,

Source§

type Refinement = BoundsRefinement<T>

Source§

fn refine(&mut self, refinement: &Self::Refinement)

Applies the given refinement to this instance, modifying it in place. Read more
Source§

fn refined(self, refinement: Self::Refinement) -> Self

Returns a new instance with the refinement applied, equivalent to cloning self and calling refine on it.
Source§

fn is_superset_of(&self, refinement: &Self::Refinement) -> bool

Returns true if this instance would contain all values from the refinement. Read more
Source§

fn subtract(&self, refinement: &Self::Refinement) -> Self::Refinement

Returns a refinement that represents the difference between this instance and the given refinement. Read more
Source§

fn from_cascade(cascade: &Cascade<Self>) -> Self
where Self: Sized + Default,

Creates an instance from a cascade by merging all refinements atop the default value.
Source§

impl<T> Serialize for Bounds<T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Sub<Point<T>> for Bounds<T>
where T: Sub<T, Output = T> + Clone + Debug + Default + PartialEq,

Source§

type Output = Bounds<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Point<T>) -> Self

Performs the - operation. Read more
Source§

impl<T: Copy + Clone + Debug + Default + PartialEq> Copy for Bounds<T>

Source§

impl<T: Eq + Clone + Debug + Default + PartialEq> Eq for Bounds<T>

Source§

impl<T: Clone + Debug + Default + PartialEq> StructuralPartialEq for Bounds<T>

Auto Trait Implementations§

§

impl<T> Freeze for Bounds<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Bounds<T>
where T: RefUnwindSafe,

§

impl<T> Send for Bounds<T>
where T: Send,

§

impl<T> Sync for Bounds<T>
where T: Sync,

§

impl<T> Unpin for Bounds<T>
where T: Unpin,

§

impl<T> UnwindSafe for Bounds<T>
where T: 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,