From bc7b2c95288520c56e134c02c8da3df3d85a71c3 Mon Sep 17 00:00:00 2001 From: Shrikrishna Bhat <37535815+master-of-none@users.noreply.github.com> Date: Sun, 27 Aug 2023 04:54:28 +0000 Subject: [PATCH] Added default - fixed clippy warnings --- lists/src/first.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lists/src/first.rs b/lists/src/first.rs index f34b332..3a0aa3e 100644 --- a/lists/src/first.rs +++ b/lists/src/first.rs @@ -21,7 +21,7 @@ impl List { pub fn push(&mut self, elem: i32) { let new_node = Box::new(Node { - elem: elem, + elem, next: mem::replace(&mut self.head, Link::Empty), }); @@ -39,6 +39,12 @@ impl List { } } +impl Default for List { + fn default() -> Self { + Self::new() + } +} + impl Drop for List { fn drop(&mut self) { let mut cur_link = mem::replace(&mut self.head, Link::Empty);