or will I just be a usafe { }
rust noob forever?
BORROWCHECKING: ON. COPILOT: OFF.
Opening files? Whose got time for that? I'll just be feeding on stdin
cat datx.txt | cargo run
day 1:
- read the first bit of the rust book but no borrow checking or anything
loop
is an interesting keyword- const by default is nice I guess
&
as a reference -> "don't copy me"vec!
is a macro that creates a vector- there's
Result
and there'sOption
for return typesResult
is for when you want to return an error (Ok or Err)Option
is for when you want to returnNone
(None or Some), reminds me of Maybe in Haskell or the Optional type in Python- you can
.unwrap()
aResult
orOption
to get the value out, but it will panic if it'sErr
orNone
- You can do
parse::<TYPE>
to parse into a type.parse::<i32>()
will parse into an integer. I think this is like a template function in C++.
so far, so good.