From a5005a9967991ceae7c1cca2be08e0a1f9f70493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 1 Jan 2017 22:07:20 +0100 Subject: [PATCH] style: document the sink module. --- components/style/sink.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/style/sink.rs b/components/style/sink.rs index 33aa26ac1af..343bf07d869 100644 --- a/components/style/sink.rs +++ b/components/style/sink.rs @@ -2,10 +2,20 @@ * 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}; use std::marker::PhantomData; +/// 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 { + /// Push a value into self. fn push(&mut self, value: T); } @@ -21,13 +31,16 @@ impl Push for SmallVec { } } +/// A struct that implements `Push`, but only stores whether it's empty. pub struct ForgetfulSink(bool, PhantomData); impl ForgetfulSink { + /// Trivially construct a new `ForgetfulSink`. pub fn new() -> Self { ForgetfulSink(true, PhantomData) } + /// Whether this sink is empty or not. pub fn is_empty(&self) -> bool { self.0 }