1use std::fmt::Debug;
7use std::hash::Hash;
8
9use rustc_ast_ir::Mutability;
10
11use crate::elaborate::Elaboratable;
12use crate::fold::{TypeFoldable, TypeSuperFoldable};
13use crate::relate::Relate;
14use crate::solve::{AdtDestructorKind, SizedTraitKind};
15use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
16use crate::{self as ty, CollectAndApply, Interner, UpcastFrom};
17
18pub trait Ty<I: Interner<Ty = Self>>:
19 Copy
20 + Debug
21 + Hash
22 + Eq
23 + Into<I::GenericArg>
24 + Into<I::Term>
25 + IntoKind<Kind = ty::TyKind<I>>
26 + TypeSuperVisitable<I>
27 + TypeSuperFoldable<I>
28 + Relate<I>
29 + Flags
30{
31 fn new_unit(interner: I) -> Self;
32
33 fn new_bool(interner: I) -> Self;
34
35 fn new_u8(interner: I) -> Self;
36
37 fn new_usize(interner: I) -> Self;
38
39 fn new_infer(interner: I, var: ty::InferTy) -> Self;
40
41 fn new_var(interner: I, var: ty::TyVid) -> Self;
42
43 fn new_param(interner: I, param: I::ParamTy) -> Self;
44
45 fn new_placeholder(interner: I, param: I::PlaceholderTy) -> Self;
46
47 fn new_bound(interner: I, debruijn: ty::DebruijnIndex, var: I::BoundTy) -> Self;
48
49 fn new_anon_bound(interner: I, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self;
50
51 fn new_alias(interner: I, kind: ty::AliasTyKind, alias_ty: ty::AliasTy<I>) -> Self;
52
53 fn new_projection_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self {
54 Ty::new_alias(
55 interner,
56 ty::AliasTyKind::Projection,
57 ty::AliasTy::new_from_args(interner, def_id, args),
58 )
59 }
60
61 fn new_projection(
62 interner: I,
63 def_id: I::DefId,
64 args: impl IntoIterator<Item: Into<I::GenericArg>>,
65 ) -> Self {
66 Ty::new_alias(
67 interner,
68 ty::AliasTyKind::Projection,
69 ty::AliasTy::new(interner, def_id, args),
70 )
71 }
72
73 fn new_error(interner: I, guar: I::ErrorGuaranteed) -> Self;
74
75 fn new_adt(interner: I, adt_def: I::AdtDef, args: I::GenericArgs) -> Self;
76
77 fn new_foreign(interner: I, def_id: I::DefId) -> Self;
78
79 fn new_dynamic(
80 interner: I,
81 preds: I::BoundExistentialPredicates,
82 region: I::Region,
83 kind: ty::DynKind,
84 ) -> Self;
85
86 fn new_coroutine(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self;
87
88 fn new_coroutine_closure(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self;
89
90 fn new_closure(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self;
91
92 fn new_coroutine_witness(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self;
93
94 fn new_ptr(interner: I, ty: Self, mutbl: Mutability) -> Self;
95
96 fn new_ref(interner: I, region: I::Region, ty: Self, mutbl: Mutability) -> Self;
97
98 fn new_array_with_const_len(interner: I, ty: Self, len: I::Const) -> Self;
99
100 fn new_slice(interner: I, ty: Self) -> Self;
101
102 fn new_tup(interner: I, tys: &[I::Ty]) -> Self;
103
104 fn new_tup_from_iter<It, T>(interner: I, iter: It) -> T::Output
105 where
106 It: Iterator<Item = T>,
107 T: CollectAndApply<Self, Self>;
108
109 fn new_fn_def(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self;
110
111 fn new_fn_ptr(interner: I, sig: ty::Binder<I, ty::FnSig<I>>) -> Self;
112
113 fn new_pat(interner: I, ty: Self, pat: I::Pat) -> Self;
114
115 fn new_unsafe_binder(interner: I, ty: ty::Binder<I, I::Ty>) -> Self;
116
117 fn tuple_fields(self) -> I::Tys;
118
119 fn to_opt_closure_kind(self) -> Option<ty::ClosureKind>;
120
121 fn from_closure_kind(interner: I, kind: ty::ClosureKind) -> Self;
122
123 fn from_coroutine_closure_kind(interner: I, kind: ty::ClosureKind) -> Self;
124
125 fn is_ty_var(self) -> bool {
126 matches!(self.kind(), ty::Infer(ty::TyVar(_)))
127 }
128
129 fn is_ty_error(self) -> bool {
130 matches!(self.kind(), ty::Error(_))
131 }
132
133 fn is_floating_point(self) -> bool {
134 matches!(self.kind(), ty::Float(_) | ty::Infer(ty::FloatVar(_)))
135 }
136
137 fn is_integral(self) -> bool {
138 matches!(self.kind(), ty::Infer(ty::IntVar(_)) | ty::Int(_) | ty::Uint(_))
139 }
140
141 fn is_fn_ptr(self) -> bool {
142 matches!(self.kind(), ty::FnPtr(..))
143 }
144
145 fn has_unsafe_fields(self) -> bool;
147
148 fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> {
149 self.kind().fn_sig(interner)
150 }
151
152 fn discriminant_ty(self, interner: I) -> I::Ty;
153
154 fn is_known_rigid(self) -> bool {
155 self.kind().is_known_rigid()
156 }
157
158 fn is_guaranteed_unsized_raw(self) -> bool {
159 match self.kind() {
160 ty::Dynamic(_, _, ty::Dyn) | ty::Slice(_) | ty::Str => true,
161 ty::Bool
162 | ty::Char
163 | ty::Int(_)
164 | ty::Uint(_)
165 | ty::Float(_)
166 | ty::Adt(_, _)
167 | ty::Foreign(_)
168 | ty::Array(_, _)
169 | ty::Pat(_, _)
170 | ty::RawPtr(_, _)
171 | ty::Ref(_, _, _)
172 | ty::FnDef(_, _)
173 | ty::FnPtr(_, _)
174 | ty::UnsafeBinder(_)
175 | ty::Closure(_, _)
176 | ty::CoroutineClosure(_, _)
177 | ty::Coroutine(_, _)
178 | ty::CoroutineWitness(_, _)
179 | ty::Never
180 | ty::Tuple(_)
181 | ty::Alias(_, _)
182 | ty::Param(_)
183 | ty::Bound(_, _)
184 | ty::Placeholder(_)
185 | ty::Infer(_)
186 | ty::Error(_)
187 | ty::Dynamic(_, _, ty::DynStar) => false,
188 }
189 }
190}
191
192pub trait Tys<I: Interner<Tys = Self>>:
193 Copy + Debug + Hash + Eq + SliceLike<Item = I::Ty> + TypeFoldable<I> + Default
194{
195 fn inputs(self) -> I::FnInputTys;
196
197 fn output(self) -> I::Ty;
198}
199
200pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq {
201 fn rust() -> Self;
202
203 fn is_rust(self) -> bool;
205}
206
207pub trait Safety<I: Interner<Safety = Self>>: Copy + Debug + Hash + Eq {
208 fn safe() -> Self;
209
210 fn is_safe(self) -> bool;
211
212 fn prefix_str(self) -> &'static str;
213}
214
215pub trait Region<I: Interner<Region = Self>>:
216 Copy
217 + Debug
218 + Hash
219 + Eq
220 + Into<I::GenericArg>
221 + IntoKind<Kind = ty::RegionKind<I>>
222 + Flags
223 + Relate<I>
224{
225 fn new_bound(interner: I, debruijn: ty::DebruijnIndex, var: I::BoundRegion) -> Self;
226
227 fn new_anon_bound(interner: I, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self;
228
229 fn new_static(interner: I) -> Self;
230
231 fn new_placeholder(interner: I, var: I::PlaceholderRegion) -> Self;
232
233 fn is_bound(self) -> bool {
234 matches!(self.kind(), ty::ReBound(..))
235 }
236}
237
238pub trait Const<I: Interner<Const = Self>>:
239 Copy
240 + Debug
241 + Hash
242 + Eq
243 + Into<I::GenericArg>
244 + Into<I::Term>
245 + IntoKind<Kind = ty::ConstKind<I>>
246 + TypeSuperVisitable<I>
247 + TypeSuperFoldable<I>
248 + Relate<I>
249 + Flags
250{
251 fn new_infer(interner: I, var: ty::InferConst) -> Self;
252
253 fn new_var(interner: I, var: ty::ConstVid) -> Self;
254
255 fn new_bound(interner: I, debruijn: ty::DebruijnIndex, var: I::BoundConst) -> Self;
256
257 fn new_anon_bound(interner: I, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self;
258
259 fn new_placeholder(interner: I, param: I::PlaceholderConst) -> Self;
260
261 fn new_unevaluated(interner: I, uv: ty::UnevaluatedConst<I>) -> Self;
262
263 fn new_expr(interner: I, expr: I::ExprConst) -> Self;
264
265 fn new_error(interner: I, guar: I::ErrorGuaranteed) -> Self;
266
267 fn new_error_with_message(interner: I, msg: impl ToString) -> Self {
268 Self::new_error(interner, interner.delay_bug(msg))
269 }
270
271 fn is_ct_var(self) -> bool {
272 matches!(self.kind(), ty::ConstKind::Infer(ty::InferConst::Var(_)))
273 }
274
275 fn is_ct_error(self) -> bool {
276 matches!(self.kind(), ty::ConstKind::Error(_))
277 }
278}
279
280pub trait ValueConst<I: Interner<ValueConst = Self>>: Copy + Debug + Hash + Eq {
281 fn ty(self) -> I::Ty;
282 fn valtree(self) -> I::ValTree;
283}
284
285pub trait ExprConst<I: Interner<ExprConst = Self>>: Copy + Debug + Hash + Eq + Relate<I> {
286 fn args(self) -> I::GenericArgs;
287}
288
289pub trait GenericsOf<I: Interner<GenericsOf = Self>> {
290 fn count(&self) -> usize;
291}
292
293pub trait GenericArg<I: Interner<GenericArg = Self>>:
294 Copy
295 + Debug
296 + Hash
297 + Eq
298 + IntoKind<Kind = ty::GenericArgKind<I>>
299 + TypeVisitable<I>
300 + Relate<I>
301 + From<I::Ty>
302 + From<I::Region>
303 + From<I::Const>
304 + From<I::Term>
305{
306 fn as_term(&self) -> Option<I::Term> {
307 match self.kind() {
308 ty::GenericArgKind::Lifetime(_) => None,
309 ty::GenericArgKind::Type(ty) => Some(ty.into()),
310 ty::GenericArgKind::Const(ct) => Some(ct.into()),
311 }
312 }
313
314 fn as_type(&self) -> Option<I::Ty> {
315 if let ty::GenericArgKind::Type(ty) = self.kind() { Some(ty) } else { None }
316 }
317
318 fn expect_ty(&self) -> I::Ty {
319 self.as_type().expect("expected a type")
320 }
321
322 fn as_const(&self) -> Option<I::Const> {
323 if let ty::GenericArgKind::Const(c) = self.kind() { Some(c) } else { None }
324 }
325
326 fn expect_const(&self) -> I::Const {
327 self.as_const().expect("expected a const")
328 }
329
330 fn as_region(&self) -> Option<I::Region> {
331 if let ty::GenericArgKind::Lifetime(c) = self.kind() { Some(c) } else { None }
332 }
333
334 fn expect_region(&self) -> I::Region {
335 self.as_region().expect("expected a const")
336 }
337
338 fn is_non_region_infer(self) -> bool {
339 match self.kind() {
340 ty::GenericArgKind::Lifetime(_) => false,
341 ty::GenericArgKind::Type(ty) => ty.is_ty_var(),
342 ty::GenericArgKind::Const(ct) => ct.is_ct_var(),
343 }
344 }
345}
346
347pub trait Term<I: Interner<Term = Self>>:
348 Copy + Debug + Hash + Eq + IntoKind<Kind = ty::TermKind<I>> + TypeFoldable<I> + Relate<I>
349{
350 fn as_type(&self) -> Option<I::Ty> {
351 if let ty::TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
352 }
353
354 fn expect_ty(&self) -> I::Ty {
355 self.as_type().expect("expected a type, but found a const")
356 }
357
358 fn as_const(&self) -> Option<I::Const> {
359 if let ty::TermKind::Const(c) = self.kind() { Some(c) } else { None }
360 }
361
362 fn expect_const(&self) -> I::Const {
363 self.as_const().expect("expected a const, but found a type")
364 }
365
366 fn is_infer(self) -> bool {
367 match self.kind() {
368 ty::TermKind::Ty(ty) => ty.is_ty_var(),
369 ty::TermKind::Const(ct) => ct.is_ct_var(),
370 }
371 }
372
373 fn is_error(self) -> bool {
374 match self.kind() {
375 ty::TermKind::Ty(ty) => ty.is_ty_error(),
376 ty::TermKind::Const(ct) => ct.is_ct_error(),
377 }
378 }
379
380 fn to_alias_term(self) -> Option<ty::AliasTerm<I>> {
381 match self.kind() {
382 ty::TermKind::Ty(ty) => match ty.kind() {
383 ty::Alias(_kind, alias_ty) => Some(alias_ty.into()),
384 _ => None,
385 },
386 ty::TermKind::Const(ct) => match ct.kind() {
387 ty::ConstKind::Unevaluated(uv) => Some(uv.into()),
388 _ => None,
389 },
390 }
391 }
392}
393
394pub trait GenericArgs<I: Interner<GenericArgs = Self>>:
395 Copy + Debug + Hash + Eq + SliceLike<Item = I::GenericArg> + Default + Relate<I>
396{
397 fn rebase_onto(
398 self,
399 interner: I,
400 source_def_id: I::DefId,
401 target: I::GenericArgs,
402 ) -> I::GenericArgs;
403
404 fn type_at(self, i: usize) -> I::Ty;
405
406 fn region_at(self, i: usize) -> I::Region;
407
408 fn const_at(self, i: usize) -> I::Const;
409
410 fn identity_for_item(interner: I, def_id: I::DefId) -> I::GenericArgs;
411
412 fn extend_with_error(
413 interner: I,
414 def_id: I::DefId,
415 original_args: &[I::GenericArg],
416 ) -> I::GenericArgs;
417
418 fn split_closure_args(self) -> ty::ClosureArgsParts<I>;
419 fn split_coroutine_closure_args(self) -> ty::CoroutineClosureArgsParts<I>;
420 fn split_coroutine_args(self) -> ty::CoroutineArgsParts<I>;
421
422 fn as_closure(self) -> ty::ClosureArgs<I> {
423 ty::ClosureArgs { args: self }
424 }
425 fn as_coroutine_closure(self) -> ty::CoroutineClosureArgs<I> {
426 ty::CoroutineClosureArgs { args: self }
427 }
428 fn as_coroutine(self) -> ty::CoroutineArgs<I> {
429 ty::CoroutineArgs { args: self }
430 }
431}
432
433pub trait Predicate<I: Interner<Predicate = Self>>:
434 Copy
435 + Debug
436 + Hash
437 + Eq
438 + TypeSuperVisitable<I>
439 + TypeSuperFoldable<I>
440 + Flags
441 + UpcastFrom<I, ty::PredicateKind<I>>
442 + UpcastFrom<I, ty::Binder<I, ty::PredicateKind<I>>>
443 + UpcastFrom<I, ty::ClauseKind<I>>
444 + UpcastFrom<I, ty::Binder<I, ty::ClauseKind<I>>>
445 + UpcastFrom<I, I::Clause>
446 + UpcastFrom<I, ty::NormalizesTo<I>>
447 + UpcastFrom<I, ty::TraitRef<I>>
448 + UpcastFrom<I, ty::Binder<I, ty::TraitRef<I>>>
449 + UpcastFrom<I, ty::TraitPredicate<I>>
450 + UpcastFrom<I, ty::OutlivesPredicate<I, I::Ty>>
451 + UpcastFrom<I, ty::OutlivesPredicate<I, I::Region>>
452 + IntoKind<Kind = ty::Binder<I, ty::PredicateKind<I>>>
453 + Elaboratable<I>
454{
455 fn as_clause(self) -> Option<I::Clause>;
456
457 fn as_normalizes_to(self) -> Option<ty::Binder<I, ty::NormalizesTo<I>>> {
458 let kind = self.kind();
459 match kind.skip_binder() {
460 ty::PredicateKind::NormalizesTo(pred) => Some(kind.rebind(pred)),
461 _ => None,
462 }
463 }
464
465 fn allow_normalization(self) -> bool;
467}
468
469pub trait Clause<I: Interner<Clause = Self>>:
470 Copy
471 + Debug
472 + Hash
473 + Eq
474 + TypeFoldable<I>
475 + UpcastFrom<I, ty::Binder<I, ty::ClauseKind<I>>>
476 + UpcastFrom<I, ty::TraitRef<I>>
477 + UpcastFrom<I, ty::Binder<I, ty::TraitRef<I>>>
478 + UpcastFrom<I, ty::TraitPredicate<I>>
479 + UpcastFrom<I, ty::Binder<I, ty::TraitPredicate<I>>>
480 + UpcastFrom<I, ty::ProjectionPredicate<I>>
481 + UpcastFrom<I, ty::Binder<I, ty::ProjectionPredicate<I>>>
482 + IntoKind<Kind = ty::Binder<I, ty::ClauseKind<I>>>
483 + Elaboratable<I>
484{
485 fn as_predicate(self) -> I::Predicate;
486
487 fn as_trait_clause(self) -> Option<ty::Binder<I, ty::TraitPredicate<I>>> {
488 self.kind()
489 .map_bound(|clause| if let ty::ClauseKind::Trait(t) = clause { Some(t) } else { None })
490 .transpose()
491 }
492
493 fn as_host_effect_clause(self) -> Option<ty::Binder<I, ty::HostEffectPredicate<I>>> {
494 self.kind()
495 .map_bound(
496 |clause| if let ty::ClauseKind::HostEffect(t) = clause { Some(t) } else { None },
497 )
498 .transpose()
499 }
500
501 fn as_projection_clause(self) -> Option<ty::Binder<I, ty::ProjectionPredicate<I>>> {
502 self.kind()
503 .map_bound(
504 |clause| {
505 if let ty::ClauseKind::Projection(p) = clause { Some(p) } else { None }
506 },
507 )
508 .transpose()
509 }
510
511 fn instantiate_supertrait(self, cx: I, trait_ref: ty::Binder<I, ty::TraitRef<I>>) -> Self;
516}
517
518pub trait Clauses<I: Interner<Clauses = Self>>:
519 Copy
520 + Debug
521 + Hash
522 + Eq
523 + TypeSuperVisitable<I>
524 + TypeSuperFoldable<I>
525 + Flags
526 + SliceLike<Item = I::Clause>
527{
528}
529
530pub trait PlaceholderLike<I: Interner>: Copy + Debug + Hash + Eq {
532 fn universe(self) -> ty::UniverseIndex;
533 fn var(self) -> ty::BoundVar;
534
535 type Bound: BoundVarLike<I>;
536 fn new(ui: ty::UniverseIndex, bound: Self::Bound) -> Self;
537 fn new_anon(ui: ty::UniverseIndex, var: ty::BoundVar) -> Self;
538 fn with_updated_universe(self, ui: ty::UniverseIndex) -> Self;
539}
540
541pub trait IntoKind {
542 type Kind;
543
544 fn kind(self) -> Self::Kind;
545}
546
547pub trait BoundVarLike<I: Interner>: Copy + Debug + Hash + Eq {
548 fn var(self) -> ty::BoundVar;
549
550 fn assert_eq(self, var: I::BoundVarKind);
551}
552
553pub trait ParamLike: Copy + Debug + Hash + Eq {
554 fn index(self) -> u32;
555}
556
557pub trait AdtDef<I: Interner>: Copy + Debug + Hash + Eq {
558 fn def_id(self) -> I::DefId;
559
560 fn is_struct(self) -> bool;
561
562 fn struct_tail_ty(self, interner: I) -> Option<ty::EarlyBinder<I, I::Ty>>;
566
567 fn is_phantom_data(self) -> bool;
568
569 fn is_manually_drop(self) -> bool;
570
571 fn all_field_tys(self, interner: I) -> ty::EarlyBinder<I, impl IntoIterator<Item = I::Ty>>;
573
574 fn sizedness_constraint(
575 self,
576 interner: I,
577 sizedness: SizedTraitKind,
578 ) -> Option<ty::EarlyBinder<I, I::Ty>>;
579
580 fn is_fundamental(self) -> bool;
581
582 fn destructor(self, interner: I) -> Option<AdtDestructorKind>;
583}
584
585pub trait ParamEnv<I: Interner>: Copy + Debug + Hash + Eq + TypeFoldable<I> {
586 fn caller_bounds(self) -> impl SliceLike<Item = I::Clause>;
587}
588
589pub trait Features<I: Interner>: Copy {
590 fn generic_const_exprs(self) -> bool;
591
592 fn coroutine_clone(self) -> bool;
593
594 fn associated_const_equality(self) -> bool;
595}
596
597pub trait DefId<I: Interner>: Copy + Debug + Hash + Eq + TypeFoldable<I> {
598 fn is_local(self) -> bool;
599
600 fn as_local(self) -> Option<I::LocalDefId>;
601}
602
603pub trait BoundExistentialPredicates<I: Interner>:
604 Copy + Debug + Hash + Eq + Relate<I> + SliceLike<Item = ty::Binder<I, ty::ExistentialPredicate<I>>>
605{
606 fn principal_def_id(self) -> Option<I::DefId>;
607
608 fn principal(self) -> Option<ty::Binder<I, ty::ExistentialTraitRef<I>>>;
609
610 fn auto_traits(self) -> impl IntoIterator<Item = I::DefId>;
611
612 fn projection_bounds(
613 self,
614 ) -> impl IntoIterator<Item = ty::Binder<I, ty::ExistentialProjection<I>>>;
615}
616
617pub trait Span<I: Interner>: Copy + Debug + Hash + Eq + TypeFoldable<I> {
618 fn dummy() -> Self;
619}
620
621pub trait OpaqueTypeStorageEntries: Debug + Copy + Default {
622 fn needs_reevaluation(self, canonicalized: usize) -> bool;
626}
627
628pub trait SliceLike: Sized + Copy {
629 type Item: Copy;
630 type IntoIter: Iterator<Item = Self::Item> + DoubleEndedIterator;
631
632 fn iter(self) -> Self::IntoIter;
633
634 fn as_slice(&self) -> &[Self::Item];
635
636 fn get(self, idx: usize) -> Option<Self::Item> {
637 self.as_slice().get(idx).copied()
638 }
639
640 fn len(self) -> usize {
641 self.as_slice().len()
642 }
643
644 fn is_empty(self) -> bool {
645 self.len() == 0
646 }
647
648 fn contains(self, t: &Self::Item) -> bool
649 where
650 Self::Item: PartialEq,
651 {
652 self.as_slice().contains(t)
653 }
654
655 fn to_vec(self) -> Vec<Self::Item> {
656 self.as_slice().to_vec()
657 }
658
659 fn last(self) -> Option<Self::Item> {
660 self.as_slice().last().copied()
661 }
662
663 fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])> {
664 self.as_slice().split_last()
665 }
666}
667
668impl<'a, T: Copy> SliceLike for &'a [T] {
669 type Item = T;
670 type IntoIter = std::iter::Copied<std::slice::Iter<'a, T>>;
671
672 fn iter(self) -> Self::IntoIter {
673 self.iter().copied()
674 }
675
676 fn as_slice(&self) -> &[Self::Item] {
677 *self
678 }
679}
680
681impl<'a, T: Copy, const N: usize> SliceLike for &'a [T; N] {
682 type Item = T;
683 type IntoIter = std::iter::Copied<std::slice::Iter<'a, T>>;
684
685 fn iter(self) -> Self::IntoIter {
686 self.into_iter().copied()
687 }
688
689 fn as_slice(&self) -> &[Self::Item] {
690 *self
691 }
692}
693
694impl<'a, S: SliceLike> SliceLike for &'a S {
695 type Item = S::Item;
696 type IntoIter = S::IntoIter;
697
698 fn iter(self) -> Self::IntoIter {
699 (*self).iter()
700 }
701
702 fn as_slice(&self) -> &[Self::Item] {
703 (*self).as_slice()
704 }
705}