Skip to main content

libsugar/
chain_todo.rs

1//! Chain Todo
2
3use core::fmt::Display;
4
5/// Chain call version of `todo!()`
6pub trait Todo {
7    #[inline]
8    /// Chain call version of `todo!()`
9    fn todo(&self) -> ! {
10        todo!()
11    }
12}
13impl<T> Todo for T {}
14
15/// Chain call version of `todo!(msg)`
16pub trait TodoMsg {
17    #[inline]
18    /// Chain call version of `todo!(msg)`
19    fn todo_msg<T: Display>(&self, msg: T) -> ! {
20        todo!("{}", msg)
21    }
22}
23impl<T> TodoMsg for T {}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28
29    #[test]
30    #[should_panic]
31    fn test_todo() {
32        1.todo();
33    }
34
35    #[test]
36    #[should_panic]
37    fn test_todo_msg() {
38        1.todo_msg("asd");
39    }
40}