Loony division-sowing anti-FSF nu-dev mastoclowns vs. BlueSky!
A figure of speech I came across once comes to mind. It goes something like “may god put the fire out with a rainfall of gasoline”.
It is always a risky move going from the safe echo chamber to the real world though. It always brings a shock to the system.
Regarding Cargo.lock, the recommendation always was to include it in version control for application/binary crates, but not library ones. But tendencies changed over time to include it even for libraries. If a rust-toolchain file is tracked by version control, and is pinned to a specific stable release, then Cargo.lock should definitely be tracked too [1][2].
It’s strictly more information tracked, so there is no logical reason not to include it. There was this concern about people not being aware of –locked not being the default behaviour of cargo install, giving a false sense of security/reliability/reproducibility. But “false sense” is never a good technical argument in my book.
Anyway, your crate is an application/binary one. And if you were to not change the “*” dependency version requirement, then it is almost guaranteed that building your crate will break in the future without tracking Cargo.lock ;)
“*” dep version requirements.Cargo.lock to version control.Vec<u8> later anyway?Here is an originally random list (using cargo tree --prefix=depth) with some very loose logical grouping. Wide-scoped and well-known crates removed (some remaining are probably still known by most).
My quick notes which are tailored to beginners:
Use Option::ok_or_else() and Result::map_err() instead of let … else.
let … else didn’t always exist. And you might find that some old timers are slightly triggered by it.Options as iterators (yes Options are iterators).? operator and the Try traitType inference and generic params
let headers: HashMap = header_pairs .iter() .map(|line| line.split_once(":").unwrap()) .map(|(k, v)| (k.trim().to_string(), v.trim().to_string())) .collect();(Borken sanitization will probably butcher this code, good thing the problem will be gone in Lemmy 0.19)
Three tips here:
headers will be returned as a struct field, the type of which is already known.collect() itself. That may prove useful in other scenarios.Result/Option if the iterator items are Results/Options. So that .unwrap() is not an ergonomic necessity 😉Minor point
.into() or .to_owned() for &str => String conversions.
make good use of the crate echo system
http crate is the compatibility layer used HTTP rust implementations. Check it out and maybe incorporate it into your
experimental/educational code.Alright, I will stop myself here.
Performing HTML sanitization before writing text to the database turned out to be a failure. It causes lots of problems which cant be solved, such as double escapes when editing. So Im getting rid ...
Broken input sanitization probably.
Issue will thankfully no longer exist in the next lemmy release.