Struct zng_unit::SideOffsets2D
source · pub struct SideOffsets2D<T, U> {
pub top: T,
pub right: T,
pub bottom: T,
pub left: T,
/* private fields */
}
Expand description
A group of 2D side offsets, which correspond to top/right/bottom/left for borders, padding, and margins in CSS, optionally tagged with a unit.
Fields§
§top: T
Top offset.
right: T
Right offset.
bottom: T
Bottom offset.
left: T
Left offset.
Implementations§
source§impl<T, U> SideOffsets2D<T, U>
impl<T, U> SideOffsets2D<T, U>
sourcepub const fn new(top: T, right: T, bottom: T, left: T) -> Self
pub const fn new(top: T, right: T, bottom: T, left: T) -> Self
Constructor taking a scalar for each side.
Sides are specified in top-right-bottom-left order following CSS’s convention.
sourcepub fn from_vectors_outer(min: Vector2D<T, U>, max: Vector2D<T, U>) -> Selfwhere
T: Neg<Output = T>,
pub fn from_vectors_outer(min: Vector2D<T, U>, max: Vector2D<T, U>) -> Selfwhere
T: Neg<Output = T>,
Construct side offsets from min and a max vector offsets.
The outer rect of the resulting side offsets is equivalent to translating a rectangle’s upper-left corner with the min vector and translating the bottom-right corner with the max vector.
sourcepub fn from_vectors_inner(min: Vector2D<T, U>, max: Vector2D<T, U>) -> Selfwhere
T: Neg<Output = T>,
pub fn from_vectors_inner(min: Vector2D<T, U>, max: Vector2D<T, U>) -> Selfwhere
T: Neg<Output = T>,
Construct side offsets from min and a max vector offsets.
The inner rect of the resulting side offsets is equivalent to translating a rectangle’s upper-left corner with the min vector and translating the bottom-right corner with the max vector.
sourcepub fn is_zero(&self) -> boolwhere
T: Zero + PartialEq,
pub fn is_zero(&self) -> boolwhere
T: Zero + PartialEq,
Returns true
if all side offsets are zero.
sourcepub fn new_all_same(all: T) -> Selfwhere
T: Copy,
pub fn new_all_same(all: T) -> Selfwhere
T: Copy,
Constructor setting the same value to all sides, taking a scalar value directly.
sourcepub fn horizontal(&self) -> T
pub fn horizontal(&self) -> T
Left + right.
Trait Implementations§
source§impl<T, U> Add for SideOffsets2D<T, U>where
T: Add<T, Output = T>,
impl<T, U> Add for SideOffsets2D<T, U>where
T: Add<T, Output = T>,
source§impl<T, U> AddAssign for SideOffsets2D<T, U>where
T: AddAssign<T>,
impl<T, U> AddAssign for SideOffsets2D<T, U>where
T: AddAssign<T>,
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moresource§impl<T: Clone, U> Clone for SideOffsets2D<T, U>
impl<T: Clone, U> Clone for SideOffsets2D<T, U>
source§impl<T: Debug, U> Debug for SideOffsets2D<T, U>
impl<T: Debug, U> Debug for SideOffsets2D<T, U>
source§impl<T: Default, U> Default for SideOffsets2D<T, U>
impl<T: Default, U> Default for SideOffsets2D<T, U>
source§impl<'de, T, U> Deserialize<'de> for SideOffsets2D<T, U>where
T: Deserialize<'de>,
impl<'de, T, U> Deserialize<'de> for SideOffsets2D<T, U>where
T: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<T: Copy + DivAssign, U> DivAssign<Scale<T, U, U>> for SideOffsets2D<T, U>
impl<T: Copy + DivAssign, U> DivAssign<Scale<T, U, U>> for SideOffsets2D<T, U>
source§fn div_assign(&mut self, other: Scale<T, U, U>)
fn div_assign(&mut self, other: Scale<T, U, U>)
/=
operation. Read moresource§impl<T: Copy + DivAssign, U> DivAssign<T> for SideOffsets2D<T, U>
impl<T: Copy + DivAssign, U> DivAssign<T> for SideOffsets2D<T, U>
source§fn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
/=
operation. Read moresource§impl<T, U> From<SideOffsets2D<T, U>> for SideOffsets2D<T, U>
impl<T, U> From<SideOffsets2D<T, U>> for SideOffsets2D<T, U>
source§impl<T, U> From<SideOffsets2D<T, U>> for SideOffsets2D<T, U>
impl<T, U> From<SideOffsets2D<T, U>> for SideOffsets2D<T, U>
source§fn from(value: SideOffsets2D<T, U>) -> Self
fn from(value: SideOffsets2D<T, U>) -> Self
source§impl<T, U> Hash for SideOffsets2D<T, U>where
T: Hash,
impl<T, U> Hash for SideOffsets2D<T, U>where
T: Hash,
source§impl<T: Copy + MulAssign, U> MulAssign<Scale<T, U, U>> for SideOffsets2D<T, U>
impl<T: Copy + MulAssign, U> MulAssign<Scale<T, U, U>> for SideOffsets2D<T, U>
source§fn mul_assign(&mut self, other: Scale<T, U, U>)
fn mul_assign(&mut self, other: Scale<T, U, U>)
*=
operation. Read moresource§impl<T: Copy + MulAssign, U> MulAssign<T> for SideOffsets2D<T, U>
impl<T: Copy + MulAssign, U> MulAssign<T> for SideOffsets2D<T, U>
source§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
*=
operation. Read moresource§impl<T, U> Neg for SideOffsets2D<T, U>where
T: Neg<Output = T>,
impl<T, U> Neg for SideOffsets2D<T, U>where
T: Neg<Output = T>,
source§impl<T, U> PartialEq for SideOffsets2D<T, U>where
T: PartialEq,
impl<T, U> PartialEq for SideOffsets2D<T, U>where
T: PartialEq,
source§impl<T, U> Serialize for SideOffsets2D<T, U>where
T: Serialize,
impl<T, U> Serialize for SideOffsets2D<T, U>where
T: Serialize,
source§impl<T, U> Sub for SideOffsets2D<T, U>where
T: Sub<T, Output = T>,
impl<T, U> Sub for SideOffsets2D<T, U>where
T: Sub<T, Output = T>,
source§impl<T, U> SubAssign for SideOffsets2D<T, U>where
T: SubAssign<T>,
impl<T, U> SubAssign for SideOffsets2D<T, U>where
T: SubAssign<T>,
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-=
operation. Read moreimpl<T: Copy, U> Copy for SideOffsets2D<T, U>
impl<T, U> Eq for SideOffsets2D<T, U>where
T: Eq,
Auto Trait Implementations§
impl<T, U> Freeze for SideOffsets2D<T, U>where
T: Freeze,
impl<T, U> RefUnwindSafe for SideOffsets2D<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for SideOffsets2D<T, U>
impl<T, U> Sync for SideOffsets2D<T, U>
impl<T, U> Unpin for SideOffsets2D<T, U>
impl<T, U> UnwindSafe for SideOffsets2D<T, U>where
T: UnwindSafe,
U: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)