collect_failable 0.18.0

A trait for collecting values into a container which has an invariant to uphold and whose construction may fail
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::errors::capacity::{FixedCap, RemainingCap};
use crate::errors::types::SizeHint;
use alloc::vec::Vec;

impl<T> RemainingCap for Vec<T> {
    /// Returns [`SizeHint::unbounded(0)`](SizeHint::unbounded) because [`Vec`]
    /// can grow indefinitely.
    fn remaining_cap(&self) -> SizeHint {
        SizeHint::unbounded(0)
    }
}

impl<T> FixedCap for Vec<T> {
    /// Returns [`SizeHint::unbounded(0)`](SizeHint::unbounded) because [`Vec`]
    /// has no fixed capacity.
    const CAP: SizeHint = SizeHint::unbounded(0);
}