tinymist_std/concepts/
mod.rs

1mod takable;
2use std::{path::Path, sync::Arc};
3
4pub use takable::*;
5
6pub mod cow_mut;
7
8mod query;
9pub use query::*;
10
11mod read;
12pub use read::*;
13
14mod marker;
15pub use marker::*;
16
17#[cfg(feature = "typst")]
18pub mod typst;
19
20/// An immutable string.
21pub type ImmutStr = Arc<str>;
22/// An immutable byte slice.
23pub type ImmutBytes = Arc<[u8]>;
24/// An immutable path.
25pub type ImmutPath = Arc<Path>;
26
27/// A trait for converting an `Arc<T>` into `Self`.
28pub trait FromArc<T> {
29    /// Converts an `Arc<T>` into `Self`.
30    fn from_arc(arc: Arc<T>) -> Self;
31}
32
33impl<S, T> FromArc<S> for T
34where
35    Arc<S>: Into<T>,
36{
37    fn from_arc(arc: Arc<S>) -> T {
38        arc.into()
39    }
40}
41
42/// A trait for converting `Arc<T>` into `Self`.
43pub trait ArcInto<T> {
44    /// Converts `Arc<T>` into `Self`.
45    fn arc_into(self: Arc<Self>) -> T;
46}
47
48impl<S, T> ArcInto<T> for S
49where
50    Arc<S>: Into<T>,
51{
52    fn arc_into(self: Arc<Self>) -> T {
53        self.into()
54    }
55}