mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +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
|
|
}
|