mirror of
https://github.com/astral-sh/ruff
synced 2026-01-11 08:34:29 -05:00
[refurb] Count codepoints not bytes for slice-to-remove-prefix-or-suffix (FURB188) (#13631)
This commit is contained in:
@@ -96,6 +96,14 @@ impl Int {
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the [`Int`] as an u64, if it can be represented as that data type.
|
||||
pub fn as_usize(&self) -> Option<usize> {
|
||||
match &self.0 {
|
||||
Number::Small(small) => usize::try_from(*small).ok(),
|
||||
Number::Big(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the [`Int`] as an i8, if it can be represented as that data type.
|
||||
pub fn as_i8(&self) -> Option<i8> {
|
||||
match &self.0 {
|
||||
|
||||
Reference in New Issue
Block a user