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)]
24#[repr(C, u8)]
25pub enum GenericUrlOrNone<U> {
26 /// `none`
27 None,
28 /// A URL.
29 Url(U),
30}
31
32pub use self::GenericUrlOrNone as UrlOrNone;
33
34impl<Url> UrlOrNone<Url> {
35 /// Initial "none" value for properties such as `list-style-image`
36 pub fn none() -> Self {
37 UrlOrNone::None
38 }
39
40 /// Returns whether the value is `none`.
41 pub fn is_none(&self) -> bool {
42 match *self {
43 UrlOrNone::None => true,
44 UrlOrNone::Url(..) => false,
45 }
46 }
47}