`#[repr(C)]pub struct Lp(/* private fields */);`

## Expand description

Logical pixels, a device-independent measurement

A logical pixel is equivalent to a single pixel on a 96-DPI display. However,
this unit is scaled when converiting to `Px`

to honor the target display’s
actual DPI.

For example, consider these assertions:

```
use figures::units::{Lp, Px};
use figures::{Fraction, ScreenScale};
// Scaling factor of 1.0
assert_eq!(Lp::new(1).into_px(Fraction::new_whole(1)), Px::new(1));
// Scaling factor of 2.0
assert_eq!(Lp::new(1).into_px(Fraction::new_whole(2)), Px::new(2));
// Scaling factor of 0.5
assert_eq!(Lp::new(1).into_px(Fraction::new(1, 2)), Px::from(0.5));
```

Logical pixels are designed around several use cases. Internally, this type uses integers to represent logical pixels, which ensures that math is always predictable, and any precision loss is controllable by the developer.

To ensure that the `Lp`

type has as little precision loss as possible, it uses a
scale of 1,905 subpixels . This number may seem arbitrary, but it is a multiple
of the prime numbers 3, 5, and 127. These numbers are important because:

- 72: Typographic points are defined as 72 points per inch, and the prime
factorization is
`2^3 * 3^2`

. - 96: A scaling factor of 1 is defined as 96 pixels per inchm, and the prime
factorization is
`2^5 * 3`

. - 254: Allows using metric units lossleslly because 2.54cm = 1in, and it’s prime
factorization is
`2 * 127`

- 5: Five is a low common prime, and everyone likes round numbers.

Because the `Lp`

scale is arbitrary and hard to reason about, this type has many
constructors to allow specifying measurements in various units developers will
be more comfortable with:

```
use figures::units::Lp;
// Centimeters
assert_eq!(Lp::cm_f(1.), Lp::cm(1));
// Millimeters
assert_eq!(Lp::mm_f(1.), Lp::mm(1));
assert_eq!(Lp::mm(10), Lp::cm(1));
// Inches
assert_eq!(Lp::inches_f(1.), Lp::inches(1));
assert_eq!(Lp::inches(1), Lp::cm_f(2.54));
// Points
assert_eq!(Lp::points_f(36.), Lp::points(36));
assert_eq!(Lp::points(36), Lp::inches_f(0.5));
```

## Implementations§

source§### impl Lp

### impl Lp

source#### pub const fn saturating_sub(self, other: Self) -> Self

#### pub const fn saturating_sub(self, other: Self) -> Self

source#### pub const fn saturating_add(self, other: Self) -> Self

#### pub const fn saturating_add(self, other: Self) -> Self

source#### pub const fn saturating_mul(self, other: Self) -> Self

#### pub const fn saturating_mul(self, other: Self) -> Self

source#### pub const fn saturating_div(self, other: Self) -> Self

#### pub const fn saturating_div(self, other: Self) -> Self

source§### impl Lp

### impl Lp

source#### pub const fn points(points: i32) -> Self

#### pub const fn points(points: i32) -> Self

Returns a value equivalent to the number of `points`

provided. One
point is 1/72 of an
inch.

source#### pub fn points_f(points: f32) -> Self

#### pub fn points_f(points: f32) -> Self

Returns a value equivalent to the number of `points`

provided. One
point is 1/72 of an
inch.

source#### pub const fn cm(centimeters: i32) -> Self

#### pub const fn cm(centimeters: i32) -> Self

Returns a value equivalent to the number of `centimeters`

provided.

source#### pub fn cm_f(centimeters: f32) -> Self

#### pub fn cm_f(centimeters: f32) -> Self

Returns a value equivalent to the number of `centimeters`

provided.

source#### pub const fn mm(millimeters: i32) -> Self

#### pub const fn mm(millimeters: i32) -> Self

Returns a value equivalent to the number of `millimeters`

provided.

source#### pub fn mm_f(millimeters: f32) -> Self

#### pub fn mm_f(millimeters: f32) -> Self

Returns a value equivalent to the number of `millimeters`

provided.

## Trait Implementations§

source§### impl AddAssign<i32> for Lp

### impl AddAssign<i32> for Lp

source§#### fn add_assign(&mut self, rhs: i32)

#### fn add_assign(&mut self, rhs: i32)

`+=`

operation. Read moresource§### impl AddAssign for Lp

### impl AddAssign for Lp

source§#### fn add_assign(&mut self, rhs: Self)

#### fn add_assign(&mut self, rhs: Self)

`+=`

operation. Read moresource§### impl<'de> Deserialize<'de> for Lp

### impl<'de> Deserialize<'de> for Lp

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 DivAssign<i32> for Lp

### impl DivAssign<i32> for Lp

source§#### fn div_assign(&mut self, rhs: i32)

#### fn div_assign(&mut self, rhs: i32)

`/=`

operation. Read moresource§### impl DivAssign for Lp

### impl DivAssign for Lp

source§#### fn div_assign(&mut self, rhs: Self)

#### fn div_assign(&mut self, rhs: Self)

`/=`

operation. Read moresource§### impl FloatConversion for Lp

### impl FloatConversion for Lp

source§### impl IntoComponents<Lp> for f32

### impl IntoComponents<Lp> for f32

source§#### fn into_components(self) -> (Lp, Lp)

#### fn into_components(self) -> (Lp, Lp)

