#[repr(transparent)]pub struct Percentage(pub f32);Expand description
A fraction of a whole: 0.5 is 50%, 1.0 all of it. NSH keeps CSS
percentages as fractions everywhere (styles, gradients, transform
origins). Values outside 0..=1 are taken (a gradient stop at 150%,
a -50% translation).
Tuple Fields§
§0: f32Implementations§
Source§impl Percentage
impl Percentage
Sourcepub const ZERO: Percentage
pub const ZERO: Percentage
Zero.
Sourcepub fn abs(self) -> Percentage
pub fn abs(self) -> Percentage
The absolute value.
Sourcepub fn min(self, other: Percentage) -> Percentage
pub fn min(self, other: Percentage) -> Percentage
The smaller of two values.
Sourcepub fn max(self, other: Percentage) -> Percentage
pub fn max(self, other: Percentage) -> Percentage
The larger of two values.
Sourcepub fn clamp(self, min: Percentage, max: Percentage) -> Percentage
pub fn clamp(self, min: Percentage, max: Percentage) -> Percentage
The value within min..=max.
Sourcepub fn floor(self) -> Percentage
pub fn floor(self) -> Percentage
Rounded down.
Sourcepub fn round(self) -> Percentage
pub fn round(self) -> Percentage
Rounded to the nearest whole value.
Sourcepub fn ceil(self) -> Percentage
pub fn ceil(self) -> Percentage
Rounded up.
Trait Implementations§
Source§impl Add for Percentage
impl Add for Percentage
Source§type Output = Percentage
type Output = Percentage
The resulting type after applying the
+ operator.Source§fn add(self, rhs: Percentage) -> Percentage
fn add(self, rhs: Percentage) -> Percentage
Performs the
+ operation. Read moreSource§impl AddAssign for Percentage
impl AddAssign for Percentage
Source§fn add_assign(&mut self, rhs: Percentage)
fn add_assign(&mut self, rhs: Percentage)
Performs the
+= operation. Read moreSource§impl Clone for Percentage
impl Clone for Percentage
Source§fn clone(&self) -> Percentage
fn clone(&self) -> Percentage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Percentage
Source§impl Debug for Percentage
impl Debug for Percentage
Source§impl Default for Percentage
impl Default for Percentage
Source§fn default() -> Percentage
fn default() -> Percentage
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for Percentage
impl<'de> Deserialize<'de> for Percentage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Percentage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Percentage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Percentage
impl Display for Percentage
Source§impl Div for Percentage
The ratio of two values.
impl Div for Percentage
The ratio of two values.
Source§impl Div<f32> for Percentage
impl Div<f32> for Percentage
Source§type Output = Percentage
type Output = Percentage
The resulting type after applying the
/ operator.Source§impl DivAssign<f32> for Percentage
impl DivAssign<f32> for Percentage
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
Performs the
/= operation. Read moreimpl Eq for Percentage
Source§impl From<Percentage> for DefiniteLength
impl From<Percentage> for DefiniteLength
Source§fn from(f: Percentage) -> DefiniteLength
fn from(f: Percentage) -> DefiniteLength
Converts to this type from the input type.
Source§impl From<Percentage> for Length
impl From<Percentage> for Length
Source§fn from(f: Percentage) -> Length
fn from(f: Percentage) -> Length
Converts to this type from the input type.
Source§impl From<Percentage> for Radians
A fraction of a full turn (Radians::from(percentage(0.25)) is a
quarter turn), as in GPUI.
impl From<Percentage> for Radians
A fraction of a full turn (Radians::from(percentage(0.25)) is a
quarter turn), as in GPUI.
Source§fn from(value: Percentage) -> Radians
fn from(value: Percentage) -> Radians
Converts to this type from the input type.
Source§impl From<f32> for Percentage
impl From<f32> for Percentage
Source§fn from(v: f32) -> Percentage
fn from(v: f32) -> Percentage
Converts to this type from the input type.
Source§impl Half for Percentage
impl Half for Percentage
Source§fn half(&self) -> Percentage
fn half(&self) -> Percentage
Half the value.
Source§impl Hash for Percentage
impl Hash for Percentage
Source§impl IntoReactive<DefiniteLength> for Percentage
impl IntoReactive<DefiniteLength> for Percentage
Source§fn into_reactive(self) -> Reactive<DefiniteLength>
fn into_reactive(self) -> Reactive<DefiniteLength>
As a
Reactive.Source§impl IntoReactive<Length> for Percentage
impl IntoReactive<Length> for Percentage
Source§impl IntoReactive<Percentage> for Percentage
impl IntoReactive<Percentage> for Percentage
Source§fn into_reactive(self) -> Reactive<Percentage>
fn into_reactive(self) -> Reactive<Percentage>
As a
Reactive.Source§impl Mul<f32> for Percentage
impl Mul<f32> for Percentage
Source§type Output = Percentage
type Output = Percentage
The resulting type after applying the
* operator.Source§impl MulAssign<f32> for Percentage
impl MulAssign<f32> for Percentage
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
Performs the
*= operation. Read moreSource§impl Neg for Percentage
impl Neg for Percentage
Source§type Output = Percentage
type Output = Percentage
The resulting type after applying the
- operator.Source§fn neg(self) -> Percentage
fn neg(self) -> Percentage
Performs the unary
- operation. Read moreSource§impl PartialEq for Percentage
impl PartialEq for Percentage
Source§impl PartialOrd for Percentage
impl PartialOrd for Percentage
Source§impl Serialize for Percentage
impl Serialize for Percentage
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,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Percentage
Source§impl Sub for Percentage
impl Sub for Percentage
Source§type Output = Percentage
type Output = Percentage
The resulting type after applying the
- operator.Source§fn sub(self, rhs: Percentage) -> Percentage
fn sub(self, rhs: Percentage) -> Percentage
Performs the
- operation. Read moreSource§impl SubAssign for Percentage
impl SubAssign for Percentage
Source§fn sub_assign(&mut self, rhs: Percentage)
fn sub_assign(&mut self, rhs: Percentage)
Performs the
-= operation. Read moreSource§impl Sum for Percentage
impl Sum for Percentage
Source§fn sum<I>(iter: I) -> Percentagewhere
I: Iterator<Item = Percentage>,
fn sum<I>(iter: I) -> Percentagewhere
I: Iterator<Item = Percentage>,
Takes an iterator and generates
Self from the elements by “summing up”
the items.Source§impl<'a> Sum<&'a Percentage> for Percentage
impl<'a> Sum<&'a Percentage> for Percentage
Source§fn sum<I>(iter: I) -> Percentagewhere
I: Iterator<Item = &'a Percentage>,
fn sum<I>(iter: I) -> Percentagewhere
I: Iterator<Item = &'a Percentage>,
Takes an iterator and generates
Self from the elements by “summing up”
the items.Auto Trait Implementations§
impl Freeze for Percentage
impl RefUnwindSafe for Percentage
impl Send for Percentage
impl Sync for Percentage
impl Unpin for Percentage
impl UnsafeUnpin for Percentage
impl UnwindSafe for Percentage
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<E> IntoThrown for Ewhere
E: Display,
impl<E> IntoThrown for Ewhere
E: Display,
Source§fn into_thrown(self) -> Thrown
fn into_thrown(self) -> Thrown
The exception.