pub trait ShardExt {
type Shard;
// Required method
fn split_inplace_at(self, at: usize) -> (Self::Shard, Self::Shard);
}Expand description
An extension trait for things that can be split into shards
For your convenience, this is implemented for both Vec and
VecShard, so you can split recursively:
let drinks = vec!["heineken", "jupiler", "turmbräu", "orange juice", "champagne"];
let (beers, other_drinks) = drinks.split_inplace_at(3);
let (bad_beers, good_beers) = beers.split_inplace_at(2);
assert_eq!(*good_beers, ["turmbräu"]);Required Associated Types§
Required Methods§
Sourcefn split_inplace_at(self, at: usize) -> (Self::Shard, Self::Shard)
fn split_inplace_at(self, at: usize) -> (Self::Shard, Self::Shard)
Split this array into two shards at the given index. This is an O(1) operation, as it keeps the underlying storage. In exchange, this means that the memory will not be reclaimed until all existing shards using it are dropped.