let mut a_number = 10;
todo!
macroRust에서는 완성되지 않은 기능을 명시할 때 사용된다. 컴파일러는 컴파일 시 todo!
macro에서 아직 구현되지 않은 기능이 있다고 패닉을 발생시킨다.
예제코드
fn do_something_awesome(x: i16){
println!("This function will do something awesome, but not implemented yet!\nJust print {}", x);
todo!("Please implement me...")
}
fn main(){
let a_number = 8;
do_something_awesome(a_number);
}
컴파일 결과
PS C:\workspace\rust-tutorial\projects\test_todo_macro> cargo run
Compiling test_todo_macro v0.1.0 (C:\workspace\rust-tutorial\projects\test_todo_macro)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s
Running `target\debug\test_todo_macro.exe`
This function will do something awesome, but not implemented yet!
Just print 8
thread 'main' panicked at src/main.rs:3:5:
not yet implemented: Please implement me...
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\test_todo_macro.exe` (exit code: 101)