agner_sup/common/gen_child_spec/
args_clone.rs

1use std::fmt;
2
3use crate::common::gen_child_spec::traits::CreateArgs;
4
5pub fn args_clone<T>(value: T) -> ArgsClone<T>
6where
7    ArgsClone<T>: CreateArgs<Input = (), Output = T>,
8{
9    ArgsClone(value)
10}
11
12#[derive(Clone)]
13pub struct ArgsClone<T>(T);
14
15impl<T> CreateArgs for ArgsClone<T>
16where
17    T: Clone,
18{
19    type Input = ();
20    type Output = T;
21
22    fn create_args(&mut self, (): Self::Input) -> Self::Output {
23        self.0.clone()
24    }
25}
26
27impl<T> fmt::Debug for ArgsClone<T> {
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        f.debug_struct("ArgsClone").field("type", &std::any::type_name::<T>()).finish()
30    }
31}