Hello, I am new to Rust, I was hoping if anyone had the time they could look over my code and give feedback. Just things like poor practices, beginner mistakes, etc. Thank you in advance!
Hello, welcome to the Rust forums! I've never used Amazon CloudWatch, so I can't test there, but here are some things I noticed while reading your code:
- When logging, please do not require log messages to be
Strings. This adds extra overhead that isn't necessary because the messages will not be mutated after creation. Instead, use a
&'a str. You will need to add lifetimes to your
LogLevelenum, but it will make your library a lot more friendly.
- Less of a critique, but perhaps you could add a library feature that toggles on and off the color code formatting when logging. Codes like
\x1b[0mdo not work on certains platforms, like some Windows versions. (I'm pretty sure the old
cmd.exedoesn't support them, but I haven't tested it.)
- I'm noticing a frequent use of
<br><br>in your documentation. In general that shouldn't be necessary and makes reading the un-rendered code comments more difficult. You can test the documentation output with
lib.rs, you re-export items from the prelude. This is more of a style thing, but usually
lib.rsre-exports from the actual modules and the prelude re-exports from
lib.rs(or the modules directly). This isn't big though, so you don't need to change it.
- I recommend running your code through rustfmt and clippy to catch any other mistakes that I missed.
That's all that I've seen so far without extensively going over your code. Some of the things look quite professional, so good job! I hope that you've enjoyed using Rust.