pub enum Pat {
}Variants§
Wild
Ident(IdentPat)
Struct(StructPat)
TupleStruct(TupleStructPat)
Or(Vec<Pat>)
Tuple(Vec<Pat>)
Box(Box<Pat>)
Ref(RefPat)
Lit(Expr)
Range(Range)
Slice(Vec<Pat>)
Rest
Paren(Box<Pat>)
MacCall(MacCall)
Implementations§
source§impl Pat
impl Pat
pub fn ident(ident: impl Into<String>) -> Self
pub fn slf() -> Self
sourcepub fn ref_self() -> Self
pub fn ref_self() -> Self
Examples found in repository?
examples/enum.rs (line 9)
1 2 3 4 5 6 7 8 9 10 11 12 13
fn main() -> Result<(), Box<dyn std::error::Error>> {
use ruast::*;
let mut krate = Crate::new();
let def = EnumDef::empty("Foo")
.with_variant(Variant::empty("Bar"))
.with_variant(Variant::tuple("Baz", vec![FieldDef::anonymous("u32")]));
krate.add_item(def);
let imp = Impl::empty("Foo").with_item(Fn::empty_method("test", Pat::ref_self()));
krate.add_item(imp);
println!("{krate}");
Ok(())
}More examples
examples/struct.rs (line 9)
1 2 3 4 5 6 7 8 9 10 11 12 13
fn main() -> Result<(), Box<dyn std::error::Error>> {
use ruast::*;
let mut krate = Crate::new();
let def = StructDef::empty("Foo")
.with_field(FieldDef::inherited("foo", Type::from("u32")))
.with_field(FieldDef::inherited("bar", Type::from("u32")));
krate.add_item(def);
let imp = Impl::empty("Foo").with_item(Fn::empty_method("test", Pat::ref_self()));
krate.add_item(imp);
println!("{krate}");
Ok(())
}pub fn ref_mut_self() -> Self
pub fn mut_self() -> Self
pub fn mut_(ident: impl Into<String>) -> Self
pub fn bind(self, kind: impl Into<LocalKind>) -> Local
Trait Implementations§
source§impl From<Pat> for TokenStream
impl From<Pat> for TokenStream
impl Eq for Pat
impl StructuralEq for Pat
impl StructuralPartialEq for Pat
Auto Trait Implementations§
impl RefUnwindSafe for Pat
impl Send for Pat
impl Sync for Pat
impl Unpin for Pat
impl UnwindSafe for Pat
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