-
Notifications
You must be signed in to change notification settings - Fork 477
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
Add datetime value parser #1723
Conversation
Ah, self referential structs... AFAIK there are a few approaches: use some library that will do some magic, leak the string to get static lifetime, write a wrapper type (like |
I think this is correct, as long as it is in its own module: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ffad275ea8783f05068a850ac351195c |
@MaxVerevkin, why does it matter if it's in its own module? |
This way it can be proven that no code accidentally leaks static reference, because public API would only provide access to borrowed items. Actually, never mind. Any fn make_static_item(item: Item<'_>) -> Item<'static> {
match item {
Item::Literal(str) => Item::OwnedLiteral(str.into()),
// And so on
}
}
fn parse(str: &str) -> Vec<Item<'static>> {
StrftimeItems::new(str).map(make_static_item).collect()
} |
I even think this could be upstreamed to |
Thanks @MaxVerevkin for your help getting the static item stuff worked out!! I added docs the the formatting page as well. |
This should be tagged as breaking (removal of the locale option and addition of the new datetime formatter) |
|
Resolves greshake#1708 Allow quoted values in format arg parse
Hopefully that does it 🤞! |
Resolves #1708
(well will)I added a new parsers for the current time.
Issues to resolve* icon doesn't work* Instead of parsing the format each iteration it seems that aStrftimeItems
could be used, but the lifetimes eluded me so far.