4 ms·
Yes, I wanted to try Rust for this year's Advent of Code and I gave up before I figured out how to read the input file.
by st1x7 6y ago
Yes, I wanted to try Rust for this year's Advent of Code and I gave up before I figured out how to read the input file.
- steveklabnik 6y agoIf you give it a try again, https://doc.rust-lang.org/std/fs/fn.read_to_string.html https://doc.rust-lang.org/std/fs/fn.read_to_string.html is probably whet you want.
- methyl 6y agoI wonder if this type signature may be too intimidating for newcomers: Result<(), Box<dyn std::error::Error + 'static>> It's probably huge effort to somehow target examples both for newbies and advanced users. I don't know what's good solution and if it's a real problem at all.
- jkelleyrtp 6y agoRust is a language that you need to sit down and read the book. It's not for casual exploration in the same way that JS/Py are. People in the Rust ecosystem will tell you to either unwrap the error or use https://docs.rs/anyhow/1.0.34/anyhow/ https://docs.rs/anyhow/1.0.34/anyhow/ to completely ignore it. Great thing - it's simple to ctrl-f and turn your one-off code into production code with powerful errorhandling.
- deleted 6y ago[deleted]
- brundolf 6y agoIt's a language where it's worthwhile to sit down and read the book, but it aspires to be fairly accessible too via zero-cost abstractions and integrated tooling. I think it's been moderately successful in this goal all things considered, but there's always more progress to be made.
- steveklabnik 6y agoYes, normally I would hide that. Not sure why it wasn't here. I'll make a ticket :) Thanks!