contextual 0.1.6

Utility crate to deal with data in context
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::Contextual;

pub trait IntoRefWithContext<'a, U: ?Sized, C: ?Sized> {
	fn into_ref_with(self, context: &'a C) -> &'a U;
}

impl<'a, T: IntoRefWithContext<'a, str, C>, C: ?Sized> Contextual<T, &'a C> {
	pub fn into_str(self) -> &'a str {
		self.0.into_ref_with(self.1)
	}
}

impl<'a, T: IntoRefWithContext<'a, str, C>, C: ?Sized> Contextual<T, &'a mut C> {
	pub fn into_str(self) -> &'a str {
		self.0.into_ref_with(self.1)
	}
}