Skip to main content

Size

Struct Size 

Source
#[repr(C)]
pub struct Size<T> { pub width: T, pub height: T, }
Expand description

A width and a height.

Fields§

§width: T

The width.

§height: T

The height.

Implementations§

Source§

impl Size<Length>

Source

pub fn auto() -> Size<Length>

Both dimensions auto.

Source

pub fn full() -> Size<Length>

The whole of the parent in both dimensions.

Source§

impl<T> Size<T>

Source

pub const fn new(width: T, height: T) -> Size<T>

A size of width × height.

Source§

impl<T> Size<T>
where T: Clone,

Source

pub fn map<U>(&self, f: impl Fn(T) -> U) -> Size<U>

Both dimensions converted by f.

Source§

impl<T> Size<T>
where T: Clone + PartialOrd,

Source

pub fn max(&self, other: &Size<T>) -> Size<T>

The larger of each dimension of both sizes.

Source

pub fn min(&self, other: &Size<T>) -> Size<T>

The smaller of each dimension of both sizes.

Source§

impl<T> Size<T>
where T: Half,

Source

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

The center of a box of this size at the origin.

Source§

impl Size<Points>

Source

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

Scaled to device pixels at factor (unrounded).

Source

pub fn to_device_pixels(self, scale_factor: f32) -> Size<DevicePixels>

In whole device pixels at scale_factor.

Source§

impl Size<DevicePixels>

Source

pub fn to_points(self, scale_factor: f32) -> Size<Points>

In points at scale_factor device pixels per point.

Trait Implementations§

Source§

impl<T> Add for Size<T>
where T: Add<Output = T>,

Source§

type Output = Size<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T> Along for Size<T>
where T: Clone,

Source§

type Unit = T

The value of one dimension.
Source§

fn along(&self, axis: Axis) -> T

The value along axis.
Source§

fn apply_along(&self, axis: Axis, f: impl FnOnce(T) -> T) -> Size<T>

The value with f applied to the dimension along axis.
Source§

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

Source§

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

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<T> Copy for Size<T>
where T: Copy,

Source§

impl<T> Debug for Size<T>
where T: Debug,

Source§

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

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

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

Source§

fn default() -> Size<T>

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

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

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Size<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, S> Div<S> for Size<T>
where T: Div<S, Output = T>, S: Clone,

Source§

type Output = Size<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: S) -> Size<T>

Performs the / operation. Read more
Source§

impl<T> Eq for Size<T>
where T: Eq,

Source§

impl From<ImageSize> for Size<DevicePixels>

Source§

fn from(s: ImageSize) -> Size<DevicePixels>

Converts to this type from the input type.
Source§

impl<T> From<Point<T>> for Size<T>

Source§

fn from(p: Point<T>) -> Size<T>

Converts to this type from the input type.
Source§

impl<T> From<Size<T>> for Point<T>

Source§

fn from(s: Size<T>) -> Point<T>

Converts to this type from the input type.
Source§

impl From<Size<f32>> for Size<Points>

Source§

fn from(s: Size<f32>) -> Size<Points>

Converts to this type from the input type.
Source§

impl<T> Hash for Size<T>
where T: Hash,

Source§

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

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 for Size<T>
where T: IsZero,

Source§

fn is_zero(&self) -> bool

Either dimension is zero (the size covers no area), as GPUI’s.

Source§

impl JsValue for Size<DevicePixels>

A size in pixels: TS’s PixelSize ({ width, height }).

Source§

fn ts_type(_types: &mut TsTypes) -> String

Its TypeScript type (string, AlertButton), declaring the named types it uses in types.
Source§

fn from_js(value: JsIn<'_>) -> Result<Size<DevicePixels>, PropError>

The value of JS value value.
Source§

fn to_js<'a>(&self, host: &'a dyn JsHost) -> Result<JsOwned<'a>, PropError>

The value as a JS value of host.
Source§

impl JsValue for Size<Points>

A size in points: TS’s Size ({ width, height }).

Source§

fn ts_type(_types: &mut TsTypes) -> String

Its TypeScript type (string, AlertButton), declaring the named types it uses in types.
Source§

fn from_js(value: JsIn<'_>) -> Result<Size<Points>, PropError>

The value of JS value value.
Source§

fn to_js<'a>(&self, host: &'a dyn JsHost) -> Result<JsOwned<'a>, PropError>

The value as a JS value of host.
Source§

impl<T, S> Mul<S> for Size<T>
where T: Mul<S, Output = T>, S: Clone,

Source§

type Output = Size<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: S) -> Size<T>

Performs the * operation. Read more
Source§

impl<T, S> MulAssign<S> for Size<T>
where T: MulAssign<S>, S: Clone,

Source§

fn mul_assign(&mut self, rhs: S)

Performs the *= operation. Read more
Source§

impl<T> PartialEq for Size<T>
where T: PartialEq,

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl<T> Serialize for Size<T>
where T: Serialize,

Source§

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

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

impl<T> StructuralPartialEq for Size<T>
where T: PartialEq,

Source§

impl<T> Sub for Size<T>
where T: Sub<Output = T>,

Source§

type Output = Size<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T> Forget for Size<T>

§

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

§

impl<T> Move for Size<T>

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for Size<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Size<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> Arg for T
where T: JsValue,

Source§

fn ts_type(types: &mut TsTypes) -> String

Its TypeScript type.
Source§

fn from_js(value: JsIn<'_>) -> Result<T, PropError>

The value of a JS argument.
Source§

impl<T> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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> CallbackArgs for T
where T: Ret,

Source§

const ARITY: usize

How many there are.
Source§

fn ts_params(types: &mut TsTypes, names: &[&str]) -> String

Its TypeScript parameters, named names (name: string, amount: number), or without names value for one and a, b, … for several.
Source§

fn into_js_args<'a>( self, host: &'a dyn JsHost, ) -> Result<Vec<JsOwned<'a>>, PropError>

The arguments as JS values.
Source§

fn classes(out: &mut Vec<&'static ClassDef>)

Source§

impl<T> CallbackRet for T
where T: JsValue,

Source§

fn ts_type(types: &mut TsTypes) -> String

Its TypeScript type.
Source§

fn from_js(value: JsIn<'_>) -> Result<T, PropError>

The value the function returned.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<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> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Ret for T
where T: JsValue,

Source§

fn ts_type(types: &mut TsTypes) -> String

Its TypeScript type.
Source§

fn into_js<'a>(self, host: &'a dyn JsHost) -> Result<JsOwned<'a>, PropError>

The value for JS.
Source§

const UNIT: bool = false

(): nothing (a callback taking it has no parameters).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,

Source§

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
where T: for<'r> ScalarMul<&'r Rhs, Output>,

Source§

impl<T> ToJs for T
where T: Ret + 'static,

Source§

fn to_js_value<'a>( self: Box<T>, host: &'a dyn JsHost, ) -> Result<JsOwned<'a>, PropError>

The value as a JS value of host.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<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