I am a bit late on the blog post on this one, but I attempted Advent of Code once again this year. I got 29 Stars, which doesn’t match my best year. However this is the first year I have attempted this in any language other than Python. This year I used rust, this is the first time I have written any rust, and the source probably shows this but I learnt a lot. I think a lot of AoC tasks map much easier to dynamic languages than rust, and i defiantly found myself fighting the compiler and language more than previous years, but that may have been as much my inexperience with rust as the language itself.

One very handy library I did find was a peg parser that made consuming the text based input files much easier.

peg::parser! {
    grammar list_parser() for str {
        rule number() -> V
        = n:$(['0'..='9']+) {? V::new_value(n.parse().or(Err("u32"))) }

        pub rule list() -> V
        = "[" l:((number()/list()) ** ",") "]" {? V::new_list(Ok(l)) }
    }
}

As expected lifetimes and borrowing took some time to get used to, but after a while borrowing and cloning became second nature (though I am sure I have done some very un-optimal things with memory).

One area I did find very hard was containers such as RC and RefCell. Which I felt the examples and documentation for were not very helpful, and the API somewhat clunky to use.