From ef3bf906c477048076faa8e18b50fc34175f6c14 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 19 Mar 2020 11:38:26 +0100 Subject: Generalize --- crates/ra_syntax/src/algo.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/ra_syntax/src') 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(me: &T, direction: Direction) -> Option { + me.syntax().siblings(direction).skip(1).find_map(T::cast) +} + #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum InsertPosition { First, -- cgit v1.2.3