ast: pub patterns, and, since Pat replaced Ty, !(never) patterns.
This commit is contained in:
@@ -65,6 +65,8 @@ pub enum Use {
|
||||
pub enum Pat {
|
||||
/// Matches anything without binding
|
||||
Ignore,
|
||||
/// Matches nothing, ever
|
||||
Never,
|
||||
/// Matches nothing; used for macro substitution
|
||||
MetId(String),
|
||||
/// Matches anything, and binds it to a name
|
||||
@@ -84,6 +86,8 @@ pub enum Pat {
|
||||
/// Operators on lists of patterns
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum PatOp {
|
||||
/// Changes the visibility mode to "public"
|
||||
Pub,
|
||||
/// Changes the binding mode to "mutable"
|
||||
Mut,
|
||||
/// Matches the dereference of a pointer (`&pat`)
|
||||
@@ -541,6 +545,7 @@ impl Display for Pat {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Ignore => "_".fmt(f),
|
||||
Self::Never => "!".fmt(f),
|
||||
Self::Lit(literal) => literal.fmt(f),
|
||||
Self::MetId(name) => write!(f, "`{name}"),
|
||||
Self::Name(name) => name.fmt(f),
|
||||
@@ -569,6 +574,7 @@ impl Display for Pat {
|
||||
impl Display for PatOp {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(match self {
|
||||
Self::Pub => "pub ",
|
||||
Self::Mut => "mut ",
|
||||
Self::Ref => "&",
|
||||
Self::Rest => "..",
|
||||
|
||||
Reference in New Issue
Block a user