]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide_db/src/helpers.rs
Merge #11455
[rust.git] / crates / ide_db / src / helpers.rs
index 9c6d3775c7f2b9ce30b70601e969bc1b8f313ce5..c355016c5dfd054dac27f949f37eeb4a6882bab6 100644 (file)
@@ -82,6 +82,9 @@ pub fn pick_best_token(
 ) -> Option<SyntaxToken> {
     tokens.max_by_key(move |t| f(t.kind()))
 }
+pub fn pick_token<T: AstToken>(mut tokens: TokenAtOffset<SyntaxToken>) -> Option<T> {
+    tokens.find_map(T::cast)
+}
 
 /// Converts the mod path struct into its ast representation.
 pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path {