forked from Rust-related/RustPython
Use binding for str.zfill sign matching
Co-Authored-By: Noah <33094578+coolreader18@users.noreply.github.com>
This commit is contained in:
@@ -993,14 +993,9 @@ impl PyString {
|
||||
if len <= value.len() {
|
||||
value.to_owned()
|
||||
} else {
|
||||
let first = value.bytes().next();
|
||||
let (sign, s) = match first {
|
||||
Some(b'+') | Some(b'-') => (
|
||||
std::str::from_utf8(&[first.unwrap(); 1])
|
||||
.unwrap()
|
||||
.to_owned(),
|
||||
&value[1..],
|
||||
),
|
||||
let mut bytes = value.bytes();
|
||||
let (sign, s) = match bytes.next() {
|
||||
Some(sign @ b'+') | Some(sign @ b'-') => ((sign as char).to_string(), &value[1..]),
|
||||
_ => ("".to_owned(), value.as_str()),
|
||||
};
|
||||
format!("{}{}{}", sign, "0".repeat(len - value.len()), s,)
|
||||
|
||||
Reference in New Issue
Block a user