pub struct RootType<'a>(/* private fields */);
Expand description
A root type, with no array suffixes. Corresponds to a single, non-sequence type. This is the most basic type specifier.
Note that this type might modify the input string, so span()
must not be assumed to be the same as the input string.
§Examples
let root_type = RootType::parse("uint256")?;
assert_eq!(root_type.span(), "uint256");
// Allows unknown types
assert_eq!(RootType::parse("MyStruct")?.span(), "MyStruct");
// No sequences
assert!(RootType::parse("uint256[2]").is_err());
// No tuples
assert!(RootType::parse("(uint256,uint256)").is_err());
// Input string might get modified
assert_eq!(RootType::parse("uint")?.span(), "uint256");
Implementations§
Source§impl<'a> RootType<'a>
impl<'a> RootType<'a>
Sourcepub const unsafe fn new_unchecked(s: &'a str) -> Self
pub const unsafe fn new_unchecked(s: &'a str) -> Self
Create a new root type from a string without checking if it’s valid.
§Safety
The string passed in must be a valid Solidity identifier. See
is_valid_identifier
.
Sourcepub fn try_basic_solidity(self) -> Result<()>
pub fn try_basic_solidity(self) -> Result<()>
Returns Ok(())
if the type is a basic Solidity type.
Trait Implementations§
Source§impl<'a> Ord for RootType<'a>
impl<'a> Ord for RootType<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialOrd for RootType<'a>
impl<'a> PartialOrd for RootType<'a>
impl<'a> Copy for RootType<'a>
impl<'a> Eq for RootType<'a>
impl<'a> StructuralPartialEq for RootType<'a>
Auto Trait Implementations§
impl<'a> Freeze for RootType<'a>
impl<'a> RefUnwindSafe for RootType<'a>
impl<'a> Send for RootType<'a>
impl<'a> Sync for RootType<'a>
impl<'a> Unpin for RootType<'a>
impl<'a> UnwindSafe for RootType<'a>
Blanket Implementations§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)