Movatterモバイル変換


[0]ホーム

URL:


Concat

std::slice

TraitConcat 

Source
pub trait Concat<Item>
where Item: ?Sized,
{ typeOutput; // Required method fnconcat(slice: &Self) -> Self::Output;}
🔬This is a nightly-only experimental API. (slice_concat_trait #27747)
Expand description

Helper trait for[T]::concat.

Note: theItem type parameter is not used in this trait,but it allows impls to be more generic.Without it, we get this error:

error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predica   --> library/alloc/src/slice.rs:608:6    |608 | impl<T: Clone, V: Borrow<[T]>> Concat for [V] {    |      ^ unconstrained type parameter

This is because there could existV types with multipleBorrow<[_]> impls,such that multipleT types would apply:

pub structFoo(Vec<u32>, Vec<String>);implstd::borrow::Borrow<[u32]>forFoo {fnborrow(&self) ->&[u32] {&self.0}}implstd::borrow::Borrow<[String]>forFoo {fnborrow(&self) ->&[String] {&self.1}}

Required Associated Types§

Source

typeOutput

🔬This is a nightly-only experimental API. (slice_concat_trait #27747)

The resulting type after concatenation

Required Methods§

Source

fnconcat(slice: &Self) -> Self::Output

🔬This is a nightly-only experimental API. (slice_concat_trait #27747)

Implementation of[T]::concat

Dyn Compatibility§

This trait isnotdyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S>Concat<str> for[S]
where S:Borrow<str>,

Note:str inConcat<str> is not meaningful here.This type parameter of the trait only exists to enable another impl.

Source§

impl<T, V>Concat<T> for[V]
where T:Clone, V:Borrow<[T]>,


[8]ページ先頭

©2009-2026 Movatter.jp