Enum entity::PrimitiveType [−][src]
Represents primitive value types
Variants
Number(NumberType)
Implementations
impl PrimitiveType
[src]
pub fn is_bool(&self) -> bool
[src]
pub fn is_char(&self) -> bool
[src]
pub fn is_number(&self) -> bool
[src]
pub fn is_unit(&self) -> bool
[src]
pub fn to_number_type(&self) -> Option<NumberType>
[src]
pub fn from_type_name(tname: &str) -> Result<Self, ParseError>
[src]
Constructs a primitive value type from a Rust-based type string similar
to what you would find from std::any::type_name
Examples
use entity::{PrimitiveType as PVT, NumberType as NT}; assert_eq!( PVT::from_type_name("bool").unwrap(), PVT::Bool, ); assert_eq!( PVT::from_type_name("char").unwrap(), PVT::Char, ); assert_eq!( PVT::from_type_name("u8").unwrap(), PVT::Number(NT::U8), ); assert_eq!( PVT::from_type_name("()").unwrap(), PVT::Unit, );
Trait Implementations
impl Clone for PrimitiveType
[src]
fn clone(&self) -> PrimitiveType
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for PrimitiveType
[src]
impl Debug for PrimitiveType
[src]
impl Default for PrimitiveType
[src]
impl Display for PrimitiveType
[src]
impl Eq for PrimitiveType
[src]
impl<'a> From<&'a Primitive> for PrimitiveType
[src]
impl From<Primitive> for PrimitiveType
[src]
impl From<PrimitiveType> for ValueType
[src]
fn from(t: PrimitiveType) -> Self
[src]
Converts primitive value type to a value type
impl FromStr for PrimitiveType
[src]
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
Parses a primitive value type
Examples
use entity::{PrimitiveType as PVT, NumberType as NT}; use strum::ParseError; use std::str::FromStr; assert_eq!(PVT::from_str("bool").unwrap(), PVT::Bool); assert_eq!(PVT::from_str("char").unwrap(), PVT::Char); assert_eq!(PVT::from_str("u32").unwrap(), PVT::Number(NT::U32)); assert_eq!(PVT::from_str("number:u32").unwrap(), PVT::Number(NT::U32)); assert_eq!(PVT::from_str("unit").unwrap(), PVT::Unit); assert_eq!(PVT::from_str("unknown").unwrap_err(), ParseError::VariantNotFound);
impl PartialEq<PrimitiveType> for PrimitiveType
[src]
fn eq(&self, other: &PrimitiveType) -> bool
[src]
fn ne(&self, other: &PrimitiveType) -> bool
[src]
impl StructuralEq for PrimitiveType
[src]
impl StructuralPartialEq for PrimitiveType
[src]
Auto Trait Implementations
impl RefUnwindSafe for PrimitiveType
impl Send for PrimitiveType
impl Sync for PrimitiveType
impl Unpin for PrimitiveType
impl UnwindSafe for PrimitiveType
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,