Advent of Code 2019 Day 6 - Beginner Rust solution I am doing Advent of Code 2019 in order to learn Rust (it's been fun, but challenging!). 

I am looking for help and feedback from more experiences Rustaceans on my solution to Day 6: Universal Orbit Map in Rust. 

Specifically I am looking to see where I am not doing it the idiomatic Rust way, where my Java background shines through or anything that doesn't look or feel right or Rust-ish.

use std::collections::HashMap;
use std::io;
use std::io::Read;

fn main() {
    let mut input = String::new();
    match io::stdin().read_to_string(&amp;mut input) {
        Ok(v) =&gt; v,
        Err(_) =&gt; panic!("Unable to read input"),
    };
    let mut orbits = HashMap::new();
    input
        .lines()
        .map(|l| l.split(")").collect::&lt;Vec&lt;&amp;str&gt;&gt;())
        .for_each(|o| {
            orbits.insert(o[1].to_string(), o[0].to_string());
        });
    let num_orbits = orbits
        .iter()
        .map(|k| path(k.0, &amp;orbits))
        .map(|p| p.len())
        .sum::&lt;usize&gt;();

    let mut you_path = path("YOU", &amp;orbits);
    let mut san_path = path("SAN", &amp;orbits);

    while you_path.get(you_path.len() - 1) == san_path.get(san_path.len() - 1) {
        you_path.pop();
        san_path.pop();
    }

    println!(
        "Number of orbits: {}, Number of jumps: {}",
        num_orbits,
        (you_path.len() + san_path.len())
    );
}

fn path(from: &amp;str, orbits: &amp;HashMap&lt;String, String&gt;) -&gt; Vec&lt;String&gt; {
    let mut p = Vec::new();
    let mut inner = from;
    loop {
        match orbits.get(inner) {
            Some(v) =&gt; {
                p.push(v.to_string());
                inner = v;
            }
            None =&gt; break,
        };
    }
    p
}
Disclaimer: I don't know Rust.

I only have comments on performance.

To compute the number of orbits, it's unnecessary to compute paths, you could compute just the length of paths. That would reduce the space complexity to constant.

When computing the number of orbits, instead of going from each planet until the root, you could go from the root, traversing paths to every planet exactly once. That would reduce the time complexity to linear.

When computing the common ancestor from SAN and YOU, you only need to track part of the path segments, until a common point.