/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
usecrate::error::Result; use payload_support::Fit; use serde::Serialize;
/// Truncates `list` to fit within `payload_size_max_bytes` when serialized to /// JSON. pubfn shrink_to_fit<T: Serialize>(list: &mut Vec<T>, payload_size_max_bytes: usize) -> Result<()> { match payload_support::try_fit_items(list, payload_size_max_bytes) {
Fit::All => {}
Fit::Some(count) => list.truncate(count.get()),
Fit::None => list.clear(),
Fit::Err(e) => Err(e)?,
};
Ok(())
}
#[cfg(test)] mod tests { usesuper::super::record::CommandRecord; usesuper::*;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.