Reversal of a singly-linked list in Rust
Before I begin, I recommend reading Learning Rust With Entirely Too Many Linked Lists.


Avoid unwraps, especially those after checking is_some. Use pattern matching instead.
The first test in reverse is redundant with the rest of the logic.
Implement Debug or Display to DRY up the printing of the list.
You should have some tests, especially for edge cases: 0, 1, and 2 items.
I'm not a fan of side effects inside of a map - it should err more on the side of purely functional. I'd use a match, even though it's more lines of code.
I'd simplify the iterator by just keeping a &amp;Link
You could choose to remove the temporary variable from push_front.
for item in foo.iter() is usually written as for item in &amp;foo, which implies that you need to implement IntoIterator for a reference to your type.




use std::fmt;

type Link&lt;T&gt; = Option&lt;Box&lt;Node&lt;T&gt;&gt;&gt;;

struct Node&lt;T&gt; {
    elem: T,
    next: Link&lt;T&gt;,
}

struct List&lt;T&gt; {
    head: Link&lt;T&gt;,
}

pub struct Iter&lt;'a, T: 'a&gt; {
    next: &amp;'a Link&lt;T&gt;,
}

impl&lt;T&gt; List&lt;T&gt; {
    pub fn new() -&gt; Self {
        List { head: None }
    }

    pub fn push_front(&amp;mut self, elem: T) {
        self.head = Some(Box::new(Node {
            elem: elem,
            next: self.head.take(),
        }));
    }

    pub fn reverse(&amp;mut self) {
        let mut prev = None;
        let mut current_node = self.head.take();

        while let Some(mut current_node_inner) = current_node.take() {
            let next = current_node_inner.next.take();
            current_node_inner.next = prev.take();
            prev = Some(current_node_inner);
            current_node = next;
        }

        self.head = prev.take();
    }

    pub fn iter(&amp;self) -&gt; Iter&lt;T&gt; {
        Iter { next: &amp;self.head }
    }
}

impl&lt;'a, T&gt; IntoIterator for &amp;'a List&lt;T&gt; {
    type Item = &amp;'a T;
    type IntoIter = Iter&lt;'a, T&gt;;

    fn into_iter(self) -&gt; Self::IntoIter {
        self.iter()
    }
}

impl&lt;'a, T&gt; Iterator for Iter&lt;'a, T&gt; {
    type Item = &amp;'a T;

    fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt; {
        match self.next.as_ref() {
            Some(next) =&gt; {
                self.next = &amp;next.next;
                Some(&amp;next.elem)
            }
            None =&gt; None,
        }
    }
}

impl&lt;T&gt; fmt::Debug for List&lt;T&gt;
    where T: fmt::Debug,
{
    fn fmt(&amp;self, f: &amp;mut fmt::Formatter) -&gt; fmt::Result {
        for item in self {
            write!(f, "{:?} ", item)?;
        }
        Ok(())
    }
}