diff options
| author | CAD97 <cad97@cad97.com> | 2020-02-18 13:18:33 -0500 |
|---|---|---|
| committer | CAD97 <cad97@cad97.com> | 2020-04-08 02:24:16 -0400 |
| commit | 2fcfd233f755c548ddc4d5fda517a7dbb9f04ba3 (patch) | |
| tree | 655c31fd84477a56252737868e7c65c965dbaa0f /src/test | |
| parent | b70e7fd0db5d23a2e045e89b8bc7e5564acce9b7 (diff) | |
| download | rust-2fcfd233f755c548ddc4d5fda517a7dbb9f04ba3.tar.gz rust-2fcfd233f755c548ddc4d5fda517a7dbb9f04ba3.zip | |
Redesign the Step trait
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/impl-trait/example-calendar.rs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/test/ui/impl-trait/example-calendar.rs b/src/test/ui/impl-trait/example-calendar.rs index f1b1656745e..fafab8a102a 100644 --- a/src/test/ui/impl-trait/example-calendar.rs +++ b/src/test/ui/impl-trait/example-calendar.rs @@ -2,6 +2,7 @@ #![feature(fn_traits, step_trait, + step_trait_ext, unboxed_closures, )] @@ -10,7 +11,6 @@ //! Originally converted to Rust by [Daniel Keep](https://github.com/DanielKeep). use std::fmt::Write; -use std::mem; /// Date representation. #[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] @@ -156,32 +156,16 @@ impl<'a, 'b> std::ops::Add<&'b NaiveDate> for &'a NaiveDate { } } -impl std::iter::Step for NaiveDate { +unsafe impl std::iter::Step for NaiveDate { fn steps_between(_: &Self, _: &Self) -> Option<usize> { unimplemented!() } - fn replace_one(&mut self) -> Self { - mem::replace(self, NaiveDate(0, 0, 1)) + fn forward_checked(start: Self, n: usize) -> Option<Self> { + Some((0..n).fold(start, |x, _| x.succ())) } - fn replace_zero(&mut self) -> Self { - mem::replace(self, NaiveDate(0, 0, 0)) - } - - fn add_one(&self) -> Self { - self.succ() - } - - fn sub_one(&self) -> Self { - unimplemented!() - } - - fn add_usize(&self, _: usize) -> Option<Self> { - unimplemented!() - } - - fn sub_usize(&self, _: usize) -> Option<Self> { + fn backward_checked(_: Self, _: usize) -> Option<Self> { unimplemented!() } } |
