mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 02:08:17 +00:00
parent
0c64bea89e
commit
d3e7027d67
1 changed files with 30 additions and 0 deletions
|
@ -23,3 +23,33 @@ pub type ImmutStr = Arc<str>;
|
|||
pub type ImmutBytes = Arc<[u8]>;
|
||||
/// An immutable path.
|
||||
pub type ImmutPath = Arc<Path>;
|
||||
|
||||
/// A trait for converting an `Arc<T>` into `Self`.
|
||||
pub trait FromArc<T> {
|
||||
/// Converts an `Arc<T>` into `Self`.
|
||||
fn from_arc(arc: Arc<T>) -> Self;
|
||||
}
|
||||
|
||||
impl<S, T> FromArc<S> for T
|
||||
where
|
||||
Arc<S>: Into<T>,
|
||||
{
|
||||
fn from_arc(arc: Arc<S>) -> T {
|
||||
arc.into()
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait for converting `Arc<T>` into `Self`.
|
||||
pub trait ArcInto<T> {
|
||||
/// Converts `Arc<T>` into `Self`.
|
||||
fn arc_into(self: Arc<Self>) -> T;
|
||||
}
|
||||
|
||||
impl<S, T> ArcInto<T> for S
|
||||
where
|
||||
Arc<S>: Into<T>,
|
||||
{
|
||||
fn arc_into(self: Arc<Self>) -> T {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue