Generalize AnchorRangeMultimap's 'intersecting ranges' API
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
79ba217485
commit
f1db618be2
2 changed files with 24 additions and 9 deletions
|
@ -2523,3 +2523,19 @@ impl ToPoint for usize {
|
|||
content.into().visible_text.to_point(*self)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FromAnchor {
|
||||
fn from_anchor<'a>(anchor: &Anchor, content: &Content<'a>) -> Self;
|
||||
}
|
||||
|
||||
impl FromAnchor for Point {
|
||||
fn from_anchor<'a>(anchor: &Anchor, content: &Content<'a>) -> Self {
|
||||
anchor.to_point(content)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromAnchor for usize {
|
||||
fn from_anchor<'a>(anchor: &Anchor, content: &Content<'a>) -> Self {
|
||||
anchor.to_offset(content)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue