mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
[refurb] Count codepoints not bytes for slice-to-remove-prefix-or-suffix (FURB188)
(#13631)
This commit is contained in:
parent
27ac34d683
commit
14ee5dbfde
4 changed files with 114 additions and 7 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue