3 ms·
Not being a rust programmer myself, my comment should be taken as that: You commented in your code on some long functions needing to be decomposed, that might
by vectorEQ 8y ago
Not being a rust programmer myself, my comment should be taken as that:
You commented in your code on some long functions needing to be decomposed, that might be a good start, your own todo. :-)
Other than this as a c programmer i see some opportunity in the _find_best_matching_filter_index function to perhaps apply a macro to the repeating syntax of
let words = tst_utils::_words_vector_from_string("aaa bbb ccc ddd");
assert_eq!(log_filters._find_best_matching_filter_index(&words), 0);
Where in C i would create something so i could type MACRO_NAME("aaa bbb ccc ddd") for example to make that part read more easily and make it easier to add or remove items there.
I see macros are supported, but am because of my lack of rust knowledge unaware if my suggestion is possible at all.
https://doc.rust-lang.org/book/ch19-06-macros.html https://doc.rust-lang.org/book/ch19-06-macros.html might shed some light on that.
It's not really changing code but would make it much more readable. (macros are great for such things in C for sure if not overdone)
- gkuk 8y agoThanks! I definitely need to be more DRY in tests.
- vectorEQ 8y agoI always feel the same. usually only after i wrote something a million times i'll notice i could have made a macro and end up replacing it all again :D
- steveklabnik 8y agoYou'd write a function to do this in Rust, not a macro.