selectors/
sink.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! Small helpers to abstract over different containers.
6#![deny(missing_docs)]
7
8use smallvec::{Array, SmallVec};
9
10/// A trait to abstract over a `push` method that may be implemented for
11/// different kind of types.
12///
13/// Used to abstract over `Array`, `SmallVec` and `Vec`, and also to implement a
14/// type which `push` method does only tweak a byte when we only need to check
15/// for the presence of something.
16pub trait Push<T> {
17    /// Push a value into self.
18    fn push(&mut self, value: T);
19}
20
21impl<T> Push<T> for Vec<T> {
22    fn push(&mut self, value: T) {
23        Vec::push(self, value);
24    }
25}
26
27impl<A: Array> Push<A::Item> for SmallVec<A> {
28    fn push(&mut self, value: A::Item) {
29        SmallVec::push(self, value);
30    }
31}