mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
simplify
This commit is contained in:
parent
d5f7b2e52a
commit
a6b92a8cc0
9 changed files with 141 additions and 144 deletions
|
@ -96,6 +96,21 @@ pub enum RangeOrOffset {
|
|||
Offset(TextSize),
|
||||
}
|
||||
|
||||
impl RangeOrOffset {
|
||||
pub fn expect_offset(self) -> TextSize {
|
||||
match self {
|
||||
RangeOrOffset::Offset(it) => it,
|
||||
RangeOrOffset::Range(_) => panic!("expected an offset but got a range instead"),
|
||||
}
|
||||
}
|
||||
pub fn expect_range(self) -> TextRange {
|
||||
match self {
|
||||
RangeOrOffset::Range(it) => it,
|
||||
RangeOrOffset::Offset(_) => panic!("expected a range but got an offset"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RangeOrOffset> for TextRange {
|
||||
fn from(selection: RangeOrOffset) -> Self {
|
||||
match selection {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue