top | item 41031294

(no title)

frereit | 1 year ago

I agree. Personally, I'd prefer

    let span = 5.days() + 8.hours() + 1.minutes();

discuss

order

mutatio|1 year ago

wging|1 year ago

That isn't an implementation of addition between Spans and other Spans. It looks like there isn't one in the library right now. `impl<'a> Add<Span> for &'a Zoned` means a borrow of Zoned is on the left hand side, and a Span on the right. So it says that if z is a Zoned (not a Span) and s is a Span, you can do `&z + s` to add a span to a Zoned. There are a bunch of implementations there, DateTime + Span, Date + Span, Time + Span, Offset + Span. All with Span on the right, but none for Span + Span (nor Span + &Span, or &Span + &Span, ...).

csomar|1 year ago

I wonder if OP will accept a PR for such a change. Your proposal is much readable and flexible (it's not clear from the docs if you can add random time ranges together). Plus, you'll be able to create your own ranges like `1.decade` or `1.application_timeframe` and add/subtract them.

mijoharas|1 year ago

Have you checked the API to see if that works? I imagine it does.