/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Generic types that share their serialization implementations //! for both specified and computed values.
/// Returns whether this value is the `auto` value. #[inline] pubfn is_auto(&self) -> bool {
matches!(*self, ClipRectOrAuto::Auto)
}
}
pubuse page::PageSize;
pubuse text::NumberOrAuto;
/// An optional value, much like `Option<T>`, but with a defined struct layout /// to be able to use it from C++ as well. /// /// Note that this is relatively inefficient, struct-layout-wise, as you have /// one byte for the tag, but padding to the alignment of T. If you have /// multiple optional values and care about struct compactness, you might be /// better off "coalescing" the combinations into a parent enum. But that /// shouldn't matter for most use cases. #[allow(missing_docs)] #[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
Serialize,
Deserialize,
)] #[repr(C, u8)] pubenum Optional<T> { #[css(skip)]
None,
Some(T),
}
impl<T> Optional<T> { /// Returns whether this value is present. pubfn is_some(&self) -> bool {
matches!(*self, Self::Some(..))
}
/// Returns whether this value is not present. pubfn is_none(&self) -> bool {
matches!(*self, Self::None)
}
/// Turns this Optional<> into a regular rust Option<>. pubfn into_rust(self) -> Option<T> { matchself { Self::Some(v) => Some(v), Self::None => None,
}
}
/// Return a reference to the containing value, if any, as a plain rust /// Option<>. pubfn as_ref(&self) -> Option<&T> { match *self { Self::Some(ref v) => Some(v), Self::None => None,
}
}
/// Return a mutable reference to the containing value, if any, as a plain /// rust Option<>. pubfn as_mut(&mutself) -> Option<&mut T> { match *self { Self::Some(refmut v) => Some(v), Self::None => None,
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.