Commit c909108
authored
Add TryFrom for PartialDuration to Duration (#585)
This PR adds a `TryFrom` implemenation for converting a PartialDuration
to Duration.
The core reasoning is to simplify the case where someone would want to
add a single day in Rust.
```rust
use temporal_rs::{Temporal, PlainDate, partial::PartialDuration};
let today = Temporal::now().plain_date_iso(None).unwrap();
let one_day = PartialDuration::empty().with_days(1);
// Before:
// let tomorrow = today.add(Duration::from_partial_duration(one_day).unwrap()).unwrap()
// After:
let tomorrow = today.add(one_day.try_into().unwrap()).unwrap();
```1 parent 1f6b893 commit c909108
1 file changed
+7
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
336 | 343 | | |
337 | 344 | | |
338 | 345 | | |
| |||
0 commit comments