pub struct GlobalType { /* private fields */ }Expand description
Global types classify global variables, which hold a value and can either be mutable or immutable.
See https://webassembly.github.io/spec/core/syntax/types.html#global-types
§Examples
§Mutable
use wasm_ast::{ValueType, GlobalType, Mutability};
let mutable = GlobalType::mutable(ValueType::I64);
assert_eq!(mutable.mutability(), Mutability::Mutable);
assert_eq!(mutable.kind(), ValueType::I64);
assert_eq!(mutable, GlobalType::new( ValueType::I64,Mutability::Mutable));§Immutable
use wasm_ast::{ValueType, GlobalType, Mutability};
let immutable = GlobalType::immutable(ValueType::F64);
assert_eq!(immutable.mutability(), Mutability::Immutable);
assert_eq!(immutable.kind(), ValueType::F64);
assert_eq!(immutable, GlobalType::new( ValueType::F64,Mutability::Immutable));Implementations§
Source§impl GlobalType
impl GlobalType
Sourcepub fn new(kind: ValueType, mutability: Mutability) -> Self
pub fn new(kind: ValueType, mutability: Mutability) -> Self
Creates a new GlobalType for a global variable with the given mutability and value type.
Sourcepub fn mutable(kind: ValueType) -> Self
pub fn mutable(kind: ValueType) -> Self
Creates a new GlobalType for a mutable global variable.
Sourcepub fn immutable(kind: ValueType) -> Self
pub fn immutable(kind: ValueType) -> Self
Creates a new GlobalType for an immutable (i.e. constant) global variable.
Sourcepub fn kind(&self) -> ValueType
pub fn kind(&self) -> ValueType
The ValueType of the global variable defined by this GlobalType.
Sourcepub fn mutability(&self) -> Mutability
pub fn mutability(&self) -> Mutability
The mutability (i.e. variable versus constant) of the global variable type.
Trait Implementations§
Source§impl Clone for GlobalType
impl Clone for GlobalType
Source§fn clone(&self) -> GlobalType
fn clone(&self) -> GlobalType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GlobalType
impl Debug for GlobalType
Source§impl PartialEq for GlobalType
impl PartialEq for GlobalType
impl Copy for GlobalType
impl Eq for GlobalType
impl StructuralPartialEq for GlobalType
Auto Trait Implementations§
impl Freeze for GlobalType
impl RefUnwindSafe for GlobalType
impl Send for GlobalType
impl Sync for GlobalType
impl Unpin for GlobalType
impl UnwindSafe for GlobalType
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