Overall this looks nice, but I found myself stumbling over the ToSpan syntax: let span = 5.days().hours(8).minutes(1); It feels sort of weird how the first number appears in front, and then all the other ones are function arguments. I suppose if you don't like that you can just write: let span = Span::new().days(5).hours(8).minutes(1); at the expense of a couple characters, which is not too bad.
I stumbled over use jiff::{Timestamp, ToSpan}; fn main() -> Result { let time: Timestamp = "2024-07-11T01:14:00Z".parse()?; I seem to remember Rust does that thing with interfaces instead of classes, is it that? How come I import a library and all of a sudden strings have a `parse()` method that despite its generic name results in a `Timestamp` object? or is it the left-hand side that determines which meaning `str.pa…
- let time = Timestamp::parse("2024-07-11T01:14:00Z")?;
- let time: Timestamp = "2024-07-11T01:14:00Z".parse()?;
- let time = "2024-07-11T01:14:00Z".parse::()?;
You’re free to choose whatever you prefer, although the compiler needs to be able to infer the type of time. If it can’t, it’ll let you know.
So a fourth option is allowed, as long as the subsequent lines make the type of time unambiguous.
- let time = "2024-07-11T01:14:00Z".parse()?;
This is a direct consequence of Timestamp implementing the FromStr trait.