Skip to content

Commit c83bb99

Browse files
committed
upgrade to rust 1.31 and 2018 edition
1 parent 903a239 commit c83bb99

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

exercises/doubly-linked-list/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "doubly-linked-list"
33
version = "0.0.0"
4+
edition = "2018"
45

56
[features]
67
# check correct covariance and Send, Sync

exercises/doubly-linked-list/example.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct LinkedList<T> {
2424
unsafe impl<T: Send> Send for LinkedList<T> {}
2525
unsafe impl<T: Sync> Sync for LinkedList<T> {}
2626

27-
pub struct Cursor<'a, T: 'a> {
27+
pub struct Cursor<'a, T> {
2828
list: &'a mut LinkedList<T>,
2929
node: OptNodePtr<T>,
3030
}
@@ -174,12 +174,12 @@ impl<T> Drop for LinkedList<T> {
174174
}
175175
}
176176

177-
pub struct Iter<'a, T: 'a> {
177+
pub struct Iter<'a, T> {
178178
next_node: OptNodePtr<T>,
179179
marker: std::marker::PhantomData<&'a LinkedList<T>>,
180180
}
181181

182-
impl<'a, T: 'a> Iterator for Iter<'a, T> {
182+
impl<'a, T> Iterator for Iter<'a, T> {
183183
type Item = &'a T;
184184

185185
fn next(&mut self) -> Option<Self::Item> {
@@ -192,7 +192,7 @@ impl<'a, T: 'a> Iterator for Iter<'a, T> {
192192
}
193193
}
194194

195-
impl<'a, T: 'a> Cursor<'a, T> {
195+
impl<T> Cursor<'_, T> {
196196
pub fn peek_mut(&mut self) -> Option<&mut T> {
197197
unsafe {
198198
self.node.map(|node| &mut (*node.as_ptr()).element)

exercises/doubly-linked-list/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ mod pre_implemented;
55

66
pub struct LinkedList<T>(std::marker::PhantomData<T>);
77

8-
pub struct Cursor<'a, T: 'a>(std::marker::PhantomData<&'a mut T>);
8+
pub struct Cursor<'a, T>(std::marker::PhantomData<&'a mut T>);
99

10-
pub struct Iter<'a, T: 'a>(std::marker::PhantomData<&'a T>);
10+
pub struct Iter<'a, T>(std::marker::PhantomData<&'a T>);
1111

1212
impl<T> LinkedList<T> {
1313
pub fn new() -> Self {
@@ -76,7 +76,7 @@ impl<T> Cursor<'_, T> {
7676
}
7777
}
7878

79-
impl<'a, T: 'a> Iterator for Iter<'a, T> {
79+
impl<'a, T> Iterator for Iter<'a, T> {
8080
type Item = &'a T;
8181

8282
fn next(&mut self) -> Option<&'a T> {

exercises/doubly-linked-list/src/pre_implemented.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
//! You are free to use anything, if it suits you.
33
//! They are useful for the test framework, but the implementation is trivial.
44
//! We supply them to reduce work both for you and the mentors.
5-
use {LinkedList, Cursor};
6-
5+
use crate::{LinkedList, Cursor};
76

87
impl<T> LinkedList<T> {
98
pub fn push_back(&mut self, element: T) {
@@ -31,7 +30,7 @@ impl<T> LinkedList<T> {
3130
}
3231
}
3332

34-
impl<T> ::std::iter::FromIterator<T> for LinkedList<T> {
33+
impl<T> std::iter::FromIterator<T> for LinkedList<T> {
3534
fn from_iter<I>(iter: I) -> Self
3635
where
3736
I: IntoIterator<Item = T>,
@@ -51,7 +50,7 @@ impl<T: Clone> Clone for LinkedList<T> {
5150
}
5251

5352
// seek methods, return false if end of list is reached prematurely
54-
impl<'a, T: 'a> Cursor<'a, T> {
53+
impl<T> Cursor<'_, T> {
5554
pub fn seek_forward(&mut self, n: usize) -> bool {
5655
(0..n).all(|_| self.next().is_some())
5756
}

exercises/doubly-linked-list/tests/doubly-linked-list.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
extern crate doubly_linked_list;
21
use doubly_linked_list::*;
32

43
#[test]

0 commit comments

Comments
 (0)