diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-13 21:39:38 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-13 21:40:06 +0100 |
| commit | 880b1847bd4170ce80be5781c2163ba085cdcaff (patch) | |
| tree | 3fbfdb70cb04c4922f0ec9e3f29f2c63d11d753b /library/src/visualize | |
| parent | cb3c263c4a67f4d361dbdb5048a1c073bd1fff96 (diff) | |
Derive `Cast` for enums
Diffstat (limited to 'library/src/visualize')
| -rw-r--r-- | library/src/visualize/image.rs | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/library/src/visualize/image.rs b/library/src/visualize/image.rs index 29a04c96..4509cf5a 100644 --- a/library/src/visualize/image.rs +++ b/library/src/visualize/image.rs @@ -113,33 +113,15 @@ impl Layout for ImageNode { } /// How an image should adjust itself to a given area. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum ImageFit { - /// The image should completely cover the area. + /// The image should completely cover the area. This is the default. Cover, /// The image should be fully contained in the area. Contain, - /// The image should be stretched so that it exactly fills the area. - Stretch, -} - -cast_from_value! { - ImageFit, - /// The image should completely cover the area. This is the default. - "cover" => Self::Cover, - /// The image should be fully contained in the area. - "contain" => Self::Contain, /// The image should be stretched so that it exactly fills the area, even if /// this means that the image will be distorted. - "stretch" => Self::Stretch, -} - -cast_to_value! { - fit: ImageFit => Value::from(match fit { - ImageFit::Cover => "cover", - ImageFit::Contain => "contain", - ImageFit::Stretch => "stretch", - }) + Stretch, } /// Load an image from a path. |
