mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
2215adc834
https://bugzilla.mozilla.org/show_bug.cgi?id=1373800 Source-Repo: https://github.com/servo/servo Source-Revision: b211664e877a3e4d712314fa7f3002fd19cff549 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 779228343f44919c07d9a6a74b55aff71535bc0a
32 lines
949 B
Rust
32 lines
949 B
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
//! Small helpers to abstract over different containers.
|
|
#![deny(missing_docs)]
|
|
|
|
use smallvec::{Array, SmallVec};
|
|
|
|
/// A trait to abstract over a `push` method that may be implemented for
|
|
/// different kind of types.
|
|
///
|
|
/// Used to abstract over `Array`, `SmallVec` and `Vec`, and also to implement a
|
|
/// type which `push` method does only tweak a byte when we only need to check
|
|
/// for the presence of something.
|
|
pub trait Push<T> {
|
|
/// Push a value into self.
|
|
fn push(&mut self, value: T);
|
|
}
|
|
|
|
impl<T> Push<T> for Vec<T> {
|
|
fn push(&mut self, value: T) {
|
|
Vec::push(self, value);
|
|
}
|
|
}
|
|
|
|
impl<A: Array> Push<A::Item> for SmallVec<A> {
|
|
fn push(&mut self, value: A::Item) {
|
|
SmallVec::push(self, value);
|
|
}
|
|
}
|