| 1 | //! # DPI |
| 2 | //! |
| 3 | //! ## Why should I care about UI scaling? |
| 4 | //! |
| 5 | //! Modern computer screens don't have a consistent relationship between resolution and size. |
| 6 | //! 1920x1080 is a common resolution for both desktop and mobile screens, despite mobile screens |
| 7 | //! typically being less than a quarter the size of their desktop counterparts. Moreover, neither |
| 8 | //! desktop nor mobile screens have consistent resolutions within their own size classes - common |
| 9 | //! mobile screens range from below 720p to above 1440p, and desktop screens range from 720p to 5K |
| 10 | //! and beyond. |
| 11 | //! |
| 12 | //! Given that, it's a mistake to assume that 2D content will only be displayed on screens with |
| 13 | //! a consistent pixel density. If you were to render a 96-pixel-square image on a 1080p screen and |
| 14 | //! then render the same image on a similarly-sized 4K screen, the 4K rendition would only take up |
| 15 | //! about a quarter of the physical space as it did on the 1080p screen. That issue is especially |
| 16 | //! problematic with text rendering, where quarter-sized text becomes a significant legibility |
| 17 | //! problem. |
| 18 | //! |
| 19 | //! Failure to account for the scale factor can create a significantly degraded user experience. |
| 20 | //! Most notably, it can make users feel like they have bad eyesight, which will potentially cause |
| 21 | //! them to think about growing elderly, resulting in them having an existential crisis. Once users |
| 22 | //! enter that state, they will no longer be focused on your application. |
| 23 | //! |
| 24 | //! ## How should I handle it? |
| 25 | //! |
| 26 | //! The solution to this problem is to account for the device's *scale factor*. The scale factor is |
| 27 | //! the factor UI elements should be scaled by to be consistent with the rest of the user's system - |
| 28 | //! for example, a button that's usually 50 pixels across would be 100 pixels across on a device |
| 29 | //! with a scale factor of `2.0`, or 75 pixels across with a scale factor of `1.5`. |
| 30 | //! |
| 31 | //! Many UI systems, such as CSS, expose DPI-dependent units like [points] or [picas]. That's |
| 32 | //! usually a mistake since there's no consistent mapping between the scale factor and the screen's |
| 33 | //! actual DPI. Unless printing to a physical medium, you should work in scaled pixels rather |
| 34 | //! than any DPI-dependent units. |
| 35 | //! |
| 36 | //! ### Position and Size types |
| 37 | //! |
| 38 | //! The [`PhysicalPosition`] / [`PhysicalSize`] / [`PhysicalUnit`] types correspond with the actual pixels on the |
| 39 | //! device, and the [`LogicalPosition`] / [`LogicalSize`] / [`LogicalUnit`] types correspond to the physical pixels |
| 40 | //! divided by the scale factor. |
| 41 | //! |
| 42 | //! The position and size types are generic over their exact pixel type, `P`, to allow the |
| 43 | //! API to have integer precision where appropriate (e.g. most window manipulation functions) and |
| 44 | //! floating precision when necessary (e.g. logical sizes for fractional scale factors and touch |
| 45 | //! input). If `P` is a floating-point type, please do not cast the values with `as {int}`. Doing so |
| 46 | //! will truncate the fractional part of the float rather than properly round to the nearest |
| 47 | //! integer. Use the provided `cast` function or [`From`]/[`Into`] conversions, which handle the |
| 48 | //! rounding properly. Note that precision loss will still occur when rounding from a float to an |
| 49 | //! int, although rounding lessens the problem. |
| 50 | //! |
| 51 | //! ## Cargo Features |
| 52 | //! |
| 53 | //! This crate provides the following Cargo features: |
| 54 | //! |
| 55 | //! * `serde`: Enables serialization/deserialization of certain types with |
| 56 | //! [Serde](https://crates.io/crates/serde). |
| 57 | //! * `mint`: Enables mint (math interoperability standard types) conversions. |
| 58 | //! |
| 59 | //! |
| 60 | //! [points]: https://en.wikipedia.org/wiki/Point_(typography) |
| 61 | //! [picas]: https://en.wikipedia.org/wiki/Pica_(typography) |
| 62 | |
| 63 | #![cfg_attr( |
| 64 | docsrs, |
| 65 | feature(doc_auto_cfg, doc_cfg_hide), |
| 66 | doc(cfg_hide(doc, docsrs)) |
| 67 | )] |
| 68 | #![forbid(unsafe_code)] |
| 69 | |
| 70 | #[cfg(feature = "serde")] |
| 71 | use serderust-analyzer cargo serde 1.0.229 crate/::{Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#, Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#}; |
| 72 | |
| 73 | pub trait Pixelrust-analyzer cargo dpi 0.1.1 Pixel#: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<f64> { |
| 74 | fn from_f64rust-analyzer cargo dpi 0.1.1 Pixel#from_f64().(f: f64) -> Self; |
| 75 | fn castrust-analyzer cargo dpi 0.1.1 Pixel#cast().<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(self) -> P { |
| 76 | P::from_f64rust-analyzer cargo dpi 0.1.1 Pixel#from_f64().(self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for u8 { |
| 81 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[u8][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[u8][Pixel] { |
| 82 | f.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u8 |
| 83 | } |
| 84 | } |
| 85 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for u16 { |
| 86 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[u16][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[u16][Pixel] { |
| 87 | f.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u16 |
| 88 | } |
| 89 | } |
| 90 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for u32 { |
| 91 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[u32][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[u32][Pixel] { |
| 92 | f.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u32 |
| 93 | } |
| 94 | } |
| 95 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for i8 { |
| 96 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[i8][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[i8][Pixel] { |
| 97 | f.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as i8 |
| 98 | } |
| 99 | } |
| 100 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for i16 { |
| 101 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[i16][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[i16][Pixel] { |
| 102 | f.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as i16 |
| 103 | } |
| 104 | } |
| 105 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for i32 { |
| 106 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[i32][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[i32][Pixel] { |
| 107 | f.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as i32 |
| 108 | } |
| 109 | } |
| 110 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for f32 { |
| 111 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[f32][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[f32][Pixel] { |
| 112 | f as f32 |
| 113 | } |
| 114 | } |
| 115 | impl Pixelrust-analyzer cargo dpi 0.1.1 Pixel# for f64 { |
| 116 | fn from_f64rust-analyzer cargo dpi 0.1.1 impl#[f64][Pixel]from_f64().(f: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[f64][Pixel] { |
| 117 | f |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /// Checks that the scale factor is a normal positive `f64`. |
| 122 | /// |
| 123 | /// All functions that take a scale factor assert that this will return `true`. If you're sourcing scale factors from |
| 124 | /// anywhere other than winit, it's recommended to validate them using this function before passing them to winit; |
| 125 | /// otherwise, you risk panics. |
| 126 | #[inline] |
| 127 | pub fn validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(scale_factor: f64) -> bool { |
| 128 | scale_factor.is_sign_positiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_sign_positive().() && scale_factor.is_normalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_normal().() |
| 129 | } |
| 130 | |
| 131 | /// A logical pixel unit. |
| 132 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 133 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 134 | pub struct LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>(pub P); |
| 135 | |
| 136 | impl<P> LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P> { |
| 137 | /// Represents a minimum logical unit of [`f64::MAX`]. |
| 138 | pub const MINrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]MIN.: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<f64> = LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(f64::MINrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]MIN.); |
| 139 | /// Represents a logical unit of `0_f64`. |
| 140 | pub const ZEROrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]ZERO.: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<f64> = LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(0.0); |
| 141 | /// Represents a maximum logical unit that is equal to [`f64::MAX`]. |
| 142 | pub const MAXrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]MAX.: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<f64> = LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(f64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]MAX.); |
| 143 | |
| 144 | #[inline] |
| 145 | pub const fn newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(v: P) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`] { |
| 146 | LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#(v) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P> { |
| 151 | #[inline] |
| 152 | pub fn from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]from_physical().<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<X>>, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>( |
| 153 | physical: T, |
| 154 | scale_factor: f64, |
| 155 | ) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`] { |
| 156 | physical.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]to_logical().(scale_factor) |
| 157 | } |
| 158 | |
| 159 | #[inline] |
| 160 | pub fn to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]to_physical().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<X> { |
| 161 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(scale_factor)); |
| 162 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(self.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().scale_factor).castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]cast().() |
| 163 | } |
| 164 | |
| 165 | #[inline] |
| 166 | pub fn castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]cast().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self) -> LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<X> { |
| 167 | LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#(self.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<X> for LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P> { |
| 172 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`][`From<X>`]from().(v: X) -> LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P> { |
| 173 | LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(v.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for u8 { |
| 178 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[u8][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> u8 { |
| 179 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for u16 { |
| 184 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[u16][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> u16 { |
| 185 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for u32 { |
| 190 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[u32][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> u32 { |
| 191 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for i8 { |
| 196 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[i8][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> i8 { |
| 197 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for i16 { |
| 202 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[i16][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> i16 { |
| 203 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for i32 { |
| 208 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[i32][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> i32 { |
| 209 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for f32 { |
| 214 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[f32][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> f32 { |
| 215 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for f64 { |
| 220 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[f64][`From<LogicalUnit<P>>`]from().(v: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> f64 { |
| 221 | v.0rust-analyzer cargo dpi 0.1.1 LogicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | /// A physical pixel unit. |
| 226 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 227 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 228 | pub struct PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>(pub P); |
| 229 | |
| 230 | impl<P> PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P> { |
| 231 | /// Represents a minimum physical unit of [`f64::MAX`]. |
| 232 | pub const MINrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]MIN.: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<f64> = LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(f64::MINrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]MIN.); |
| 233 | /// Represents a physical unit of `0_f64`. |
| 234 | pub const ZEROrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]ZERO.: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<f64> = LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(0.0); |
| 235 | /// Represents a maximum physical unit that is equal to [`f64::MAX`]. |
| 236 | pub const MAXrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]MAX.: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<f64> = LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(f64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]MAX.); |
| 237 | |
| 238 | #[inline] |
| 239 | pub const fn newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(v: P) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`] { |
| 240 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#(v) |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P> { |
| 245 | #[inline] |
| 246 | pub fn from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]from_logical().<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<X>>, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(logical: T, scale_factor: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`] { |
| 247 | logical.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]to_physical().(scale_factor) |
| 248 | } |
| 249 | |
| 250 | #[inline] |
| 251 | pub fn to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]to_logical().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<X> { |
| 252 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(scale_factor)); |
| 253 | LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(self.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().scale_factor).castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]cast().() |
| 254 | } |
| 255 | |
| 256 | #[inline] |
| 257 | pub fn castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]cast().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self) -> PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<X> { |
| 258 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#(self.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<X> for PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P> { |
| 263 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`][`From<X>`]from().(v: X) -> PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P> { |
| 264 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(v.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for u8 { |
| 269 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[u8][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> u8 { |
| 270 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for u16 { |
| 275 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[u16][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> u16 { |
| 276 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for u32 { |
| 281 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[u32][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> u32 { |
| 282 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for i8 { |
| 287 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[i8][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> i8 { |
| 288 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for i16 { |
| 293 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[i16][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> i16 { |
| 294 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for i32 { |
| 299 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[i32][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> i32 { |
| 300 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for f32 { |
| 305 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[f32][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> f32 { |
| 306 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for f64 { |
| 311 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[f64][`From<PhysicalUnit<P>>`]from().(v: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> f64 { |
| 312 | v.0rust-analyzer cargo dpi 0.1.1 PhysicalUnit#0..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().() |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | /// A pixel unit that's either physical or logical. |
| 317 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 318 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 319 | pub enum PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# { |
| 320 | Physicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Physical#(PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<i32>), |
| 321 | Logicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Logical#(LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<f64>), |
| 322 | } |
| 323 | |
| 324 | impl PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# { |
| 325 | /// Represents a minimum logical unit of [`f64::MAX`]. |
| 326 | pub const MINrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit]MIN.: PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# = PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Logicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Logical#(LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(f64::MINrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]MIN.)); |
| 327 | /// Represents a logical unit of `0_f64`. |
| 328 | pub const ZEROrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit]ZERO.: PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# = PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Logicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Logical#(LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(0.0)); |
| 329 | /// Represents a maximum logical unit that is equal to [`f64::MAX`]. |
| 330 | pub const MAXrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit]MAX.: PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# = PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Logicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Logical#(LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(f64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]MAX.)); |
| 331 | |
| 332 | pub fn newrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit]new().<S: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#>>(unit: S) -> PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# { |
| 333 | unit.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() |
| 334 | } |
| 335 | |
| 336 | pub fn to_logicalrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit]to_logical().<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P> { |
| 337 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 338 | PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Physicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Physical#(unit) => unit.to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]to_logical().(scale_factor), |
| 339 | PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Logicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Logical#(unit) => unit.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]cast().(), |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | pub fn to_physicalrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit]to_physical().<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P> { |
| 344 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 345 | PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Physicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Physical#(unit) => unit.castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]cast().(), |
| 346 | PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Logicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Logical#(unit) => unit.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]to_physical().(scale_factor), |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>> for PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# { |
| 352 | #[inline] |
| 353 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit][`From<PhysicalUnit<P>>`]from().(unit: PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<P>) -> PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# { |
| 354 | PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Physicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Physical#(unit.castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]cast().()) |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>> for PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# { |
| 359 | #[inline] |
| 360 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[PixelUnit][`From<LogicalUnit<P>>`]from().(unit: LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<P>) -> PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit# { |
| 361 | PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#::Logicalrust-analyzer cargo dpi 0.1.1 PixelUnit#Logical#(unit.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]cast().()) |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /// A position represented in logical pixels. |
| 366 | /// |
| 367 | /// The position is stored as floats, so please be careful. Casting floats to integers truncates the |
| 368 | /// fractional part, which can cause noticeable issues. To help with that, an `Into<(i32, i32)>` |
| 369 | /// implementation is provided which does the rounding for you. |
| 370 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 371 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 372 | pub struct LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 373 | pub xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x.: P, |
| 374 | pub yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y.: P, |
| 375 | } |
| 376 | |
| 377 | impl<P> LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 378 | #[inline] |
| 379 | pub const fn newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(x: P, y: P) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`] { |
| 380 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition# { xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x., yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y. } |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 385 | #[inline] |
| 386 | pub fn from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]from_physical().<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<X>>, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>( |
| 387 | physical: T, |
| 388 | scale_factor: f64, |
| 389 | ) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`] { |
| 390 | physical.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]to_logical().(scale_factor) |
| 391 | } |
| 392 | |
| 393 | #[inline] |
| 394 | pub fn to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]to_physical().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<X> { |
| 395 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(scale_factor)); |
| 396 | let x = self.xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().scale_factor; |
| 397 | let y = self.yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().scale_factor; |
| 398 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(x, y).castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]cast().() |
| 399 | } |
| 400 | |
| 401 | #[inline] |
| 402 | pub fn castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]cast().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self) -> LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<X> { |
| 403 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition# { |
| 404 | xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x.: self.xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 405 | yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y.: self.yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(X, X)> for LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 411 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][`From<(X, X)>`]from().((x, y): (X, X)) -> LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 412 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>> for (X, X) { |
| 417 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`(X, X)`][`From<LogicalPosition<P>>`]from().(p: LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>) -> (X, X) { |
| 418 | (p.xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), p.yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[X; 2]> for LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 423 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][`From<[X; 2]>`]from().([x, y]: [X; 2]) -> LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 424 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>> for [X; 2] { |
| 429 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`[X; 2]`][`From<LogicalPosition<P>>`]from().(p: LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>) -> [X; 2] { |
| 430 | [p.xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), p.yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()] |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | #[cfg(feature = "mint")] |
| 435 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2#<P>> for LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 436 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][`From<mint::Point2<P>>`]from().(p: mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][`From<mint::Point2<P>>`] { |
| 437 | Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][`From<mint::Point2<P>>`]::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(p.xrust-analyzer cargo mint 0.5.9 vector/Point2#x., p.yrust-analyzer cargo mint 0.5.9 vector/Point2#y.) |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | #[cfg(feature = "mint")] |
| 442 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>> for mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2#<P> { |
| 443 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`mint::Point2<P>`][`From<LogicalPosition<P>>`]from().(p: LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`mint::Point2<P>`][`From<LogicalPosition<P>>`] { |
| 444 | mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2# { xrust-analyzer cargo mint 0.5.9 vector/Point2#x.: p.xrust-analyzer cargo dpi 0.1.1 LogicalPosition#x., yrust-analyzer cargo mint 0.5.9 vector/Point2#y.: p.yrust-analyzer cargo dpi 0.1.1 LogicalPosition#y. } |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | /// A position represented in physical pixels. |
| 449 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 450 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 451 | pub struct PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 452 | pub xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x.: P, |
| 453 | pub yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y.: P, |
| 454 | } |
| 455 | |
| 456 | impl<P> PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 457 | #[inline] |
| 458 | pub const fn newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(x: P, y: P) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`] { |
| 459 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition# { xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x., yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y. } |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 464 | #[inline] |
| 465 | pub fn from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]from_logical().<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<X>>, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>( |
| 466 | logical: T, |
| 467 | scale_factor: f64, |
| 468 | ) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`] { |
| 469 | logical.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]to_physical().(scale_factor) |
| 470 | } |
| 471 | |
| 472 | #[inline] |
| 473 | pub fn to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]to_logical().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<X> { |
| 474 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(scale_factor)); |
| 475 | let x = self.xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().scale_factor; |
| 476 | let y = self.yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().scale_factor; |
| 477 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(x, y).castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]cast().() |
| 478 | } |
| 479 | |
| 480 | #[inline] |
| 481 | pub fn castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]cast().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self) -> PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<X> { |
| 482 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition# { |
| 483 | xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x.: self.xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 484 | yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y.: self.yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(X, X)> for PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 490 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][`From<(X, X)>`]from().((x, y): (X, X)) -> PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 491 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>> for (X, X) { |
| 496 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`(X, X)`][`From<PhysicalPosition<P>>`]from().(p: PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>) -> (X, X) { |
| 497 | (p.xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), p.yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[X; 2]> for PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 502 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][`From<[X; 2]>`]from().([x, y]: [X; 2]) -> PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 503 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>> for [X; 2] { |
| 508 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`[X; 2]`][`From<PhysicalPosition<P>>`]from().(p: PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>) -> [X; 2] { |
| 509 | [p.xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), p.yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()] |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | #[cfg(feature = "mint")] |
| 514 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2#<P>> for PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 515 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][`From<mint::Point2<P>>`]from().(p: mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][`From<mint::Point2<P>>`] { |
| 516 | Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][`From<mint::Point2<P>>`]::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(p.xrust-analyzer cargo mint 0.5.9 vector/Point2#x., p.yrust-analyzer cargo mint 0.5.9 vector/Point2#y.) |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | #[cfg(feature = "mint")] |
| 521 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>> for mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2#<P> { |
| 522 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`mint::Point2<P>`][`From<PhysicalPosition<P>>`]from().(p: PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`mint::Point2<P>`][`From<PhysicalPosition<P>>`] { |
| 523 | mintrust-analyzer cargo mint 0.5.9 crate/::Point2rust-analyzer cargo mint 0.5.9 vector/Point2# { xrust-analyzer cargo mint 0.5.9 vector/Point2#x.: p.xrust-analyzer cargo dpi 0.1.1 PhysicalPosition#x., yrust-analyzer cargo mint 0.5.9 vector/Point2#y.: p.yrust-analyzer cargo dpi 0.1.1 PhysicalPosition#y. } |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | /// A size represented in logical pixels. |
| 528 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 529 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 530 | pub struct LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 531 | pub widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width.: P, |
| 532 | pub heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height.: P, |
| 533 | } |
| 534 | |
| 535 | impl<P> LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 536 | #[inline] |
| 537 | pub const fn newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(width: P, height: P) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`] { |
| 538 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize# { widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width., heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height. } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 543 | #[inline] |
| 544 | pub fn from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]from_physical().<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<X>>, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>( |
| 545 | physical: T, |
| 546 | scale_factor: f64, |
| 547 | ) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`] { |
| 548 | physical.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]to_logical().(scale_factor) |
| 549 | } |
| 550 | |
| 551 | #[inline] |
| 552 | pub fn to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]to_physical().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<X> { |
| 553 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(scale_factor)); |
| 554 | let width = self.widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().scale_factor; |
| 555 | let height = self.heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().scale_factor; |
| 556 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(width, height).castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]cast().() |
| 557 | } |
| 558 | |
| 559 | #[inline] |
| 560 | pub fn castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]cast().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self) -> LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<X> { |
| 561 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize# { |
| 562 | widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width.: self.widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 563 | heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height.: self.heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(X, X)> for LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 569 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][`From<(X, X)>`]from().((x, y): (X, X)) -> LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 570 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>> for (X, X) { |
| 575 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`(X, X)`][`From<LogicalSize<P>>`]from().(s: LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>) -> (X, X) { |
| 576 | (s.widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), s.heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[X; 2]> for LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 581 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][`From<[X; 2]>`]from().([x, y]: [X; 2]) -> LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 582 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>> for [X; 2] { |
| 587 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`[X; 2]`][`From<LogicalSize<P>>`]from().(s: LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>) -> [X; 2] { |
| 588 | [s.widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), s.heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()] |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | #[cfg(feature = "mint")] |
| 593 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2#<P>> for LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 594 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][`From<mint::Vector2<P>>`]from().(v: mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][`From<mint::Vector2<P>>`] { |
| 595 | Selfrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][`From<mint::Vector2<P>>`]::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(v.xrust-analyzer cargo mint 0.5.9 vector/Vector2#x., v.yrust-analyzer cargo mint 0.5.9 vector/Vector2#y.) |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | #[cfg(feature = "mint")] |
| 600 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>> for mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2#<P> { |
| 601 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`mint::Vector2<P>`][`From<LogicalSize<P>>`]from().(s: LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`mint::Vector2<P>`][`From<LogicalSize<P>>`] { |
| 602 | mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2# { |
| 603 | xrust-analyzer cargo mint 0.5.9 vector/Vector2#x.: s.widthrust-analyzer cargo dpi 0.1.1 LogicalSize#width., |
| 604 | yrust-analyzer cargo mint 0.5.9 vector/Vector2#y.: s.heightrust-analyzer cargo dpi 0.1.1 LogicalSize#height., |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | /// A size represented in physical pixels. |
| 610 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 611 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 612 | pub struct PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 613 | pub widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width.: P, |
| 614 | pub heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height.: P, |
| 615 | } |
| 616 | |
| 617 | impl<P> PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 618 | #[inline] |
| 619 | pub const fn newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(width: P, height: P) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`] { |
| 620 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize# { widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width., heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height. } |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 625 | #[inline] |
| 626 | pub fn from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]from_logical().<T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<X>>, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(logical: T, scale_factor: f64) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`] { |
| 627 | logical.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]to_physical().(scale_factor) |
| 628 | } |
| 629 | |
| 630 | #[inline] |
| 631 | pub fn to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]to_logical().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<X> { |
| 632 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(scale_factor)); |
| 633 | let width = self.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().scale_factor; |
| 634 | let height = self.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().scale_factor; |
| 635 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(width, height).castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]cast().() |
| 636 | } |
| 637 | |
| 638 | #[inline] |
| 639 | pub fn castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]cast().<X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self) -> PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<X> { |
| 640 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize# { |
| 641 | widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width.: self.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 642 | heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height.: self.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(X, X)> for PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 648 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][`From<(X, X)>`]from().((x, y): (X, X)) -> PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 649 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>> for (X, X) { |
| 654 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`(X, X)`][`From<PhysicalSize<P>>`]from().(s: PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>) -> (X, X) { |
| 655 | (s.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), s.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[X; 2]> for PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 660 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][`From<[X; 2]>`]from().([x, y]: [X; 2]) -> PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 661 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(x.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), y.castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()) |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#, X: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>> for [X; 2] { |
| 666 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`[X; 2]`][`From<PhysicalSize<P>>`]from().(s: PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>) -> [X; 2] { |
| 667 | [s.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().(), s.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height..castrust-analyzer cargo dpi 0.1.1 Pixel#cast().()] |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | #[cfg(feature = "mint")] |
| 672 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2#<P>> for PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 673 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][`From<mint::Vector2<P>>`]from().(v: mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][`From<mint::Vector2<P>>`] { |
| 674 | Selfrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][`From<mint::Vector2<P>>`]::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(v.xrust-analyzer cargo mint 0.5.9 vector/Vector2#x., v.yrust-analyzer cargo mint 0.5.9 vector/Vector2#y.) |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | #[cfg(feature = "mint")] |
| 679 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>> for mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2#<P> { |
| 680 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[`mint::Vector2<P>`][`From<PhysicalSize<P>>`]from().(s: PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>) -> Selfrust-analyzer cargo dpi 0.1.1 impl#[`mint::Vector2<P>`][`From<PhysicalSize<P>>`] { |
| 681 | mintrust-analyzer cargo mint 0.5.9 crate/::Vector2rust-analyzer cargo mint 0.5.9 vector/Vector2# { |
| 682 | xrust-analyzer cargo mint 0.5.9 vector/Vector2#x.: s.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width., |
| 683 | yrust-analyzer cargo mint 0.5.9 vector/Vector2#y.: s.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height., |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | /// A size that's either physical or logical. |
| 689 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 690 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 691 | pub enum Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 692 | Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<u32>), |
| 693 | Logicalrust-analyzer cargo dpi 0.1.1 Size#Logical#(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<f64>), |
| 694 | } |
| 695 | |
| 696 | impl Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 697 | pub fn newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().<S: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Sizerust-analyzer cargo dpi 0.1.1 Size#>>(size: S) -> Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 698 | size.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() |
| 699 | } |
| 700 | |
| 701 | pub fn to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_logical().<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P> { |
| 702 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 703 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#(size) => size.to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]to_logical().(scale_factor), |
| 704 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Logicalrust-analyzer cargo dpi 0.1.1 Size#Logical#(size) => size.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]cast().(), |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | pub fn to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P> { |
| 709 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 710 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#(size) => size.castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]cast().(), |
| 711 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Logicalrust-analyzer cargo dpi 0.1.1 Size#Logical#(size) => size.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]to_physical().(scale_factor), |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | pub fn clamprust-analyzer cargo dpi 0.1.1 impl#[Size]clamp().<S: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Sizerust-analyzer cargo dpi 0.1.1 Size#>>(input: S, min: S, max: S, scale_factor: f64) -> Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 716 | let (input, min, max) = ( |
| 717 | input.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<f64>(scale_factor), |
| 718 | min.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<f64>(scale_factor), |
| 719 | max.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().().to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<f64>(scale_factor), |
| 720 | ); |
| 721 | |
| 722 | let width = input.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]clamp().(min.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width., max.widthrust-analyzer cargo dpi 0.1.1 PhysicalSize#width.); |
| 723 | let height = input.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height..clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]clamp().(min.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height., max.heightrust-analyzer cargo dpi 0.1.1 PhysicalSize#height.); |
| 724 | |
| 725 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(width, height).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>> for Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 730 | #[inline] |
| 731 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[Size][`From<PhysicalSize<P>>`]from().(size: PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<P>) -> Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 732 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#(size.castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]cast().()) |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>> for Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 737 | #[inline] |
| 738 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[Size][`From<LogicalSize<P>>`]from().(size: LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<P>) -> Sizerust-analyzer cargo dpi 0.1.1 Size# { |
| 739 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Logicalrust-analyzer cargo dpi 0.1.1 Size#Logical#(size.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]cast().()) |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | /// A position that's either physical or logical. |
| 744 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 745 | #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))] |
| 746 | pub enum Positionrust-analyzer cargo dpi 0.1.1 Position# { |
| 747 | Physicalrust-analyzer cargo dpi 0.1.1 Position#Physical#(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<i32>), |
| 748 | Logicalrust-analyzer cargo dpi 0.1.1 Position#Logical#(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<f64>), |
| 749 | } |
| 750 | |
| 751 | impl Positionrust-analyzer cargo dpi 0.1.1 Position# { |
| 752 | pub fn newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().<S: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Positionrust-analyzer cargo dpi 0.1.1 Position#>>(position: S) -> Positionrust-analyzer cargo dpi 0.1.1 Position# { |
| 753 | position.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() |
| 754 | } |
| 755 | |
| 756 | pub fn to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_logical().<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P> { |
| 757 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 758 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Physicalrust-analyzer cargo dpi 0.1.1 Position#Physical#(position) => position.to_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]to_logical().(scale_factor), |
| 759 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Logicalrust-analyzer cargo dpi 0.1.1 Position#Logical#(position) => position.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]cast().(), |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | pub fn to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_physical().<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#>(&self, scale_factor: f64) -> PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P> { |
| 764 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 765 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Physicalrust-analyzer cargo dpi 0.1.1 Position#Physical#(position) => position.castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]cast().(), |
| 766 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Logicalrust-analyzer cargo dpi 0.1.1 Position#Logical#(position) => position.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]to_physical().(scale_factor), |
| 767 | } |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>> for Positionrust-analyzer cargo dpi 0.1.1 Position# { |
| 772 | #[inline] |
| 773 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[Position][`From<PhysicalPosition<P>>`]from().(position: PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<P>) -> Positionrust-analyzer cargo dpi 0.1.1 Position# { |
| 774 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Physicalrust-analyzer cargo dpi 0.1.1 Position#Physical#(position.castrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]cast().()) |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | impl<P: Pixelrust-analyzer cargo dpi 0.1.1 Pixel#> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>> for Positionrust-analyzer cargo dpi 0.1.1 Position# { |
| 779 | #[inline] |
| 780 | fn fromrust-analyzer cargo dpi 0.1.1 impl#[Position][`From<LogicalPosition<P>>`]from().(position: LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<P>) -> Positionrust-analyzer cargo dpi 0.1.1 Position# { |
| 781 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Logicalrust-analyzer cargo dpi 0.1.1 Position#Logical#(position.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]cast().()) |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | #[cfg(test)] |
| 786 | mod testsrust-analyzer cargo dpi 0.1.1 tests/ { |
| 787 | use superrust-analyzer cargo dpi 0.1.1 crate/::*; |
| 788 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#; |
| 789 | |
| 790 | macro_rules! test_pixel_int_implrust-analyzer cargo dpi 0.1.1 tests/test_pixel_int_impl! { |
| 791 | ($($name:ident => $ty:ty),*) => {$( |
| 792 | #[test] |
| 793 | fn $name() { |
| 794 | assert_eq!( |
| 795 | <$ty as Pixel>::from_f64(37.0), |
| 796 | 37, |
| 797 | ); |
| 798 | assert_eq!( |
| 799 | <$ty as Pixel>::from_f64(37.4), |
| 800 | 37, |
| 801 | ); |
| 802 | assert_eq!( |
| 803 | <$ty as Pixel>::from_f64(37.5), |
| 804 | 38, |
| 805 | ); |
| 806 | assert_eq!( |
| 807 | <$ty as Pixel>::from_f64(37.9), |
| 808 | 38, |
| 809 | ); |
| 810 | |
| 811 | assert_eq!( |
| 812 | <$ty as Pixel>::cast::<u8>(37), |
| 813 | 37, |
| 814 | ); |
| 815 | assert_eq!( |
| 816 | <$ty as Pixel>::cast::<u16>(37), |
| 817 | 37, |
| 818 | ); |
| 819 | assert_eq!( |
| 820 | <$ty as Pixel>::cast::<u32>(37), |
| 821 | 37, |
| 822 | ); |
| 823 | assert_eq!( |
| 824 | <$ty as Pixel>::cast::<i8>(37), |
| 825 | 37, |
| 826 | ); |
| 827 | assert_eq!( |
| 828 | <$ty as Pixel>::cast::<i16>(37), |
| 829 | 37, |
| 830 | ); |
| 831 | assert_eq!( |
| 832 | <$ty as Pixel>::cast::<i32>(37), |
| 833 | 37, |
| 834 | ); |
| 835 | } |
| 836 | )*}; |
| 837 | } |
| 838 | |
| 839 | test_pixel_int_implrust-analyzer cargo dpi 0.1.1 tests/test_pixel_int_impl!! { |
| 840 | test_pixel_int_u8rust-analyzer cargo dpi 0.1.1 tests/test_pixel_int_u8(). => u8, |
| 841 | test_pixel_int_u16rust-analyzer cargo dpi 0.1.1 tests/test_pixel_int_u16(). => u16, |
| 842 | test_pixel_int_u32rust-analyzer cargo dpi 0.1.1 tests/test_pixel_int_u32(). => u32, |
| 843 | test_pixel_int_i8rust-analyzer cargo dpi 0.1.1 tests/test_pixel_int_i8(). => i8, |
| 844 | test_pixel_int_i16rust-analyzer cargo dpi 0.1.1 tests/test_pixel_int_i16(). => i16 |
| 845 | } |
| 846 | |
| 847 | macro_rules! assert_approx_eqrust-analyzer cargo dpi 0.1.1 tests/assert_approx_eq! { |
| 848 | ($a:expr, $b:expr $(,)?) => { |
| 849 | assert!( |
| 850 | ($a - $b).abs() < 0.001, |
| 851 | "{} is not approximately equal to {}", |
| 852 | $a, |
| 853 | $b |
| 854 | ); |
| 855 | }; |
| 856 | } |
| 857 | |
| 858 | macro_rules! test_pixel_float_implrust-analyzer cargo dpi 0.1.1 tests/test_pixel_float_impl! { |
| 859 | ($($name:ident => $ty:ty),*) => {$( |
| 860 | #[test] |
| 861 | fn $name() { |
| 862 | assert_approx_eq!( |
| 863 | <$ty as Pixel>::from_f64(37.0), |
| 864 | 37.0, |
| 865 | ); |
| 866 | assert_approx_eq!( |
| 867 | <$ty as Pixel>::from_f64(37.4), |
| 868 | 37.4, |
| 869 | ); |
| 870 | assert_approx_eq!( |
| 871 | <$ty as Pixel>::from_f64(37.5), |
| 872 | 37.5, |
| 873 | ); |
| 874 | assert_approx_eq!( |
| 875 | <$ty as Pixel>::from_f64(37.9), |
| 876 | 37.9, |
| 877 | ); |
| 878 | |
| 879 | assert_eq!( |
| 880 | <$ty as Pixel>::cast::<u8>(37.0), |
| 881 | 37, |
| 882 | ); |
| 883 | assert_eq!( |
| 884 | <$ty as Pixel>::cast::<u8>(37.4), |
| 885 | 37, |
| 886 | ); |
| 887 | assert_eq!( |
| 888 | <$ty as Pixel>::cast::<u8>(37.5), |
| 889 | 38, |
| 890 | ); |
| 891 | |
| 892 | assert_eq!( |
| 893 | <$ty as Pixel>::cast::<u16>(37.0), |
| 894 | 37, |
| 895 | ); |
| 896 | assert_eq!( |
| 897 | <$ty as Pixel>::cast::<u16>(37.4), |
| 898 | 37, |
| 899 | ); |
| 900 | assert_eq!( |
| 901 | <$ty as Pixel>::cast::<u16>(37.5), |
| 902 | 38, |
| 903 | ); |
| 904 | |
| 905 | assert_eq!( |
| 906 | <$ty as Pixel>::cast::<u32>(37.0), |
| 907 | 37, |
| 908 | ); |
| 909 | assert_eq!( |
| 910 | <$ty as Pixel>::cast::<u32>(37.4), |
| 911 | 37, |
| 912 | ); |
| 913 | assert_eq!( |
| 914 | <$ty as Pixel>::cast::<u32>(37.5), |
| 915 | 38, |
| 916 | ); |
| 917 | |
| 918 | assert_eq!( |
| 919 | <$ty as Pixel>::cast::<i8>(37.0), |
| 920 | 37, |
| 921 | ); |
| 922 | assert_eq!( |
| 923 | <$ty as Pixel>::cast::<i8>(37.4), |
| 924 | 37, |
| 925 | ); |
| 926 | assert_eq!( |
| 927 | <$ty as Pixel>::cast::<i8>(37.5), |
| 928 | 38, |
| 929 | ); |
| 930 | |
| 931 | assert_eq!( |
| 932 | <$ty as Pixel>::cast::<i16>(37.0), |
| 933 | 37, |
| 934 | ); |
| 935 | assert_eq!( |
| 936 | <$ty as Pixel>::cast::<i16>(37.4), |
| 937 | 37, |
| 938 | ); |
| 939 | assert_eq!( |
| 940 | <$ty as Pixel>::cast::<i16>(37.5), |
| 941 | 38, |
| 942 | ); |
| 943 | } |
| 944 | )*}; |
| 945 | } |
| 946 | |
| 947 | test_pixel_float_implrust-analyzer cargo dpi 0.1.1 tests/test_pixel_float_impl!! { |
| 948 | test_pixel_float_f32rust-analyzer cargo dpi 0.1.1 tests/test_pixel_float_f32(). => f32, |
| 949 | test_pixel_float_f64rust-analyzer cargo dpi 0.1.1 tests/test_pixel_float_f64(). => f64 |
| 950 | } |
| 951 | |
| 952 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 953 | fn test_validate_scale_factorrust-analyzer cargo dpi 0.1.1 tests/test_validate_scale_factor().() { |
| 954 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(1.0)); |
| 955 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(2.0)); |
| 956 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(3.0)); |
| 957 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(1.5)); |
| 958 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(0.5)); |
| 959 | |
| 960 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(0.0)); |
| 961 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0)); |
| 962 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(f64::INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]INFINITY.)); |
| 963 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(f64::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]NAN.)); |
| 964 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().validate_scale_factorrust-analyzer cargo dpi 0.1.1 validate_scale_factor().(f64::NEG_INFINITYrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]NEG_INFINITY.)); |
| 965 | } |
| 966 | |
| 967 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 968 | fn test_logical_unityrust-analyzer cargo dpi 0.1.1 tests/test_logical_unity().() { |
| 969 | let log_unit = LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(1.0); |
| 970 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_unit.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]to_physical().::<u32>(1.0), PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(1)); |
| 971 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_unit.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]to_physical().::<u32>(2.0), PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(2)); |
| 972 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_unit.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]cast().::<u32>(), LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(1)); |
| 973 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 974 | log_unit, |
| 975 | LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]from_physical().(PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(1.0), 1.0) |
| 976 | ); |
| 977 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 978 | log_unit, |
| 979 | LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]from_physical().(PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(2.0), 2.0) |
| 980 | ); |
| 981 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`][`From<X>`]from().(2.0), LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(2.0)); |
| 982 | |
| 983 | let x: f64 = log_unit.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 984 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, 1.0); |
| 985 | } |
| 986 | |
| 987 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 988 | fn test_physical_unitrust-analyzer cargo dpi 0.1.1 tests/test_physical_unit().() { |
| 989 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 990 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]from_logical().(LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(1.0), 1.0), |
| 991 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(1) |
| 992 | ); |
| 993 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 994 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]from_logical().(LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalUnit<P>`]new().(2.0), 0.5), |
| 995 | PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(1) |
| 996 | ); |
| 997 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`][`From<X>`]from().(2.0), PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(2.0,)); |
| 998 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`][`From<X>`]from().(2.0), PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(2.0)); |
| 999 | |
| 1000 | let x: f64 = PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalUnit<P>`]new().(1).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1001 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, 1.0); |
| 1002 | } |
| 1003 | |
| 1004 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1005 | fn test_logical_positionrust-analyzer cargo dpi 0.1.1 tests/test_logical_position().() { |
| 1006 | let log_pos = LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0); |
| 1007 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_pos.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]to_physical().::<u32>(1.0), PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2)); |
| 1008 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_pos.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]to_physical().::<u32>(2.0), PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(2, 4)); |
| 1009 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_pos.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]cast().::<u32>(), LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1, 2)); |
| 1010 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1011 | log_pos, |
| 1012 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]from_physical().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1.0, 2.0), 1.0) |
| 1013 | ); |
| 1014 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1015 | log_pos, |
| 1016 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]from_physical().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(2.0, 4.0), 2.0) |
| 1017 | ); |
| 1018 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1019 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][`From<(X, X)>`]from().((2.0, 2.0)), |
| 1020 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(2.0, 2.0) |
| 1021 | ); |
| 1022 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1023 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][`From<[X; 2]>`]from().([2.0, 3.0]), |
| 1024 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(2.0, 3.0) |
| 1025 | ); |
| 1026 | |
| 1027 | let x: (f64, f64) = log_pos.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1028 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, (1.0, 2.0)); |
| 1029 | let x: [f64; 2] = log_pos.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1030 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, [1.0, 2.0]); |
| 1031 | } |
| 1032 | |
| 1033 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1034 | fn test_physical_positionrust-analyzer cargo dpi 0.1.1 tests/test_physical_position().() { |
| 1035 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1036 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]from_logical().(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0), 1.0), |
| 1037 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2) |
| 1038 | ); |
| 1039 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1040 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]from_logical().(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(2.0, 4.0), 0.5), |
| 1041 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2) |
| 1042 | ); |
| 1043 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1044 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][`From<(X, X)>`]from().((2.0, 2.0)), |
| 1045 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(2.0, 2.0) |
| 1046 | ); |
| 1047 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1048 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][`From<[X; 2]>`]from().([2.0, 3.0]), |
| 1049 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(2.0, 3.0) |
| 1050 | ); |
| 1051 | |
| 1052 | let x: (f64, f64) = PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1053 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, (1.0, 2.0)); |
| 1054 | let x: [f64; 2] = PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1055 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, [1.0, 2.0]); |
| 1056 | } |
| 1057 | |
| 1058 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1059 | fn test_logical_sizerust-analyzer cargo dpi 0.1.1 tests/test_logical_size().() { |
| 1060 | let log_size = LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0); |
| 1061 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_size.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]to_physical().::<u32>(1.0), PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2)); |
| 1062 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_size.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]to_physical().::<u32>(2.0), PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(2, 4)); |
| 1063 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log_size.castrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]cast().::<u32>(), LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1, 2)); |
| 1064 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1065 | log_size, |
| 1066 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]from_physical().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1.0, 2.0), 1.0) |
| 1067 | ); |
| 1068 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1069 | log_size, |
| 1070 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::from_physicalrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]from_physical().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(2.0, 4.0), 2.0) |
| 1071 | ); |
| 1072 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][`From<(X, X)>`]from().((2.0, 2.0)), LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(2.0, 2.0)); |
| 1073 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::fromrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][`From<[X; 2]>`]from().([2.0, 3.0]), LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(2.0, 3.0)); |
| 1074 | |
| 1075 | let x: (f64, f64) = log_size.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1076 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, (1.0, 2.0)); |
| 1077 | let x: [f64; 2] = log_size.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1078 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, [1.0, 2.0]); |
| 1079 | } |
| 1080 | |
| 1081 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1082 | fn test_physical_sizerust-analyzer cargo dpi 0.1.1 tests/test_physical_size().() { |
| 1083 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1084 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]from_logical().(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0), 1.0), |
| 1085 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2) |
| 1086 | ); |
| 1087 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1088 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::from_logicalrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]from_logical().(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(2.0, 4.0), 0.5), |
| 1089 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2) |
| 1090 | ); |
| 1091 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][`From<(X, X)>`]from().((2.0, 2.0)), PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(2.0, 2.0)); |
| 1092 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::fromrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][`From<[X; 2]>`]from().([2.0, 3.0]), PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(2.0, 3.0)); |
| 1093 | |
| 1094 | let x: (f64, f64) = PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1095 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, (1.0, 2.0)); |
| 1096 | let x: [f64; 2] = PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1097 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(x, [1.0, 2.0]); |
| 1098 | } |
| 1099 | |
| 1100 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1101 | fn test_sizerust-analyzer cargo dpi 0.1.1 tests/test_size().() { |
| 1102 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1103 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2)), |
| 1104 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2)) |
| 1105 | ); |
| 1106 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1107 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0)), |
| 1108 | Sizerust-analyzer cargo dpi 0.1.1 Size#::Logicalrust-analyzer cargo dpi 0.1.1 Size#Logical#(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0)) |
| 1109 | ); |
| 1110 | |
| 1111 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1112 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2)).to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_logical().::<f64>(1.0), |
| 1113 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0) |
| 1114 | ); |
| 1115 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1116 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2)).to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_logical().::<f64>(2.0), |
| 1117 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(0.5, 1.0) |
| 1118 | ); |
| 1119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1120 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0)).to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_logical().::<f64>(1.0), |
| 1121 | LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0) |
| 1122 | ); |
| 1123 | |
| 1124 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1125 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<u32>(1.0), |
| 1126 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2) |
| 1127 | ); |
| 1128 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1129 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<u32>(2.0), |
| 1130 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2) |
| 1131 | ); |
| 1132 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1133 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<u32>(1.0), |
| 1134 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(1, 2) |
| 1135 | ); |
| 1136 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1137 | Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`]new().(1.0, 2.0)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<u32>(2.0), |
| 1138 | PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`]new().(2, 4) |
| 1139 | ); |
| 1140 | |
| 1141 | let small = Sizerust-analyzer cargo dpi 0.1.1 Size#::Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#((1, 2).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 1142 | let medium = Sizerust-analyzer cargo dpi 0.1.1 Size#::Logicalrust-analyzer cargo dpi 0.1.1 Size#Logical#((3, 4).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 1143 | let medium_physical = Sizerust-analyzer cargo dpi 0.1.1 Size#::newrust-analyzer cargo dpi 0.1.1 impl#[Size]new().(medium.to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Size]to_physical().::<u32>(1.0)); |
| 1144 | let large = Sizerust-analyzer cargo dpi 0.1.1 Size#::Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#((5, 6).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 1145 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Sizerust-analyzer cargo dpi 0.1.1 Size#::clamprust-analyzer cargo dpi 0.1.1 impl#[Size]clamp().(medium, small, large, 1.0), medium_physical); |
| 1146 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Sizerust-analyzer cargo dpi 0.1.1 Size#::clamprust-analyzer cargo dpi 0.1.1 impl#[Size]clamp().(small, medium, large, 1.0), medium_physical); |
| 1147 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Sizerust-analyzer cargo dpi 0.1.1 Size#::clamprust-analyzer cargo dpi 0.1.1 impl#[Size]clamp().(large, small, medium, 1.0), medium_physical); |
| 1148 | } |
| 1149 | |
| 1150 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1151 | fn test_positionrust-analyzer cargo dpi 0.1.1 tests/test_position().() { |
| 1152 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1153 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2)), |
| 1154 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Physicalrust-analyzer cargo dpi 0.1.1 Position#Physical#(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2)) |
| 1155 | ); |
| 1156 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1157 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0)), |
| 1158 | Positionrust-analyzer cargo dpi 0.1.1 Position#::Logicalrust-analyzer cargo dpi 0.1.1 Position#Logical#(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0)) |
| 1159 | ); |
| 1160 | |
| 1161 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1162 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2)).to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_logical().::<f64>(1.0), |
| 1163 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0) |
| 1164 | ); |
| 1165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1166 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2)).to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_logical().::<f64>(2.0), |
| 1167 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(0.5, 1.0) |
| 1168 | ); |
| 1169 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1170 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0)).to_logicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_logical().::<f64>(1.0), |
| 1171 | LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0) |
| 1172 | ); |
| 1173 | |
| 1174 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1175 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_physical().::<u32>(1.0), |
| 1176 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2) |
| 1177 | ); |
| 1178 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1179 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_physical().::<u32>(2.0), |
| 1180 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2) |
| 1181 | ); |
| 1182 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1183 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_physical().::<u32>(1.0), |
| 1184 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(1, 2) |
| 1185 | ); |
| 1186 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1187 | Positionrust-analyzer cargo dpi 0.1.1 Position#::newrust-analyzer cargo dpi 0.1.1 impl#[Position]new().(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`]new().(1.0, 2.0)).to_physicalrust-analyzer cargo dpi 0.1.1 impl#[Position]to_physical().::<u32>(2.0), |
| 1188 | PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::newrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`]new().(2, 4) |
| 1189 | ); |
| 1190 | } |
| 1191 | |
| 1192 | // Eat coverage for the Debug impls et al |
| 1193 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1194 | fn ensure_attrs_do_not_panicrust-analyzer cargo dpi 0.1.1 tests/ensure_attrs_do_not_panic().() { |
| 1195 | let _ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][Default]default().().clonerust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][Clone]clone().()); |
| 1196 | HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().().insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`LogicalPosition<P>`][Default]default().()); |
| 1197 | |
| 1198 | let _ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][Default]default().().clonerust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][Clone]clone().()); |
| 1199 | HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().().insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalPosition<P>`][Default]default().()); |
| 1200 | |
| 1201 | let _ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][Default]default().().clonerust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][Clone]clone().()); |
| 1202 | HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().().insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`LogicalSize<P>`][Default]default().()); |
| 1203 | |
| 1204 | let _ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][Default]default().().clonerust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][Clone]clone().()); |
| 1205 | HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().().insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#::<u32>::defaultrust-analyzer cargo dpi 0.1.1 impl#[`PhysicalSize<P>`][Default]default().()); |
| 1206 | |
| 1207 | let _ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", Sizerust-analyzer cargo dpi 0.1.1 Size#::Physicalrust-analyzer cargo dpi 0.1.1 Size#Physical#((1, 2).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).clonerust-analyzer cargo dpi 0.1.1 impl#[Size][Clone]clone().()); |
| 1208 | let _ = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", Positionrust-analyzer cargo dpi 0.1.1 Position#::Physicalrust-analyzer cargo dpi 0.1.1 Position#Physical#((1, 2).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).clonerust-analyzer cargo dpi 0.1.1 impl#[Position][Clone]clone().()); |
| 1209 | } |
| 1210 | |
| 1211 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1212 | fn ensure_copy_traitrust-analyzer cargo dpi 0.1.1 tests/ensure_copy_trait().() { |
| 1213 | fn is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().<T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#>() {} |
| 1214 | |
| 1215 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<i32>>(); |
| 1216 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<f64>>(); |
| 1217 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#>(); |
| 1218 | |
| 1219 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<i32>>(); |
| 1220 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<f64>>(); |
| 1221 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<Sizerust-analyzer cargo dpi 0.1.1 Size#>(); |
| 1222 | |
| 1223 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<i32>>(); |
| 1224 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<f64>>(); |
| 1225 | is_copyrust-analyzer cargo dpi 0.1.1 tests/is_copy().::<Positionrust-analyzer cargo dpi 0.1.1 Position#>(); |
| 1226 | } |
| 1227 | |
| 1228 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1229 | fn ensure_partial_eq_traitrust-analyzer cargo dpi 0.1.1 tests/ensure_partial_eq_trait().() { |
| 1230 | fn is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().<T: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#>() {} |
| 1231 | |
| 1232 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<LogicalUnitrust-analyzer cargo dpi 0.1.1 LogicalUnit#<i32>>(); |
| 1233 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<PhysicalUnitrust-analyzer cargo dpi 0.1.1 PhysicalUnit#<f64>>(); |
| 1234 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<PixelUnitrust-analyzer cargo dpi 0.1.1 PixelUnit#>(); |
| 1235 | |
| 1236 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<LogicalSizerust-analyzer cargo dpi 0.1.1 LogicalSize#<i32>>(); |
| 1237 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<PhysicalSizerust-analyzer cargo dpi 0.1.1 PhysicalSize#<f64>>(); |
| 1238 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<Sizerust-analyzer cargo dpi 0.1.1 Size#>(); |
| 1239 | |
| 1240 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<LogicalPositionrust-analyzer cargo dpi 0.1.1 LogicalPosition#<i32>>(); |
| 1241 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<PhysicalPositionrust-analyzer cargo dpi 0.1.1 PhysicalPosition#<f64>>(); |
| 1242 | is_partial_eqrust-analyzer cargo dpi 0.1.1 tests/is_partial_eq().::<Positionrust-analyzer cargo dpi 0.1.1 Position#>(); |
| 1243 | } |
| 1244 | } |