Skip to content

Instantly share code, notes, and snippets.

@QuietMisdreavus
Forked from nikhilshagri/lifetimes.rs
Last active April 6, 2017 19:27
Show Gist options
  • Save QuietMisdreavus/d72e040f7d7a34d9e4547cf4f7e8e3f6 to your computer and use it in GitHub Desktop.
Save QuietMisdreavus/d72e040f7d7a34d9e4547cf4f7e8e3f6 to your computer and use it in GitHub Desktop.
pub fn get_pattern_source(&self, pat: &Pat) -> Option<PatternSource<'hir>> {
let id = // get id
match self.find(id) {
Some(NodeExpr(ref e)) => {
Some(PatternSource::MatchExpr(e))
}
Some(NodeStmt(&Stmt { node: StmtDecl(ref decl, _), .. })) => {
match decl.clone().unwrap().node {
DeclLocal(ref local) => Some(PatternSource::LetDecl(local)),
_ => {
return None;
},
}
}
_ => {
return None;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment