Don't duplicate char::is_ascii_digit
This commit is contained in:
parent
8cc82ee340
commit
e533bb73bc
1 changed files with 8 additions and 15 deletions
|
@ -385,7 +385,7 @@ pub mod printf {
|
||||||
if let Start = state {
|
if let Start = state {
|
||||||
match c {
|
match c {
|
||||||
'1'..='9' => {
|
'1'..='9' => {
|
||||||
let end = at_next_cp_while(next, is_digit);
|
let end = at_next_cp_while(next, char::is_ascii_digit);
|
||||||
match end.next_cp() {
|
match end.next_cp() {
|
||||||
// Yes, this *is* the parameter.
|
// Yes, this *is* the parameter.
|
||||||
Some(('$', end2)) => {
|
Some(('$', end2)) => {
|
||||||
|
@ -427,7 +427,7 @@ pub mod printf {
|
||||||
move_to!(next);
|
move_to!(next);
|
||||||
}
|
}
|
||||||
'1'..='9' => {
|
'1'..='9' => {
|
||||||
let end = at_next_cp_while(next, is_digit);
|
let end = at_next_cp_while(next, char::is_ascii_digit);
|
||||||
state = Prec;
|
state = Prec;
|
||||||
width = Some(Num::from_str(at.slice_between(end).unwrap(), None));
|
width = Some(Num::from_str(at.slice_between(end).unwrap(), None));
|
||||||
move_to!(end);
|
move_to!(end);
|
||||||
|
@ -441,7 +441,7 @@ pub mod printf {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let WidthArg = state {
|
if let WidthArg = state {
|
||||||
let end = at_next_cp_while(at, is_digit);
|
let end = at_next_cp_while(at, char::is_ascii_digit);
|
||||||
match end.next_cp() {
|
match end.next_cp() {
|
||||||
Some(('$', end2)) => {
|
Some(('$', end2)) => {
|
||||||
state = Prec;
|
state = Prec;
|
||||||
|
@ -473,7 +473,7 @@ pub mod printf {
|
||||||
if let PrecInner = state {
|
if let PrecInner = state {
|
||||||
match c {
|
match c {
|
||||||
'*' => {
|
'*' => {
|
||||||
let end = at_next_cp_while(next, is_digit);
|
let end = at_next_cp_while(next, char::is_ascii_digit);
|
||||||
match end.next_cp() {
|
match end.next_cp() {
|
||||||
Some(('$', end2)) => {
|
Some(('$', end2)) => {
|
||||||
state = Length;
|
state = Length;
|
||||||
|
@ -488,7 +488,7 @@ pub mod printf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'0'..='9' => {
|
'0'..='9' => {
|
||||||
let end = at_next_cp_while(next, is_digit);
|
let end = at_next_cp_while(next, char::is_ascii_digit);
|
||||||
state = Length;
|
state = Length;
|
||||||
precision = Some(Num::from_str(at.slice_between(end).unwrap(), None));
|
precision = Some(Num::from_str(at.slice_between(end).unwrap(), None));
|
||||||
move_to!(end);
|
move_to!(end);
|
||||||
|
@ -563,12 +563,12 @@ pub mod printf {
|
||||||
|
|
||||||
fn at_next_cp_while<F>(mut cur: Cur<'_>, mut pred: F) -> Cur<'_>
|
fn at_next_cp_while<F>(mut cur: Cur<'_>, mut pred: F) -> Cur<'_>
|
||||||
where
|
where
|
||||||
F: FnMut(char) -> bool,
|
F: FnMut(&char) -> bool,
|
||||||
{
|
{
|
||||||
loop {
|
loop {
|
||||||
match cur.next_cp() {
|
match cur.next_cp() {
|
||||||
Some((c, next)) => {
|
Some((c, next)) => {
|
||||||
if pred(c) {
|
if pred(&c) {
|
||||||
cur = next;
|
cur = next;
|
||||||
} else {
|
} else {
|
||||||
return cur;
|
return cur;
|
||||||
|
@ -579,14 +579,7 @@ pub mod printf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_digit(c: char) -> bool {
|
fn is_flag(c: &char) -> bool {
|
||||||
match c {
|
|
||||||
'0'..='9' => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_flag(c: char) -> bool {
|
|
||||||
match c {
|
match c {
|
||||||
'0' | '-' | '+' | ' ' | '#' | '\'' => true,
|
'0' | '-' | '+' | ' ' | '#' | '\'' => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue