FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

more clippy rules by ShaharNaveh · Pull Request #8050 · RustPython/RustPython · GitHub

Repository navigation

Prev Previous commit
Next Next commit
Simplify
  • Loading branch information
ShaharNaveh committed Jun 5, 2026
commit 465f4a39f8e00715c7b9fa0a290169830fd8d1f6
18 changes: 8 additions & 10 deletions crates/vm/src/builtins/str.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1886,22 +1886,20 @@ impl ToPyObject for Wtf8Buf {
impl ToPyObject for char {
fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {
let cp = self as u32;
if u8::try_from(cp).is_ok() {
vm.ctx.latin1_char(cp as u8).into()
} else {
vm.ctx.new_str(self).into()
}
u8::try_from(cp).map_or_else(
|_| vm.ctx.new_str(self).into(),
|v| vm.ctx.latin1_char(v).into(),
)
}
}

impl ToPyObject for CodePoint {
fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef {
let cp = self.to_u32();
if u8::try_from(cp).is_ok() {
vm.ctx.latin1_char(cp as u8).into()
} else {
vm.ctx.new_str(self).into()
}
u8::try_from(cp).map_or_else(
|_| vm.ctx.new_str(self).into(),
|v| vm.ctx.latin1_char(v).into(),
)
}
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL