-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shorter logpreamble parse implementation by more nom combinators usage #33
Conversation
Added a license |
@jrouaix PR looks good, i like the nom tuple idea. Only comment/question i have is the anyhow I’ve generally try to reference this blog when determining when to use unwrap. if u think |
Hi @puffyCid About The way rust check tests completion is through panics & error results too, both tests will fail. In the example below, both
fn the_answer() -> Result<u32, MyLibError> {
Ok(42)
}
#[test]
fn test1() {
let forty_two = the_answer().unwrap();
assert_eq!(forty_two, 43);
}
#[test]
fn test2() -> anyhow::Result<()> {
let forty_two = the_answer()?;
assert_eq!(forty_two, 43);
Ok(())
} Personally I tend to consider So for instance : static RE_EMAIL: once_cell::sync::Lazy<Regex> = once_cell::sync::Lazy::new(|| Regex::new(EMAIL_REGEX).expect("Regex should be valid")); is actual production code because :
In the end it's just me preferring chaining faillible function calls with
Feel free to decide what style you like and i'll adapt this PR and future ones accordingly. |
understood, thanks for the explanation. |
Hello @puffyCid
This is a revival of the too ambitious #22.
I plan to provide you with a lot of small, easy to review&merge PRs like this one.
So in this first one :
LogPreamble
more
nom
combinators usagetuple
combinator)mut
needed)added anyhow
dev
dependency for easy error handlingunwrap
s even in test code when I can)added a
parse
function the consumes the input.detect
one is useparse/consuming
function in the next submissionsTell me what you think about this plan ?