pub enum Value {
Literal(Lit),
Array(Vec<Lit>),
}
Expand description
Represents a value for a name-value
attribute.
Variants§
Literal(Lit)
A literal value: #[attribute(name="value")]
.
Array(Vec<Lit>)
An array of literal values: #[attribute(name=1,2,3,4)]
.
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Returns true
if this value is a literal.
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Returns true
if this value is a string
or byte string
literal value.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true
if this value is an integer
or byte
literal value.
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Returns true
if this value is a numeric literal (integer or float).
Sourcepub fn to_string_literal(&self) -> Option<String>
pub fn to_string_literal(&self) -> Option<String>
Returns the String
representation of this value or None
if is not a string literal.
Sourcepub fn to_char_literal(&self) -> Option<char>
pub fn to_char_literal(&self) -> Option<char>
Returns the char
representation of this value or None
if is not a char literal.
Sourcepub fn to_bool_literal(&self) -> Option<bool>
pub fn to_bool_literal(&self) -> Option<bool>
Returns the bool
representation of this value or None
if is not a bool literal.
Sourcepub fn to_byte_literal(&self) -> Option<u8>
pub fn to_byte_literal(&self) -> Option<u8>
Returns the byte
representation of this value or None
if is not a byte literal.
Sourcepub fn to_integer_literal<N>(&self) -> Option<N>
pub fn to_integer_literal<N>(&self) -> Option<N>
Converts this value into a integer or None
if is not an integer literal.
Sourcepub fn to_float_literal<N>(&self) -> Option<N>
pub fn to_float_literal<N>(&self) -> Option<N>
Converts this value into a float or None
if is not a float literal.
Sourcepub fn as_literal(&self) -> Option<&Lit>
pub fn as_literal(&self) -> Option<&Lit>
Returns a reference to this value literal.
Sourcepub fn parse_literal<T: FromStr>(&self) -> Option<T>
pub fn parse_literal<T: FromStr>(&self) -> Option<T>
Parses this value into the given type.
§Returns None
None
if the value is not a literal.None
if the parse fails.