sea_orm/
util.rs

1/// Uses the `log` crate to perform logging.
2/// This must be enabled using the feature flag `debug-print`.
3/// ### Usage
4/// ```
5/// use sea_orm::debug_print;
6///
7/// #[derive(Debug)]
8/// enum FooError {
9///     Bar,
10///     Baz,
11/// }
12///
13/// debug_print!("{:?}", FooError::Bar);
14/// ```
15#[macro_export]
16#[cfg(feature = "debug-print")]
17macro_rules! debug_print {
18    ($( $args:expr ),*) => { tracing::debug!( $( $args ),* ); }
19}
20
21#[macro_export]
22/// Non-debug version
23#[cfg(not(feature = "debug-print"))]
24macro_rules! debug_print {
25    ($( $args:expr ),*) => {
26        true;
27    };
28}
29
30#[cfg(all(test, feature = "sync"))]
31pub trait StreamShim<T> {
32    fn try_next(&mut self) -> Result<Option<T>, crate::DbErr>;
33}
34
35#[cfg(all(test, feature = "sync"))]
36impl<I, T> StreamShim<T> for I
37where
38    I: Iterator<Item = Result<T, crate::DbErr>>,
39{
40    fn try_next(&mut self) -> Result<Option<T>, crate::DbErr> {
41        self.next().transpose()
42    }
43}