tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

url.rs (1100B)


      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 use crate::derives::*;
      8 
      9 /// An image url or none, used for example in list-style-image
     10 #[derive(
     11    Animate,
     12    Clone,
     13    ComputeSquaredDistance,
     14    Debug,
     15    MallocSizeOf,
     16    PartialEq,
     17    Parse,
     18    SpecifiedValueInfo,
     19    ToAnimatedValue,
     20    ToAnimatedZero,
     21    ToComputedValue,
     22    ToCss,
     23    ToResolvedValue,
     24    ToShmem,
     25    ToTyped,
     26 )]
     27 #[repr(C, u8)]
     28 pub enum GenericUrlOrNone<U> {
     29    /// `none`
     30    None,
     31    /// A URL.
     32    Url(U),
     33 }
     34 
     35 pub use self::GenericUrlOrNone as UrlOrNone;
     36 
     37 impl<Url> UrlOrNone<Url> {
     38    /// Initial "none" value for properties such as `list-style-image`
     39    pub fn none() -> Self {
     40        UrlOrNone::None
     41    }
     42 
     43    /// Returns whether the value is `none`.
     44    pub fn is_none(&self) -> bool {
     45        match *self {
     46            UrlOrNone::None => true,
     47            UrlOrNone::Url(..) => false,
     48        }
     49    }
     50 }