Add failing doc tests

This commit is contained in:
Paul Hauner 2019-07-08 18:53:25 +10:00
parent 1484773cd1
commit 5a7c44ed37
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF

View File

@ -29,6 +29,22 @@ impl<N: Unsigned + Clone> BitfieldBehaviour for BitVector<N> {}
/// use with a `BitList` sets a type-level (i.e., compile-time) maximum length and `BitVector`
/// provides a type-level fixed length.
///
/// ## Example
/// ```
/// use ssz_types::{Bitfield, BitVector, BitList, typenum};
///
/// type BitList8 = Bitfield<BitList<typenum::U8>>;
///
/// // The `N` type parameter specifies a maximum length. Creating a `BitList` with a larger
/// // capacity returns `None`.
/// assert!(BitList8::with_capacity(9).is_none());
///
/// let mut bitlist = BitList8::with_capacity(4); // `BitList` permits a capacity of less than the maximum.
/// assert!(bitlist.set(3, true).is_some()); // Setting inside the instantiation capacity is permitted.
/// assert!(bitlist.set(4, true).is_none()); // Setting outside that capacity is not.
///
/// ```
///
/// ## Note
///
/// The internal representation of the bitfield is the same as that required by SSZ - the highest