pub struct NonNegative<T>(pub T);Expand description
A numeric value in a grammar position that only allows non-negative values.
Negative literals are rejected. Calculations are clamped when their result can be resolved, or preserved for the browser to clamp after resolution. This wrapper constrains parsing; its contents may still be modified directly.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Clone> Clone for NonNegative<T>
impl<T: Clone> Clone for NonNegative<T>
impl<T: Copy> Copy for NonNegative<T>
Source§impl<T: Debug> Debug for NonNegative<T>
impl<T: Debug> Debug for NonNegative<T>
Source§impl<T: Default> Default for NonNegative<T>
impl<T: Default> Default for NonNegative<T>
Source§impl<'de, T> Deserialize<'de> for NonNegative<T>where
T: Deserialize<'de>,
Available on crate feature serde only.
impl<'de, T> Deserialize<'de> for NonNegative<T>where
T: Deserialize<'de>,
Available on crate feature
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'any, T> IntoOwned<'any> for NonNegative<T>where
T: IntoOwned<'any>,
Available on crate feature into_owned only.
impl<'any, T> IntoOwned<'any> for NonNegative<T>where
T: IntoOwned<'any>,
Available on crate feature
into_owned only.Source§fn into_owned(self) -> Self::Owned
fn into_owned(self) -> Self::Owned
Consumes the value and returns an owned clone.
Source§impl<T: IsCompatible> IsCompatible for NonNegative<T>
impl<T: IsCompatible> IsCompatible for NonNegative<T>
Source§fn is_compatible(&self, browsers: Browsers) -> bool
fn is_compatible(&self, browsers: Browsers) -> bool
Returns whether the value is compatible with all of the given browser targets.
Source§impl<T: JsonSchema> JsonSchema for NonNegative<T>
Available on crate feature jsonschema only.
impl<T: JsonSchema> JsonSchema for NonNegative<T>
Available on crate feature
jsonschema only.Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreSource§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§impl<'i, T: ParseNumeric<'i>> Parse<'i> for NonNegative<T>
impl<'i, T: ParseNumeric<'i>> Parse<'i> for NonNegative<T>
Source§fn parse<'t>(
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i, ParserError<'i>>>
fn parse<'t>( input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i, ParserError<'i>>>
Parse a value of this type using an existing parser.
Source§fn parse_string(input: &'i str) -> Result<Self, ParseError<'i, ParserError<'i>>>
fn parse_string(input: &'i str) -> Result<Self, ParseError<'i, ParserError<'i>>>
Parse a value from a string. Read more
Source§impl<T: PartialEq> PartialEq for NonNegative<T>
impl<T: PartialEq> PartialEq for NonNegative<T>
Source§impl<T: PartialOrd> PartialOrd for NonNegative<T>
impl<T: PartialOrd> PartialOrd for NonNegative<T>
Source§impl<T> Serialize for NonNegative<T>where
T: Serialize,
Available on crate feature serde only.
impl<T> Serialize for NonNegative<T>where
T: Serialize,
Available on crate feature
serde only.impl<T: PartialEq> StructuralPartialEq for NonNegative<T>
Source§impl<T: ToCss> ToCss for NonNegative<T>
impl<T: ToCss> ToCss for NonNegative<T>
Source§fn to_css<PrinterT: PrinterTrait>(
&self,
dest: &mut PrinterT,
) -> Result<(), PrinterError>
fn to_css<PrinterT: PrinterTrait>( &self, dest: &mut PrinterT, ) -> Result<(), PrinterError>
Serialize
self in CSS syntax, writing to dest.Source§fn to_css_string(
&self,
options: PrinterOptions<'_>,
) -> Result<String, PrinterError>
fn to_css_string( &self, options: PrinterOptions<'_>, ) -> Result<String, PrinterError>
Serialize
self in CSS syntax and return a string. Read moreSource§impl<T: TrySign> TrySign for NonNegative<T>
impl<T: TrySign> TrySign for NonNegative<T>
Source§fn is_sign_positive(&self) -> bool
fn is_sign_positive(&self) -> bool
Returns whether the value is positive. If not possible, returns false.
Source§fn is_sign_negative(&self) -> bool
fn is_sign_negative(&self) -> bool
Returns whether the value is negative. If not possible, returns false.
Source§impl<'i, T, __T: Visit<'i, __T, __V>, __V: ?Sized + Visitor<'i, __T>> Visit<'i, __T, __V> for NonNegative<T>where
T: Visit<'i, __T, __V>,
Available on crate feature visitor only.
impl<'i, T, __T: Visit<'i, __T, __V>, __V: ?Sized + Visitor<'i, __T>> Visit<'i, __T, __V> for NonNegative<T>where
T: Visit<'i, __T, __V>,
Available on crate feature
visitor only.Source§const CHILD_TYPES: VisitTypes
const CHILD_TYPES: VisitTypes
The types of values contained within this value and its children.
This is used to skip branches that don’t have any values requested
by the Visitor.
Auto Trait Implementations§
impl<T> Forget for NonNegative<T>
impl<T> Freeze for NonNegative<T>where
T: Freeze,
impl<T> Move for NonNegative<T>
impl<T> RefUnwindSafe for NonNegative<T>where
T: RefUnwindSafe,
impl<T> Send for NonNegative<T>where
T: Send,
impl<T> Sync for NonNegative<T>where
T: Sync,
impl<T> Unpin for NonNegative<T>where
T: Unpin,
impl<T> UnsafeUnpin for NonNegative<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for NonNegative<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'i, T> ParseWithOptions<'i> for Twhere
T: Parse<'i>,
impl<'i, T> ParseWithOptions<'i> for Twhere
T: Parse<'i>,
Source§fn parse_with_options<'t>(
input: &mut Parser<'i, 't>,
_options: &ParserOptions<'_>,
) -> Result<T, ParseError<'i, ParserError<'i>>>
fn parse_with_options<'t>( input: &mut Parser<'i, 't>, _options: &ParserOptions<'_>, ) -> Result<T, ParseError<'i, ParserError<'i>>>
Parse a value of this type with the given options.
Source§fn parse_string_with_options(
input: &'i str,
options: ParserOptions<'i>,
) -> Result<Self, ParseError<'i, ParserError<'i>>>
fn parse_string_with_options( input: &'i str, options: ParserOptions<'i>, ) -> Result<Self, ParseError<'i, ParserError<'i>>>
Parse a value from a string with the given options.