structural/path.rs
1/*!
2Types used to refer to the field(s) that one is accessing.
3
4The re-exported items are all field-path related.
5*/
6
7#![allow(non_snake_case, non_camel_case_types)]
8
9use crate::type_level::collection_traits::{
10 Append, AppendOut, PushBack, PushBackOut, ToTList, ToTListOut, ToTString,
11};
12
13pub use crate::{field_path_aliases, fp, FP};
14
15use core_extensions::ConstDefault;
16
17use std_::{
18 fmt::{self, Debug},
19 marker::PhantomData,
20 mem::ManuallyDrop,
21};
22
23////////////////////////////////////////////////////////////////////////////////
24
25#[cfg(test)]
26mod tests;
27
28pub mod array_paths;
29
30mod to_usize;
31
32include! { "./path/path_components.rs" }
33
34pub use crate::{
35 FieldPathSet, NestedFieldPath, NestedFieldPathSet, TStr, VariantField, VariantName,
36};
37
38////////////////////////////////////////////////////////////////////////////////
39
40/// Aliases for field paths.
41pub mod aliases {
42 field_path_aliases! {
43 index_0=0,
44 index_1=1,
45 index_2=2,
46 index_3=3,
47 index_4=4,
48 index_5=5,
49 index_6=6,
50 index_7=7,
51 index_8=8,
52 }
53}
54
55/// Aliases for TStr.
56pub mod string_aliases {
57 tstr_aliases! {
58 str_0=0,
59 str_1=1,
60 str_2=2,
61 str_3=3,
62 str_4=4,
63 str_5=5,
64 str_6=6,
65 str_7=7,
66 str_8=8,
67 str_9=9,
68 str_underscore="_",
69 }
70}
71
72////////////////////////////////////////////////////////////////////////////////
73
74mod sealed {
75 pub trait Sealed {}
76}
77use self::sealed::Sealed;
78
79impl<T> Sealed for TStr<T> {}
80
81/// A marker trait for field paths that only refers to one field.
82///
83/// # Expectations
84///
85/// This type is expected to implement `RevGetFieldImpl`,`RevGetFieldMutImpl`, `RevIntoFieldImpl`.
86pub trait IsSingleFieldPath: Sized {}
87
88/// A marker trait for field paths of non-nested field(s).
89///
90/// # Safety
91///
92/// If this type implements any of the
93/// `RevGetFieldImpl`/`RevGetFieldMutImpl`/`RevIntoFieldImpl` traits,
94/// it must delegate those impls to non-nested
95/// `Get*Field`/`Get*FieldMut`/`Into*Field` impls
96/// of the `this` parameter (the `This` type parameter in the `Rev*` traits).
97pub unsafe trait ShallowFieldPath: Sized {}
98
99/// A marker trait for field paths that refer to multiple fields
100///
101/// # Expectations
102///
103/// This type is expected to implement `RevGetMultiField`.
104pub trait IsMultiFieldPath: Sized {
105 /// Whether the paths in the set can contain duplicate paths.
106 ///
107 /// This is expected to be either:
108 ///
109 /// - `structural::path::AliasedPaths`:
110 /// for a field path that might refer to the same field multiple times.
111 ///
112 /// - `structural::path::UniquePaths`:
113 /// for a field path that doesn't refer to a field more than once.
114 ///
115 type PathUniqueness;
116}
117
118////////////////////////////////////////////////////////////////////////////////
119
120impl<T> IsSingleFieldPath for NestedFieldPath<T> {}
121
122unsafe impl<F0> ShallowFieldPath for NestedFieldPath<(F0,)> where F0: ShallowFieldPath {}
123
124impl<T> IsMultiFieldPath for NestedFieldPath<T> {
125 type PathUniqueness = UniquePaths;
126}
127
128impl<T> Debug for NestedFieldPath<T> {
129 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
130 f.debug_struct("NestedFieldPath").finish()
131 }
132}
133
134impl<T> NestedFieldPath<T>
135where
136 T: ConstDefault,
137{
138 /// Constructs a `NestedFieldPath<T>`
139 pub const NEW: Self = Self::DEFAULT;
140}
141
142// Defined for the `fp` macro
143impl<T> NestedFieldPath<T>
144where
145 Self: ConstDefault,
146{
147 #[doc(hidden)]
148 pub const NEW_ALIASED: Self = Self::DEFAULT;
149
150 #[doc(hidden)]
151 pub const unsafe fn set_uniqueness(self) -> Self {
152 self
153 }
154}
155
156impl<T> NestedFieldPath<(T,)> {
157 /// Construcst a `NestedFieldPath` from a single path component.
158 #[inline(always)]
159 pub const fn one(value: T) -> Self {
160 Self { list: (value,) }
161 }
162}
163
164impl<T> NestedFieldPath<T> {
165 /// Constructs a `NestedFieldPath` for a nested field.
166 ///
167 /// Example:
168 /// `NestedFieldPath::many(( ts!(a), ts!(b) ))`
169 /// is equivalent to `fp!(a.b)`
170 ///
171 /// Example:
172 /// `NestedFieldPath::many(( VariantField::new(ts!(A), ts!(b)), ts!(c) ))`
173 /// is equivalent to `fp!(::A.b.c)`
174 #[inline(always)]
175 pub const fn many(list: T) -> Self {
176 Self { list }
177 }
178}
179
180impl<T> ConstDefault for NestedFieldPath<T>
181where
182 T: ConstDefault,
183{
184 const DEFAULT: Self = NestedFieldPath {
185 list: ConstDefault::DEFAULT,
186 };
187}
188
189impl<S> ToTString for NestedFieldPath<(TStr<S>,)> {
190 type Output = TStr<S>;
191}
192
193impl<T> ToTList for NestedFieldPath<T>
194where
195 T: ToTList,
196{
197 type Output = ToTListOut<T>;
198}
199
200impl<T, S> PushBack<S> for NestedFieldPath<T>
201where
202 T: PushBack<S>,
203{
204 type Output = NestedFieldPath<PushBackOut<T, S>>;
205}
206
207impl<T, U> Append<NestedFieldPath<U>> for NestedFieldPath<T>
208where
209 T: Append<U>,
210{
211 type Output = NestedFieldPath<AppendOut<T, U>>;
212}
213
214impl<T> NestedFieldPath<T> {
215 /// Constructs a new NestedFieldPath with `_other` appended at the end.
216 ///
217 /// Example arguments:`fp!(a)`/`fp!(::Foo.bar)`/`fp!(::Foo)`
218 #[inline(always)]
219 pub fn push<U, V>(self, _other: U) -> NestedFieldPath<V>
220 where
221 Self: PushBack<U, Output = NestedFieldPath<V>>,
222 NestedFieldPath<V>: ConstDefault,
223 {
224 ConstDefault::DEFAULT
225 }
226
227 /// Constructs a new NestedFieldPath with `_other` appended at the end.
228 ///
229 /// Example arguments:`fp!(a,b)`/`fp!(::Foo.bar.baz)`
230 #[inline(always)]
231 pub fn append<U>(self, _other: NestedFieldPath<U>) -> NestedFieldPath<AppendOut<T, U>>
232 where
233 T: Append<U>,
234 NestedFieldPath<AppendOut<T, U>>: ConstDefault,
235 {
236 ConstDefault::DEFAULT
237 }
238
239 /// Converts this `NestedFieldPath` to a `FieldPathSet`.
240 ///
241 /// # Example
242 ///
243 /// ```rust
244 /// use structural::{StructuralExt, fp};
245 ///
246 /// let tup=(3,(5,8),(13,21));
247 ///
248 /// assert_eq!( tup.fields(fp!(2.0).into_set()), (&13,) );
249 ///
250 /// ```
251 #[inline(always)]
252 pub const fn into_set(self) -> FieldPathSet<(Self,), UniquePaths> {
253 FieldPathSet::one(self)
254 }
255}
256
257impl<C> NestedFieldPath<(C,)> {
258 /// Unwraps this non-nested field path into `C`.
259 ///
260 /// This can also be done with `path.list.0`.
261 pub fn into_component(self) -> C {
262 self.list.0
263 }
264}
265
266impl_cmp_traits! {
267 impl[T] NestedFieldPath<T>
268 where[]
269}
270
271////////////////////////////////////////////////////////////////////////////////
272
273/// A merker type indicating that a ([`Nested`])[`FieldPathSet`] contains unique field paths,
274/// in which no path is a prefix of any other path in the set,
275/// this is required to call `StructuralExt::fields_mut` or `StructuralExt::into_fields`.
276///
277/// [`FieldPathSet`]: ../struct.FieldPathSet.html
278/// [`Nested`]: ../struct.NestedFieldPathSet.html
279#[derive(Debug, Copy, Clone)]
280pub struct UniquePaths;
281
282/// A merker type indicating that a ([`Nested`])[`FieldPathSet`]
283/// might not contain unique field paths.
284/// It's not possible to pass a `FieldPathSet<_,AliasedPaths>` to
285/// `StructuralExt::fields_mut` or `StructuralExt::into_fields`.
286///
287/// [`FieldPathSet`]: ../struct.FieldPathSet.html
288/// [`Nested`]: ../struct.NestedFieldPathSet.html
289#[derive(Debug, Copy, Clone)]
290pub struct AliasedPaths;
291
292impl<T, U> IsSingleFieldPath for FieldPathSet<(T,), U> {}
293
294impl<T, U> IsMultiFieldPath for FieldPathSet<T, U> {
295 type PathUniqueness = U;
296}
297
298// `ConstDefault` is not implemented for `FieldPathSet<T.UniquePaths>`
299// because `FieldPathSet<T.UniquePaths>` ought only be constructible
300// by satisfying the safety requirements of `FieldPathSet::<T.UniquePaths>::new`,
301// which aren't cheaply enforceable on the type level.
302//
303// impl<T> !ConstDefault for FieldPathSet<T.UniquePaths>{}
304
305impl<T> ConstDefault for FieldPathSet<T, AliasedPaths>
306where
307 T: ConstDefault,
308{
309 const DEFAULT: Self = FieldPathSet {
310 paths: ManuallyDrop::new(ConstDefault::DEFAULT),
311 uniqueness: PhantomData,
312 };
313}
314
315impl<T> Default for FieldPathSet<T, AliasedPaths>
316where
317 T: Default,
318{
319 #[inline(always)]
320 fn default() -> Self {
321 Self::many(T::default())
322 }
323}
324
325impl<T> FieldPathSet<(T,), UniquePaths> {
326 /// Constructs a FieldPathSet from a single field path.
327 pub const fn one(val: T) -> Self {
328 FieldPathSet {
329 paths: ManuallyDrop::new((val,)),
330 uniqueness: PhantomData,
331 }
332 }
333}
334
335impl<T> FieldPathSet<T, AliasedPaths> {
336 /// Constructs a FieldPathSet from a tuple of up to 8 field paths.
337 ///
338 /// Note that this doesn't enforce that its input is in fact a tuple of
339 /// up to 8 field paths (because `const fn` can't have bounds yet).
340 ///
341 /// To be able to access multiple fields mutably/by value at the same time,
342 /// you must call the unsafe `.upgrade()` method.
343 ///
344 /// To access more than 8 fields, you must use the [large constructor](#method.large).
345 pub const fn many(paths: T) -> Self {
346 FieldPathSet {
347 paths: ManuallyDrop::new(paths),
348 uniqueness: PhantomData,
349 }
350 }
351}
352
353impl<T> FieldPathSet<LargePathSet<T>, AliasedPaths> {
354 /// Constructs a FieldPathSet from a tuple of tuples of field paths,
355 /// for accessing up to 64 fields.
356 ///
357 /// Note that this doesn't enforce that its input is in fact a
358 /// tuple of tuples of field paths (because `const fn` can't have bounds yet).
359 ///
360 /// To be able to access multiple fields mutably/by value at the same time,
361 /// you must call the unsafe `.upgrade()` method.
362 ///
363 /// # Example
364 ///
365 /// This example demonstrates calling this function with 8 and 9 field paths,
366 /// as well as the return value of `StructuralExt` methods for both path sets.
367 ///
368 /// Accessing over 8 fields returns a tuple of tuples (8 fields each).
369 ///
370 /// You can also destructure the tuple returned by accessor methods by using
371 /// the [`field_pat`] macro, usable from 0 to 64 fields.
372 ///
373 /// ```rust
374 /// use structural::{ FieldPathSet, StructuralExt, path_tuple, ts };
375 ///
376 /// let array = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
377 ///
378 /// {
379 /// let path8 = FieldPathSet::large(path_tuple!(
380 /// ts!(0), ts!(1), ts!(2), ts!(3), ts!(4), ts!(5), ts!(6), ts!(7),
381 /// ));
382 ///
383 /// assert_eq!(
384 /// array.cloned_fields(path8),
385 /// (10, 11, 12, 13, 14, 15, 16, 17),
386 /// );
387 /// }
388 /// {
389 /// let path9 = FieldPathSet::large(path_tuple!(
390 /// ts!(0), ts!(1), ts!(2), ts!(3), ts!(4), ts!(5), ts!(6), ts!(7),
391 /// ts!(8),
392 /// ));
393 ///
394 /// assert_eq!(
395 /// array.cloned_fields(path9),
396 /// (
397 /// (10, 11, 12, 13, 14, 15, 16, 17),
398 /// (18,),
399 /// ),
400 /// );
401 /// }
402 ///
403 /// ```
404 ///
405 /// [`field_pat`]: ./macro.field_pat.html
406 pub const fn large(paths: T) -> Self {
407 FieldPathSet {
408 paths: ManuallyDrop::new(LargePathSet(paths)),
409 uniqueness: PhantomData,
410 }
411 }
412}
413
414impl<T> FieldPathSet<T, AliasedPaths>
415where
416 T: ConstDefault,
417{
418 /// Constructs a `FieldPathSet`.
419 ///
420 /// This can also be used to construct a `FieldPathSet<T, UniquePaths>`
421 /// in a context where `T` can be inferred,
422 /// by doing `unsafe{ FieldPathSet::NEW.upgrade_unchecked() }`
423 /// (read the docs for `upgrade_unchecked` first).
424 pub const NEW: Self = Self::DEFAULT;
425}
426
427impl<T, U> FieldPathSet<T, U>
428where
429 T: ConstDefault,
430{
431 /// This can be used to construct a `FieldPathSet<T, UniquePaths>`
432 /// from a type alias,
433 /// by doing `unsafe{ FOO::NEW_ALIASED.upgrade_unchecked() }`
434 /// (read the docs for `upgrade_unchecked` first).
435 pub const NEW_ALIASED: FieldPathSet<T, AliasedPaths> = FieldPathSet::NEW;
436}
437
438impl<T> FieldPathSet<T, UniquePaths> {
439 /// Converts a `FieldPathSet<T,UniquePaths>` to a `FieldPathSet<T,AliasedPaths>`
440 #[inline(always)]
441 pub const fn downgrade(self) -> FieldPathSet<T, AliasedPaths> {
442 FieldPathSet {
443 paths: self.paths,
444 uniqueness: PhantomData,
445 }
446 }
447}
448
449impl<T> FieldPathSet<T, AliasedPaths> {
450 /// Converts a `FieldPathSet<T,AliasedPaths>` to a `FieldPathSet<T,UniquePaths>`
451 ///
452 /// # Safety
453 ///
454 /// You must ensure that all the field paths in the `T` type parameter are unique,
455 /// there must be no field path that is a prefix of any other field path.
456 #[inline(always)]
457 pub const unsafe fn upgrade_unchecked(self) -> FieldPathSet<T, UniquePaths> {
458 self.set_uniqueness()
459 }
460
461 /// Converts a `FieldPathSet<T,AliasedPaths>` to a `FieldPathSet<T,U>`
462 ///
463 /// # Safety
464 ///
465 /// You must ensure that if `U==UniquePaths`,
466 /// then all the field paths in the `T` type parameter are unique,
467 /// there must be no field path that is a prefix of any other field path.
468 #[inline(always)]
469 pub const unsafe fn set_uniqueness<U>(self) -> FieldPathSet<T, U> {
470 FieldPathSet {
471 paths: self.paths,
472 uniqueness: PhantomData,
473 }
474 }
475}
476impl<T, U> FieldPathSet<T, U> {
477 /// Gets the tuple of field paths out of this FieldPathSet.
478 #[inline(always)]
479 pub const fn into_paths(self) -> T {
480 ManuallyDrop::into_inner(self.paths)
481 }
482}
483
484impl<T, U> FieldPathSet<(T,), U> {
485 /// Converts a `FieldPathSet` containing a single field path into that field path.
486 #[inline(always)]
487 pub fn into_path(self) -> T {
488 ManuallyDrop::into_inner(self.paths).0
489 }
490}
491
492impl<T, U> FieldPathSet<T, U> {
493 /// Constructs a new FieldPathSet with `_other` appended at the end.
494 ///
495 /// Example arguments`fp!(a)`/`fp!(a.b.c)`/`fp!(::foo)`/`fp!(::bar.baz.bam)`
496 #[inline(always)]
497 pub fn push<O, Out>(self, _other: O) -> FieldPathSet<Out, AliasedPaths>
498 where
499 Self: PushBack<O, Output = FieldPathSet<Out, AliasedPaths>>,
500 FieldPathSet<Out, AliasedPaths>: ConstDefault,
501 {
502 ConstDefault::DEFAULT
503 }
504
505 /// Constructs a new FieldPathSet with the `_other` FieldPathSet
506 /// appended at the end.
507 #[inline(always)]
508 pub fn append<T2, U2>(
509 self,
510 _other: FieldPathSet<T2, U2>,
511 ) -> FieldPathSet<AppendOut<T, T2>, AliasedPaths>
512 where
513 T: Append<T2>,
514 FieldPathSet<AppendOut<T, T2>, AliasedPaths>: ConstDefault,
515 {
516 ConstDefault::DEFAULT
517 }
518}
519
520impl<T, U> ToTList for FieldPathSet<T, U>
521where
522 T: ToTList,
523{
524 type Output = ToTListOut<T>;
525}
526
527impl<T, U, P> PushBack<NestedFieldPath<P>> for FieldPathSet<T, U>
528where
529 T: PushBack<NestedFieldPath<P>>,
530{
531 type Output = FieldPathSet<PushBackOut<T, NestedFieldPath<P>>, AliasedPaths>;
532}
533
534impl<T, U, P, U2> PushBack<FieldPathSet<(P,), U2>> for FieldPathSet<T, U>
535where
536 T: PushBack<P>,
537{
538 type Output = FieldPathSet<PushBackOut<T, P>, AliasedPaths>;
539}
540
541impl<T, T2, U, U2> Append<FieldPathSet<T2, U2>> for FieldPathSet<T, U>
542where
543 T: Append<T2>,
544{
545 type Output = FieldPathSet<AppendOut<T, T2>, AliasedPaths>;
546}
547
548impl_cmp_traits! {
549 impl[T,U] FieldPathSet<T,U>
550 where[]
551}
552
553////////////////////////////////////////////////////////////////////////////////
554
555impl<F, S> NestedFieldPathSet<F, S, AliasedPaths>
556where
557 F: ConstDefault,
558 S: ConstDefault,
559{
560 /// Constructs a `NestedFieldPathSet`.
561 pub const NEW: Self = Self::DEFAULT;
562}
563
564impl<F, S, U> NestedFieldPathSet<F, S, U>
565where
566 F: ConstDefault,
567 S: ConstDefault,
568{
569 /// This can be used to construct a `NestedFieldPathSet<T, UniquePaths>`
570 /// from a type alias,
571 /// by doing `unsafe{ FOO::NEW_ALIASED.upgrade_unchecked() }`
572 /// (read the docs for `upgrade_unchecked` first).
573 pub const NEW_ALIASED: NestedFieldPathSet<F, S, AliasedPaths> = NestedFieldPathSet::NEW;
574}
575
576impl<F, S> Default for NestedFieldPathSet<F, S, AliasedPaths>
577where
578 F: Default,
579 S: Default,
580{
581 fn default() -> Self {
582 Self::new(Default::default(), Default::default())
583 }
584}
585
586impl<F, S, U> NestedFieldPathSet<F, S, U> {
587 /// Constructs a `NestedFieldPathSet` from an `F` and a `FieldPathSet`
588 pub const fn new(nested: F, set: FieldPathSet<S, U>) -> Self {
589 Self {
590 nested: ManuallyDrop::new(nested),
591 set,
592 }
593 }
594
595 /// Unwraps a `NestedFieldPathSet` into a `NestedFieldPath` and a `FieldPathSet`
596 pub const fn into_inner(self) -> (F, FieldPathSet<S, U>) {
597 (ManuallyDrop::into_inner(self.nested), self.set)
598 }
599
600 /// Unwraps a `NestedFieldPathSet` into the `NestedFieldPath` for the nested field.
601 pub const fn into_nested(self) -> F {
602 ManuallyDrop::into_inner(self.nested)
603 }
604
605 /// Unwraps a `NestedFieldPathSet` into the `FieldPathSet` used to
606 /// access the multiple fields inside a nested field.
607 pub const fn into_set(self) -> FieldPathSet<S, U> {
608 self.set
609 }
610}
611
612impl<F, S> NestedFieldPathSet<F, S, UniquePaths> {
613 /// Converts a `NestedFieldPathSet<F, S, UniquePaths>` to a
614 /// `NestedFieldPathSet<F, S, AliasedPaths>`
615 #[inline(always)]
616 pub const fn downgrade(self) -> NestedFieldPathSet<F, S, AliasedPaths> {
617 NestedFieldPathSet {
618 nested: self.nested,
619 set: self.set.downgrade(),
620 }
621 }
622}
623
624impl<F, S> NestedFieldPathSet<F, S, AliasedPaths> {
625 /// Converts a `NestedFieldPathSet<F, S, AliasedPaths>` to a
626 /// `NestedFieldPathSet<F, S, UniquePaths>`
627 ///
628 /// # Safety
629 ///
630 /// You must ensure that all the field paths in in the `S` type parameter are unique,
631 /// there must be no field path that is a prefix of any other field path.
632 #[inline(always)]
633 pub const unsafe fn upgrade_unchecked(self) -> NestedFieldPathSet<F, S, UniquePaths> {
634 self.set_uniqueness()
635 }
636
637 /// Converts a `NestedFieldPathSet<F, S, AliasedPaths>` to a
638 /// `NestedFieldPathSet<F, S, U>`
639 ///
640 /// # Safety
641 ///
642 /// If `U == UniquePaths`,
643 /// you must ensure that all the field paths in the `S` type parameter are unique,
644 /// there must be no field path that is a prefix of any other field path.
645 #[inline(always)]
646 pub const unsafe fn set_uniqueness<U>(self) -> NestedFieldPathSet<F, S, U> {
647 NestedFieldPathSet {
648 nested: self.nested,
649 set: self.set.set_uniqueness(),
650 }
651 }
652}
653
654impl<F, S, U> IsSingleFieldPath for NestedFieldPathSet<F, (S,), U> {}
655
656impl<F, S, U> IsMultiFieldPath for NestedFieldPathSet<F, S, U> {
657 type PathUniqueness = U;
658}
659
660impl<F, S> ConstDefault for NestedFieldPathSet<F, S, AliasedPaths>
661where
662 F: ConstDefault,
663 S: ConstDefault,
664{
665 const DEFAULT: Self = NestedFieldPathSet {
666 nested: ConstDefault::DEFAULT,
667 set: ConstDefault::DEFAULT,
668 };
669}
670
671////////////////////////////////////////////////////////////////////////////////
672
673/// A newtype wrapper used to allow `FieldPathSet` to access from 9 up to 64 fields.
674///
675/// For examples of constructing and using `FieldPathSet<LargePathSet<_>,_>` you can look at
676/// the [docs for `FieldPathSet::large`](../struct.FieldPathSet.html#method.large)
677#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
678pub struct LargePathSet<T>(pub T);
679
680impl<T> ConstDefault for LargePathSet<T>
681where
682 T: ConstDefault,
683{
684 const DEFAULT: Self = LargePathSet(T::DEFAULT);
685}
686
687////////////////////////////////////////////////////////////////////////////////
688
689/// A workaround for long compile-time errors.
690///
691/// The is used to work compile-time errors that are around 200 kilobytes long,
692/// caused by recusive impls.
693///
694/// This is an example of the code that triggered a long error message:
695/// ```ignore
696/// ().fields(FieldPathSet::many(panic!()))
697/// ```
698#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
699#[doc(hidden)]
700pub struct SmallPathSet<T>(pub(crate) T);
701
702impl<T> ConstDefault for SmallPathSet<T>
703where
704 T: ConstDefault,
705{
706 const DEFAULT: Self = SmallPathSet(T::DEFAULT);
707}
708
709////////////////////////////////////////////////////////////////////////////////
710
711/// Converts a `FieldPathSet<_,UniquePaths>` into a `FieldPathSet<_,AliasedPaths>`
712/// on the type level.
713pub trait IntoAliasing: IsMultiFieldPath {
714 /// The return value of this trait.
715 type Output: IsMultiFieldPath<PathUniqueness = AliasedPaths>;
716}
717
718/// Converts a `FieldPathSet<_,UniquePaths>` into a `FieldPathSet<_,AliasedPaths>`
719/// on the type level.
720pub type IntoAliasingOut<This> = <This as IntoAliasing>::Output;
721
722impl<F, U> IntoAliasing for FieldPathSet<F, U> {
723 type Output = FieldPathSet<F, AliasedPaths>;
724}
725
726impl<F, S, U> IntoAliasing for NestedFieldPathSet<F, S, U> {
727 type Output = NestedFieldPathSet<F, S, AliasedPaths>;
728}