Cargo show warning for function with `todo`

Hi it's me again,
i'm new to rust and cargo stuff, so let's say i have some functions that i haven't yet implemented but it's not important enough to stop the build or to cause any unexpected behavior, so is there is any way to make cargo warn me about these functions ?

1 Like

As far as I can tell, no. However there's a handy unimplemented! macro, which will panic if the function is called.

You can use it like this

fn frobnicate(input: String) -> Result<Foo, ErrBar> {
    unimplemented!()
}

the functions i'm talking about want lead to a "panic" it's just some extra features, something like i can print to the screen but i can't start a new line on '\n' so my code works but this function isn't implemented yet

You could add a variable binding that you never use. Maybe something like:

let todo = true; //TODO Finish implementing

Then you'll get a compile warning but no errors at runtime:

warning: unused variable: `todo`, #[warn(unused_variables)] on by default
  --> tests\s3.rs:64:13
   |
64 |         let todo = true; //TODO finish implementing
   |             ^^^^
4 Likes

thats a good idea, thank you