x_bow/impls/stdlib/
string.rs1use std::ops::Deref;
2
3use crate::{impls::transparent::TransparentDerefMapper, path::Path, trackable::Trackable};
4
5impl Trackable for String {
6 type PathBuilder<P: Path<Out = Self>> = StringPathBuilder<P>;
7
8 fn new_path_builder<P: Path<Out = Self>>(parent: P) -> Self::PathBuilder<P> {
9 StringPathBuilder { inner_path: parent }
10 }
11}
12
13#[derive(Clone, Copy, x_bow_macros::IntoPath)]
14#[into_path(prefix = crate::trackable)]
15pub struct StringPathBuilder<P: Path<Out = String>> {
16 inner_path: P,
17}
18
19impl<P: Path<Out = String>> Deref for StringPathBuilder<P> {
20 type Target = P;
21
22 fn deref(&self) -> &Self::Target {
23 &self.inner_path
24 }
25}
26
27impl<P: Path<Out = String>> StringPathBuilder<P> {
28 pub fn content(self) -> <str as Trackable>::PathBuilder<TransparentDerefMapper<String, P>> {
29 str::new_path_builder(TransparentDerefMapper::new(self.inner_path))
30 }
31}