source§#### fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,

#### fn to_vec<Type>(self) -> Typewhere Type: FromComponents<Unit>,

`FromComponents`

and
`IntoComponents`

.source§### impl IntoComponents<Lp> for i32

### impl IntoComponents<Lp> for i32

source§#### fn into_components(self) -> (Lp, Lp)

#### fn into_components(self) -> (Lp, Lp)

source§#### fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,

#### fn to_vec<Type>(self) -> Typewhere Type: FromComponents<Unit>,

`FromComponents`

and
`IntoComponents`

.source§### impl IntoSigned for Lp

### impl IntoSigned for Lp

source§### impl MulAssign<i32> for Lp

### impl MulAssign<i32> for Lp

source§#### fn mul_assign(&mut self, rhs: i32)

#### fn mul_assign(&mut self, rhs: i32)

`*=`

operation. Read moresource§### impl MulAssign for Lp

### impl MulAssign for Lp

source§#### fn mul_assign(&mut self, rhs: Self)

#### fn mul_assign(&mut self, rhs: Self)

`*=`

operation. Read moresource§### impl Ord for Lp

### impl Ord for Lp

source§### impl PartialOrd<i32> for Lp

### impl PartialOrd<i32> for Lp

1.0.0 · source§#### fn le(&self, other: &Rhs) -> bool

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

`self`

and `other`

) and is used by the `<=`

operator. Read moresource§### impl PartialOrd for Lp

### impl PartialOrd for Lp

1.0.0 · source§#### fn le(&self, other: &Rhs) -> bool

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

`self`

and `other`

) and is used by the `<=`

operator. Read moresource§### impl PixelScaling for Lp

### impl PixelScaling for Lp

source§#### const PX_SCALING_FACTOR: u16 = 1_905u16

#### const PX_SCALING_FACTOR: u16 = 1_905u16

source§### impl RemAssign<i32> for Lp

### impl RemAssign<i32> for Lp

source§#### fn rem_assign(&mut self, rhs: i32)

#### fn rem_assign(&mut self, rhs: i32)

`%=`

operation. Read moresource§### impl RemAssign for Lp

### impl RemAssign for Lp

source§#### fn rem_assign(&mut self, rhs: Self)

#### fn rem_assign(&mut self, rhs: Self)

`%=`

operation. Read moresource§### impl ScreenScale for Lp

### impl ScreenScale for Lp

source§#### fn into_px(self, scale: Fraction) -> Self::Px

#### fn into_px(self, scale: Fraction) -> Self::Px

`Px`

)
using the provided `scale`

factor.source§#### fn from_px(px: Self::Px, scale: Fraction) -> Self

#### fn from_px(px: Self::Px, scale: Fraction) -> Self

`scale`

factor.source§#### fn into_lp(self, _scale: Fraction) -> Self::Lp

#### fn into_lp(self, _scale: Fraction) -> Self::Lp

`Lp`

) using the provided `scale`

factor.source§#### fn from_lp(lp: Self::Lp, _scale: Fraction) -> Self

#### fn from_lp(lp: Self::Lp, _scale: Fraction) -> Self

`scale`

factor.source§### impl SubAssign<i32> for Lp

### impl SubAssign<i32> for Lp

source§#### fn sub_assign(&mut self, rhs: i32)

#### fn sub_assign(&mut self, rhs: i32)

`-=`

operation. Read moresource§### impl SubAssign for Lp

### impl SubAssign for Lp

source§#### fn sub_assign(&mut self, rhs: Self)

#### fn sub_assign(&mut self, rhs: Self)

`-=`

operation. Read moresource§### impl UnscaledUnit for Lp

### impl UnscaledUnit for Lp

§#### type Representation = i32

#### type Representation = i32

source§#### fn from_unscaled(unscaled: Self::Representation) -> Self

#### fn from_unscaled(unscaled: Self::Representation) -> Self

source§#### fn into_unscaled(self) -> Self::Representation

#### fn into_unscaled(self) -> Self::Representation

### impl Copy for Lp

### impl Eq for Lp

### impl Pod for Lp

### impl StructuralEq for Lp

### impl StructuralPartialEq for Lp

## Auto Trait Implementations§

### impl RefUnwindSafe for Lp

### impl Send for Lp

### impl Sync for Lp

### impl Unpin for Lp

### impl UnwindSafe for Lp

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

§### impl<A> Cast for A

### impl<A> Cast for A

§### impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,

### impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,

§#### type Bits = T

#### type Bits = T

`Self`

*must*have the same layout as the specified

`Bits`

except for
the possible invalid bit patterns being checked during
`is_valid_bit_pattern`

.§#### fn is_valid_bit_pattern(_bits: &T) -> bool

#### fn is_valid_bit_pattern(_bits: &T) -> bool

`bits`

as `&Self`

.§### impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,

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

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

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

§### impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,

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

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

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

`key`

and return `true`

if they are equal.§### 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<Unit> IntoComponents<Unit> for Unitwhere
Unit: Copy,

### impl<Unit> IntoComponents<Unit> for Unitwhere Unit: Copy,

source§#### fn into_components(self) -> (Unit, Unit)

#### fn into_components(self) -> (Unit, Unit)

source§#### fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,

#### fn to_vec<Type>(self) -> Typewhere Type: FromComponents<Unit>,

`FromComponents`

and
`IntoComponents`

.