weihanglo / rust-algorithm-club

Learn algorithms and data structures with Rust
https://rust-algo.club
MIT License
406 stars 43 forks source link

cargo checked failed for singly linked list #18

Closed henry40408 closed 5 years ago

henry40408 commented 5 years ago

OS: macOS 10.14.1 rustc version: 1.28.0

    Checking rust-algorithm-club v0.0.1 (file:///Users/henry/Develop/rust-algorithm-club)
error[E0309]: the parameter type `T` may not live long enough
  --> src/collections/singly_linked_list/mod.rs:31:5
   |
30 | pub struct Iter<'a, T> {
   |                     - help: consider adding an explicit lifetime bound `T: 'a`...
31 |     next: Option<&'a Node<T>>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: ...so that the reference type `&'a collections::singly_linked_list::Node<T>` does not outlive the data it points at
  --> src/collections/singly_linked_list/mod.rs:31:5
   |
31 |     next: Option<&'a Node<T>>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0309]: the parameter type `T` may not live long enough
  --> src/collections/singly_linked_list/mod.rs:38:5
   |
37 | pub struct IterMut<'a, T> {
   |                        - help: consider adding an explicit lifetime bound `T: 'a`...
38 |     next: Option<&'a mut Node<T>>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: ...so that the reference type `&'a mut collections::singly_linked_list::Node<T>` does not outlive the data it points at
  --> src/collections/singly_linked_list/mod.rs:38:5
   |
38 |     next: Option<&'a mut Node<T>>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0309]: the parameter type `T` may not live long enough
   --> src/collections/singly_linked_list/mod.rs:229:5
    |
228 | impl<'a, T> Iterator for Iter<'a, T> {
    |          - help: consider adding an explicit lifetime bound `T: 'a`...
229 |     type Item = &'a T;
    |     ^^^^^^^^^^^^^^^^^^
    |
note: ...so that the reference type `&'a T` does not outlive the data it points at
   --> src/collections/singly_linked_list/mod.rs:229:5
    |
229 |     type Item = &'a T;
    |     ^^^^^^^^^^^^^^^^^^

error[E0309]: the parameter type `T` may not live long enough
   --> src/collections/singly_linked_list/mod.rs:242:5
    |
241 | impl<'a, T> Iterator for IterMut<'a, T> {
    |          - help: consider adding an explicit lifetime bound `T: 'a`...
242 |     type Item = &'a mut T;
    |     ^^^^^^^^^^^^^^^^^^^^^^
    |
note: ...so that the reference type `&'a mut T` does not outlive the data it points at
   --> src/collections/singly_linked_list/mod.rs:242:5
    |
242 |     type Item = &'a mut T;
    |     ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0309`.
error: Could not compile `rust-algorithm-club`.

To learn more, run the command again with --verbose.
weihanglo commented 5 years ago

Same as #17. Update to 2018 edition may help. Ref #2