-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Parse &str
instead of &[u8]
#541
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think this makes sense directionally. Some questions about the new implementations though.
Should I turn the third commit https://github.com/djc/askama/pull/541/commits/edc3cf80d6708800322f716b90ce1ae3a939f6c0 into a new PR? |
No, the third commit can stay in this PR. So I guess my feeling is that a lot of the substantial changes to |
So this is kind of the other way around from what I intended. I'm actually more interested in the (If that is harder than I'm making it out to be or if you're just not interested in doing the work, that's fine too.) |
Iterating strings is just no fun in Rust. One little mistake and you are splitting a codepoint, which causes a panic. That's why I wanted to let nom do the error prone stuff instead of porting the &[u8] implementation directly. Also I'm not 100% sure the current implementation in main is 100% correct. E.g.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again sorry for the slow review. Your contributions are highly valued, I've just found it hard to find the time to spend enough attention on these nuanced changes.
askama_shared/src/parser.rs
Outdated
/// Skips over the any amout of `inner` until `end` was found. | ||
/// Returns a tuple of the skipped string and the found end marker. | ||
fn skip_till<'a, I, O>( | ||
mut inner: impl FnMut(&'a [u8]) -> IResult<&'a [u8], I>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think take_content()
is now the only caller for skip_till
, which means inner
is always anychar
. Can we simplify? Maybe even inline skip_till()
into take_content()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is used in #546, too.
I removed the "inner" parameter, because it's "anychar" for both its uses.
I cleaned up the implementation a bit. I think it's much easier on the eyes now. :)
@Kijewski do you have a moment to work on this soon? Otherwise I'll probably take it over, I think it's the last blocker to 0.11. |
Askama's takes valid UTF-8 files as input. So why operate on byte slices instead of strings? This makes writing some functions a lot simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for all the work on this!
Askama's takes valid UTF-8 files as input. So why operate on byte slices
instead of strings? This makes writing some functions a lot simpler.