diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-19 10:38:59 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-19 10:38:59 +0000 |
commit | 11f2c6908b23566703469f9ad7731425c23daedf (patch) | |
tree | e844c04028d229ddcb42f97fdd1f972010a8d3d2 /crates/ra_syntax | |
parent | 13af63a40393c0e299d7db2545aee0aeb1a5c2bc (diff) | |
parent | ef3bf906c477048076faa8e18b50fc34175f6c14 (diff) |
Merge #3650
3650: Generalize r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/algo.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index b87c7084e..344cf0fbe 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs | |||
@@ -73,6 +73,10 @@ pub fn least_common_ancestor(u: &SyntaxNode, v: &SyntaxNode) -> Option<SyntaxNod | |||
73 | v.ancestors().find(|it| u_ancestors.contains(it)) | 73 | v.ancestors().find(|it| u_ancestors.contains(it)) |
74 | } | 74 | } |
75 | 75 | ||
76 | pub fn neighbor<T: AstNode>(me: &T, direction: Direction) -> Option<T> { | ||
77 | me.syntax().siblings(direction).skip(1).find_map(T::cast) | ||
78 | } | ||
79 | |||
76 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 80 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
77 | pub enum InsertPosition<T> { | 81 | pub enum InsertPosition<T> { |
78 | First, | 82 | First, |