Closed nyurik closed 1 week ago
the smaller the scope of the variable, the shorter should be its name. ok
thx for looking at it! Let me clarify how these levels work, to prevent accidental misuse:
warnings
do not fail compilation - which means it is possible to develop and test things until the PR is ready. This is very important when doing the development because you do not want to be adding comments right away - you don't know at that time if what you are doing is even right or not - so the quicker you can test, the more you can focus on development, the better the result will be.RUSTFLAGS='-D warnings'
- so you won't be able to merge PRs until CI is happy with it.This achieves what you want -- clean code with comments, while it helps keep developing much faster.
forbid
means there can never be any exceptions, no matter how reasonable. deny
means it will fail compilation, but in the code it is ok to explicitly allow it when it makes sense. The errors are a good example of that - by design, they already include description as part of the #[error(...)]
attribute./// comment
is actually also an attribute -- #[doc("comment")]
-- so error
just a slightly different syntax for the error cases -- if you look at clap crate, you will see that it uses the same approach, only it uses the doc
attribute, i.e. the ///
Ok good for me, thanks!
thiserror
to handle all the error reporting, including theis_fatal()
stuffP.S. a good rule of thumb I found useful for naming variables: the smaller the scope of the variable, the shorter should be its name.