-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug_warn! macro #2902
Comments
can you show a code example how |
let my_struct = MyStruct::new("ABCDEFGHIJJKLMN");
// so e.g. the person, that the struct wrote thinks, that e.g. double characters in the String are not necessary but it would not be an error. pub fn new<T: AsRef<str>>(s: T) -> MyStruct {
if s.contains_duplicates() { // yes that fn does not exist but you'll understand
debug_warn!("String contains duplicate characters.");
}
} |
This is decided at run time; far after the compiler is involved. There may not even be a Rust compiler installed on the machine when the program is run. |
I could see this being useful for macros, similar to |
|
Wouldn't this be better solved by a custom lint rule? |
I had the idea of including a macro that issues compiler warnings to make it easier for library developers to tell the user what, for example, is not recommended.
assert! is more likely to issue errors, but adding such a warning might be useful.
The text was updated successfully, but these errors were encountered: