cs_utils/test/implements_debug.rs
1
2/// Test if an item implements `Debug` trait.
3///
4/// ### Examples
5///
6/// - Debug item:
7///
8/// ```
9/// // either "test" or "all" features must be enabled
10/// #[cfg(any(feature = "test", feature = "all"))]
11/// {
12/// use cs_utils::test::implements_debug;
13///
14/// #[derive(Debug)]
15/// struct TestStruct {}
16///
17/// // compiles fine
18/// implements_debug(TestStruct {});
19/// }
20/// ```
21///
22/// - Non-Debug item:
23///
24/// ```compile_fail
25/// // either "test" or "all" features must be enabled
26/// #[cfg(any(feature = "test", feature = "all"))]
27/// {
28/// use cs_utils::test::implements_debug;
29///
30/// // don't derive Debug
31/// struct TestStruct {}
32///
33/// // does not compile
34/// implements_debug(TestStruct {});
35/// }
36/// ```
37pub fn implements_debug<T: std::fmt::Debug>(item: T) -> T {
38 return item;
39}