Skip to content

Commit

Permalink
Demonstrate OrSaturated in the vacancy and saturation section.
Browse files Browse the repository at this point in the history
  • Loading branch information
olson-sean-k committed Oct 29, 2024
1 parent 3be7646 commit 515f7f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,23 @@
//! use mitsein::iter1;
//! use mitsein::prelude::*;
//!
//! // `saturate` returns an output and remainder: the output is an `ArrayVec1` here.
//! let xs: ArrayVec1<_, 4> = iter1::repeat(0i64).saturate().output();
//! // `saturate` returns an output and remainder: here, the output is an `ArrayVec1`.
//! let mut xs: ArrayVec1<_, 4> = iter1::repeat(0i64).saturate().output();
//! assert_eq!(xs.push_or_get_last(42), Err((42, &0)));
//!
//! let mut ys = Vec1::from_one_with_capacity(0i64, 4);
//! let vacancy = ys.vacancy();
//! ys.saturate(iter1::repeat(1i64));
//! assert_eq!(ys.insert_or_get(1, 88), Err((88, &1)));
//!
//! assert_eq!(xs.as_slice(), &[0, 0, 0, 0]);
//! assert_eq!(ys.as_slice(), &[0, 1, 1, 1]);
//! assert_eq!(ys.vacancy(), 0);
//! assert_eq!(vacancy, 3);
#![doc = "```"]
//!
//! See the [`Vacancy`] trait and the [`ExtendUntil`] and [`FromIteratorUntil`] traits.
//! See the [`Vacancy`] and [`OrSaturated`] traits and also the [`ExtendUntil`] and
//! [`FromIteratorUntil`] traits.
//!
//! # Integrations and Cargo Features
//!
Expand Down

0 comments on commit 515f7f8

Please sign in to comment.