tinymist_std/concepts/
mod.rs

1mod takable;
2use std::{borrow::Cow, 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/// A copy-on-write static string.
27pub type CowStr = Cow<'static, str>;
28
29/// A trait for converting an `Arc<T>` into `Self`.
30pub trait FromArc<T> {
31    /// Converts an `Arc<T>` into `Self`.
32    fn from_arc(arc: Arc<T>) -> Self;
33}
34
35impl<S, T> FromArc<S> for T
36where
37    Arc<S>: Into<T>,
38{
39    fn from_arc(arc: Arc<S>) -> T {
40        arc.into()
41    }
42}
43
44/// A trait for converting `Arc<T>` into `Self`.
45pub trait ArcInto<T> {
46    /// Converts `Arc<T>` into `Self`.
47    fn arc_into(self: Arc<Self>) -> T;
48}
49
50impl<S, T> ArcInto<T> for S
51where
52    Arc<S>: Into<T>,
53{
54    fn arc_into(self: Arc<Self>) -> T {
55        self.into()
56    }
57}