hexga_core/convert.rs
1pub trait TryAsRef<T>
2{
3 type Error;
4 fn try_as_ref(&self) -> Result<&T, Self::Error>;
5}
6impl<T, S> TryAsRef<T> for S
7where
8 S: AsRef<T>,
9{
10 type Error = crate::Never;
11 fn try_as_ref(&self) -> Result<&T, Self::Error> { Ok(self.as_ref()) }
12}
13
14// Todo: add TryAsMut
15
16re_export_items_from_std_or_core!(convert);
17
18pub mod prelude
19{
20 #[allow(unused)]
21 pub use super::traits::*;
22 pub use super::{AsMut, AsRef, TryAsRef};
23}
24pub mod traits
25{}
26/*
27pub trait TryAsMut<T>
28{
29 type Error: Debug;
30 fn try_as_mut(&mut self) -> Result<&mut T,Self::Error>;
31}
32impl<T,S> TryAsMut<T> for S where S: AsMut<T>
33{
34 type Error=Never;
35 fn try_as_mut(&mut self) -> Result<&mut T,Self::Error> { Ok(self.as_mut()) }
36}
37*/