That means, in order to call it, you must use std::io::Write. Alternatively, you could do what the example does and require the std::io prelude, use std::io::prelude::*;, which would bring Write and several other useful traits into scope.
I've included all the use lines without success. My problem seems to be that OpenOptions::new().write(true).create_new(true).open(path); returns a type
that has the file handle and the error included. And I was - sorry for this - too sedentary to figure this out.
If you had by chance a link or a minimum example of an asignment with the right side being std::result::Result<std::fs::File, std::io::Error>?
But I clearly need to learn myself the syntax at first, reading the books.
Though, I must say, the syntax is weird as can be. It's surely just coincidence, but nothing of "what my eyes read" reflects what it probably should do (in particular the order of words) when putting a string into a file, plus some lambda looking thing, and the as_bytes (but that's ok).
The "true" arguments are nameless things which without Intellisense are .. well anonymous things to look up in the docs, for now.
I know it would be a awkward syntax would be a phenomenon in Rust, but I can't tell what it does. I'm not afraid (anymore) to say I might be too dumb for this language. All I actually would like (if I had 3 free wishes) is the ownership features, not much beside that. Can't help it, it's... a very special syntax. I might be fighting with the compiler for months or years before I make progress.
The fields are named by the method. It's called the "builder pattern". When you see .write(true) in the builder chain, that's equivalent to (..., write=true, ...) in a language with keyword arguments. Nothing quite as bad as create_thingy(true, true, false, 0, false, NULL, 0ULL) in some interfaces I've seen (*cough* WinAPI *cough*).
Well, yeah, there are a few ways to skin this cat (and more still) . If you're just learning Rust (in fact, I'm pretty new to it myself), I'd stick to the more "clear cut" approaches, which is just adding "unwrap" to your original code as mentioned (+ making the file mut and using the prelude) - it looks fairly benign then.
The lambda/closure "functional" approach can make the code more concise in some cases (and also can avoid some lexical borrow issues), but yes, it can be terse when you're not familiar with the APIs (and Rust itself). I'd stick with it, Rust is known for its learning curve (the steepness of which, depending on your background, will vary).