1
1
//! `tor-basic-utils`: Utilities (low-level) for Tor
2
//!
3
//! Miscellaneous utilities for `tor-*` and `arti-*`.
4
//!
5
//! This crate lives at the *bottom* of the Tor crate stack.
6
//! So it contains only utilities which have no `tor-*` (or `arti-*`) dependencies.
7
//!
8
//! There is no particular theme.
9
//! More substantial sets of functionality with particular themes
10
//! are to be found in other `tor-*` crates.
11

            
12
#![deny(missing_docs)]
13
#![warn(noop_method_call)]
14
#![deny(unreachable_pub)]
15
#![warn(clippy::all)]
16
#![deny(clippy::await_holding_lock)]
17
#![deny(clippy::cargo_common_metadata)]
18
#![deny(clippy::cast_lossless)]
19
#![deny(clippy::checked_conversions)]
20
#![warn(clippy::cognitive_complexity)]
21
#![deny(clippy::debug_assert_with_mut_call)]
22
#![deny(clippy::exhaustive_enums)]
23
#![deny(clippy::exhaustive_structs)]
24
#![deny(clippy::expl_impl_clone_on_copy)]
25
#![deny(clippy::fallible_impl_from)]
26
#![deny(clippy::implicit_clone)]
27
#![deny(clippy::large_stack_arrays)]
28
#![warn(clippy::manual_ok_or)]
29
#![deny(clippy::missing_docs_in_private_items)]
30
#![deny(clippy::missing_panics_doc)]
31
#![warn(clippy::needless_borrow)]
32
#![warn(clippy::needless_pass_by_value)]
33
#![warn(clippy::option_option)]
34
#![warn(clippy::rc_buffer)]
35
#![deny(clippy::ref_option_ref)]
36
#![warn(clippy::semicolon_if_nothing_returned)]
37
#![warn(clippy::trait_duplication_in_bounds)]
38
#![deny(clippy::unnecessary_wraps)]
39
#![warn(clippy::unseparated_literal_suffix)]
40
#![deny(clippy::unwrap_used)]
41

            
42
use std::fmt;
43

            
44
#[cfg(feature = "humantime-serde")]
45
pub mod humantime_serde_option;
46

            
47
// ----------------------------------------------------------------------
48

            
49
/// Function with the signature of `Debug::fmt` that just prints `".."`
50
///
51
/// ```
52
/// use educe::Educe;
53
/// use tor_basic_utils::skip_fmt;
54
///
55
/// #[derive(Educe, Default)]
56
/// #[educe(Debug)]
57
/// struct Wombat {
58
///     visible: usize,
59
///
60
///     #[educe(Debug(method = "skip_fmt"))]
61
///     invisible: [u8; 2],
62
/// }
63
///
64
/// assert_eq!( format!("{:?}", &Wombat::default()),
65
///             "Wombat { visible: 0, invisible: .. }" );
66
/// ```
67
176
pub fn skip_fmt<T>(_: &T, f: &mut fmt::Formatter) -> fmt::Result {
68
176
    /// Inner function avoids code bloat due to generics
69
176
    fn inner(f: &mut fmt::Formatter) -> fmt::Result {
70
176
        write!(f, "..")
71
176
    }
72
176
    inner(f)
73
176
}
74

            
75
// ----------------------------------------------------------------------