style/values/generics/
url.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! Generic types for url properties.
6
7/// An image url or none, used for example in list-style-image
8#[derive(
9    Animate,
10    Clone,
11    ComputeSquaredDistance,
12    Debug,
13    MallocSizeOf,
14    PartialEq,
15    Parse,
16    SpecifiedValueInfo,
17    ToAnimatedValue,
18    ToAnimatedZero,
19    ToComputedValue,
20    ToCss,
21    ToResolvedValue,
22    ToShmem,
23    ToTyped,
24)]
25#[repr(C, u8)]
26pub enum GenericUrlOrNone<U> {
27    /// `none`
28    None,
29    /// A URL.
30    Url(U),
31}
32
33pub use self::GenericUrlOrNone as UrlOrNone;
34
35impl<Url> UrlOrNone<Url> {
36    /// Initial "none" value for properties such as `list-style-image`
37    pub fn none() -> Self {
38        UrlOrNone::None
39    }
40
41    /// Returns whether the value is `none`.
42    pub fn is_none(&self) -> bool {
43        match *self {
44            UrlOrNone::None => true,
45            UrlOrNone::Url(..) => false,
46        }
47    }
48}