Range formatting API (#9635)

This commit is contained in:
Micha Reiser 2024-01-31 11:13:37 +01:00 committed by GitHub
parent 6bb126415d
commit ce14f4dea5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 3273 additions and 762 deletions

View file

@ -1,7 +1,8 @@
use std::fmt;
use std::fmt::{Debug, Formatter};
use std::num::NonZeroUsize;
use std::num::{NonZeroUsize, ParseIntError};
use std::ops::Deref;
use std::str::FromStr;
use std::sync::Arc;
use ruff_text_size::{TextLen, TextRange, TextSize};
@ -325,6 +326,13 @@ const fn unwrap<T: Copy>(option: Option<T>) -> T {
}
}
impl FromStr for OneIndexed {
type Err = ParseIntError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(OneIndexed(NonZeroUsize::from_str(s)?))
}
}
#[cfg(test)]
mod tests {
use ruff_text_size::TextSize;