1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pub trait FromWithContext<U, C> {
	fn from_with(value: U, context: &C) -> Self;
}

impl<T, C> FromWithContext<T, C> for T {
	fn from_with(value: Self, _context: &C) -> Self {
		value
	}
}

pub trait IntoWithContext<U, C> {
	fn into_with(self, context: &C) -> U;
}

impl<T, U: FromWithContext<T, C>, C> IntoWithContext<U, C> for T {
	fn into_with(self, context: &C) -> U {
		U::from_with(self, context)
	}
}