Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create stub functions?

Tags:

rust

What's the best way to create a stub function in Rust? Something like:

fn my_method() -> bool {
  return new UnImplementedException() //wrong! But that's close to what I need
}

In C# the methods can return UnImplementedException which is convenient for creating stubs. Of course, in this particular case I could return true or false, but I want the solution that is applicable for any return type.

like image 808
Incerteza Avatar asked Jan 20 '15 04:01

Incerteza


1 Answers

You want the unimplemented! macro (doc link).

fn my_method() -> bool {
    unimplemented!()
}
like image 139
wingedsubmariner Avatar answered Sep 29 '22 17:09

wingedsubmariner