Skip to content

Commit

Permalink
Accept non-lowercase input to FromStr
Browse files Browse the repository at this point in the history
  • Loading branch information
Gawdl3y committed Mar 3, 2024
1 parent 6de5c6e commit 66b4ed1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,22 @@ impl std::str::FromStr for Dice {
type Err = Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
dice().parse(s).into_result().map_err(|errs| Error {
let lc = s.to_lowercase();
let result = dice().parse(&lc).into_result().map_err(|errs| Error {
details: errs.iter().map(|err| err.to_string()).collect::<Vec<_>>().join("; "),
})
});
result
}
}

impl std::str::FromStr for Term {
type Err = Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
term().parse(s).into_result().map_err(|errs| Error {
let lc = s.to_lowercase();
let result = term().parse(&lc).into_result().map_err(|errs| Error {
details: errs.iter().map(|err| err.to_string()).collect::<Vec<_>>().join("; "),
})
});
result
}
}

0 comments on commit 66b4ed1

Please sign in to comment.