/rust/registry/src/index.crates.io-1949cf8c6b5b557f/parcel_selectors-0.28.3/sink.rs
Line | Count | Source |
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 | | |
8 | | use 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. |
16 | | pub trait Push<T> { |
17 | | /// Push a value into self. |
18 | | fn push(&mut self, value: T); |
19 | | } |
20 | | |
21 | | impl<T> Push<T> for Vec<T> { |
22 | 0 | fn push(&mut self, value: T) { |
23 | 0 | Vec::push(self, value); |
24 | 0 | } |
25 | | } |
26 | | |
27 | | impl<A: Array> Push<A::Item> for SmallVec<A> { |
28 | 0 | fn push(&mut self, value: A::Item) { |
29 | 0 | SmallVec::push(self, value); |
30 | 0 | } |
31 | | } |