mirror of
https://github.com/rust-lang/rust
synced 2024-09-06 01:11:17 +00:00
27 lines
457 B
Rust
27 lines
457 B
Rust
trait Set<T> {
|
|
fn contains(&self, _: T) -> bool;
|
|
fn set(&mut self, _: T);
|
|
}
|
|
|
|
impl<'a, T, S> Set<&'a [T]> for S where
|
|
T: Copy,
|
|
S: Set<T>,
|
|
{
|
|
fn contains(&self, bits: &[T]) -> bool {
|
|
bits.iter().all(|&bit| self.contains(bit))
|
|
}
|
|
|
|
fn set(&mut self, bits: &[T]) {
|
|
for &bit in bits {
|
|
self.set(bit)
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let bits: &[_] = &[0, 1];
|
|
|
|
0.contains(bits);
|
|
//~^ ERROR overflow
|
|
}
|