pub struct TypeSpecifier<'a> {
pub span: &'a str,
pub stem: TypeStem<'a>,
pub sizes: Vec<Option<NonZeroUsize>>,
}Expand description
Represents a type-name. Consists of an identifier and optional array sizes.
A type specifier has a stem, which is TypeStem representing either a
RootType or a TupleSpecifier, and a list of array sizes. The array
sizes are in innermost-to-outermost order. An empty array size vec indicates
that the specified type is not an array
Type specifier examples:
uint256uint256[2]uint256[2][](uint256,uint256)(uint256,uint256)[2]MyStructMyStruct[2]
https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.typeName
§Compatibility with JSON ABI
This type supports the internalType semantics for JSON-ABI compatibility.
Examples of valid JSON ABI internal types:
contract MyContractstruct MyStructenum MyEnumstruct MyContract.MyStruct\[333\]enum MyContract.MyEnum[][][][][][]MyValueType
§Examples
let spec = TypeSpecifier::parse("uint256[2][]")?;
assert_eq!(spec.span(), "uint256[2][]");
assert_eq!(spec.stem.span(), "uint256");
// The sizes are in innermost-to-outermost order.
assert_eq!(spec.sizes.as_slice(), &[NonZeroUsize::new(2), None]);Fields§
§span: &'a strThe full span of the specifier.
stem: TypeStem<'a>The type stem, which is either a root type or a tuple type.
sizes: Vec<Option<NonZeroUsize>>Array sizes, in innermost-to-outermost order. If the size is None,
then the array is dynamic. If the size is Some, then the array is
fixed-size. If the vec is empty, then the type is not an array.
Implementations§
Source§impl<'a> TypeSpecifier<'a>
impl<'a> TypeSpecifier<'a>
Sourcepub fn try_basic_solidity(&self) -> Result<()>
pub fn try_basic_solidity(&self) -> Result<()>
Returns true if the type is a basic Solidity type.
Trait Implementations§
Source§impl AsRef<str> for TypeSpecifier<'_>
impl AsRef<str> for TypeSpecifier<'_>
Source§impl<'a> Clone for TypeSpecifier<'a>
impl<'a> Clone for TypeSpecifier<'a>
Source§fn clone(&self) -> TypeSpecifier<'a>
fn clone(&self) -> TypeSpecifier<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more