Last active
April 6, 2017 19:15
-
-
Save nikhilshagri/51fb193ac8f347ba0ff4e6213c49904d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(ref s)) => { | |
match s.node { | |
StmtDecl(ref decl, _) => { | |
match decl.clone().unwrap().node { | |
DeclLocal(ref local) => Some(PatternSource::LetDecl(local)), | |
_ => { | |
return None; | |
}, | |
} | |
} | |
_ => { | |
return None; | |
}, | |
} | |
} | |
_ => { | |
return None; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment