pub trait ValT:
ValT
+ Ord
+ From<f64>
+ From<usize> {
// Required methods
fn into_seq<S: FromIterator<Self>>(self) -> Result<S, Self>;
fn is_int(&self) -> bool;
fn as_isize(&self) -> Option<isize>;
fn as_f64(&self) -> Option<f64>;
fn is_utf8_str(&self) -> bool;
fn as_bytes(&self) -> Option<&[u8]>;
fn as_sub_str(&self, sub: &[u8]) -> Self;
fn from_utf8_bytes(b: impl AsRef<[u8]> + Send + 'static) -> Self;
// Provided methods
fn as_utf8_bytes(&self) -> Option<&[u8]> { ... }
fn try_as_bytes(&self) -> Result<&[u8], Error<Self>> { ... }
fn try_as_utf8_bytes(&self) -> Result<&[u8], Error<Self>> { ... }
}Expand description
Values that the standard library can operate on.
Required Methods§
Sourcefn into_seq<S: FromIterator<Self>>(self) -> Result<S, Self>
fn into_seq<S: FromIterator<Self>>(self) -> Result<S, Self>
Convert an array into a sequence.
This returns the original value as Err if it is not an array.
Sourcefn as_isize(&self) -> Option<isize>
fn as_isize(&self) -> Option<isize>
Use the value as machine-sized integer.
If this function returns Some(_), then Self::is_int must return true.
However, the other direction must not necessarily be the case, because
there may be integer values that are not representable by isize.
Sourcefn as_f64(&self) -> Option<f64>
fn as_f64(&self) -> Option<f64>
Use the value as floating-point number.
This succeeds for all numeric values, rounding too large/small ones to +/- Infinity.
Sourcefn is_utf8_str(&self) -> bool
fn is_utf8_str(&self) -> bool
True if the value is interpreted as UTF-8 string.
Sourcefn as_bytes(&self) -> Option<&[u8]>
fn as_bytes(&self) -> Option<&[u8]>
If the value is a string (whatever its interpretation), return its bytes.
Sourcefn as_sub_str(&self, sub: &[u8]) -> Self
fn as_sub_str(&self, sub: &[u8]) -> Self
If the value is a string and sub points to a slice of the string,
shorten the string to sub, else panic.
Sourcefn from_utf8_bytes(b: impl AsRef<[u8]> + Send + 'static) -> Self
fn from_utf8_bytes(b: impl AsRef<[u8]> + Send + 'static) -> Self
Interpret bytes as UTF-8 string value.
Provided Methods§
Sourcefn as_utf8_bytes(&self) -> Option<&[u8]>
fn as_utf8_bytes(&self) -> Option<&[u8]>
If the value is interpreted as UTF-8 string, return its bytes.
Sourcefn try_as_bytes(&self) -> Result<&[u8], Error<Self>>
fn try_as_bytes(&self) -> Result<&[u8], Error<Self>>
If the value is a string (whatever its interpretation), return its bytes, else fail.
Sourcefn try_as_utf8_bytes(&self) -> Result<&[u8], Error<Self>>
fn try_as_utf8_bytes(&self) -> Result<&[u8], Error<Self>>
If the value is interpreted as UTF-8 string, return its bytes, else fail.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.