nakago_figment/from_ref.rs
1// Taken from: https://github.com/tokio-rs/axum/blob/main/axum-core/src/extract/from_ref.rs
2
3/// Used to do reference-to-value conversions thus not consuming the input value.
4///
5/// This trait can be derived using `#[derive(FromRef)]`.
6pub trait FromRef<T> {
7 /// Converts to this type from a reference to the input type.
8 fn from_ref(input: &T) -> Self;
9}
10
11impl<T> FromRef<T> for T
12where
13 T: Clone,
14{
15 fn from_ref(input: &T) -> Self {
16 input.clone()
17 }
18}