Unverified Commit a9ab40db authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Add automated spell-checking (#718)



* Add `.config`

* Fix hunspell complaints

* Run spellcheck in CI

* Improve hunspell config

* Fix 'pre' prefix

* Remove `|` from dictionary

* Add missing words to dictionary

* Add missing words to dictionary

* Add missing words to dictionary

* Fix `n`-th → nth

* Fix indentation

* Remove comment

* Fix number

* Fix spacing

* Remove regex

* Apply suggestions from code review
Co-authored-by: default avatarBernhard Schuster <bernhard@ahoi.io>

* Fix dictionary

* Fix dictionary

* Implement review comments

* Replace SRML with FRAME

* Replace occurrences of 'spreaded'

* Tuning text regarding 'spreaded'

* Update crates/storage/src/lazy/entry.rs
Co-authored-by: default avatarHero Bird <robin.freyler@gmail.com>
Co-authored-by: default avatarBernhard Schuster <bernhard@ahoi.io>
Co-authored-by: default avatarHero Bird <robin.freyler@gmail.com>
parent f329a928
Pipeline #129415 failed with stages
in 7 minutes and 28 seconds
...@@ -91,7 +91,7 @@ pub struct ChainExtensionMethod { ...@@ -91,7 +91,7 @@ pub struct ChainExtensionMethod {
/// ///
/// The default for this flag is `true`. /// The default for this flag is `true`.
handle_status: bool, handle_status: bool,
/// If `false` the proc. macro no longer tries to enforce that the returned type encoded /// If `false` the procedural macro no longer tries to enforce that the returned type encoded
/// into the output buffer of the chain extension method call is of type `Result<T, E>`. /// into the output buffer of the chain extension method call is of type `Result<T, E>`.
/// Also `E` is no longer required to implement `From<Self::ErrorCode>` in case `handle_status` /// Also `E` is no longer required to implement `From<Self::ErrorCode>` in case `handle_status`
/// flag does not exist. /// flag does not exist.
...@@ -336,7 +336,7 @@ impl ChainExtension { ...@@ -336,7 +336,7 @@ impl ChainExtension {
/// # Note /// # Note
/// ///
/// The input Rust trait item is going to be replaced with a concrete chain extension type definition /// The input Rust trait item is going to be replaced with a concrete chain extension type definition
/// as a result of this proc. macro invocation. /// as a result of this procedural macro invocation.
fn analyse_items( fn analyse_items(
item_trait: &syn::ItemTrait, item_trait: &syn::ItemTrait,
) -> Result<(syn::TraitItemType, Vec<ChainExtensionMethod>)> { ) -> Result<(syn::TraitItemType, Vec<ChainExtensionMethod>)> {
......
...@@ -653,7 +653,7 @@ pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream { ...@@ -653,7 +653,7 @@ pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream {
/// ///
/// # Usage /// # Usage
/// ///
/// Usually the chain extension definition using this proc. macro is provided /// Usually the chain extension definition using this procedural macro is provided
/// by the author of the chain extension in a separate crate. /// by the author of the chain extension in a separate crate.
/// ink! smart contracts using this chain extension simply depend on this crate /// ink! smart contracts using this chain extension simply depend on this crate
/// and use its associated environment definition in order to make use of /// and use its associated environment definition in order to make use of
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
/// ///
/// # Note /// # Note
/// ///
/// This trait is automatically implemented when using `#[ink::chain_extension]` proc. macro. /// This trait is automatically implemented when using `#[ink::chain_extension]` procedural macro.
pub trait ChainExtensionInstance { pub trait ChainExtensionInstance {
/// The type of the chain extension instance. /// The type of the chain extension instance.
type Instance; type Instance;
...@@ -38,7 +38,7 @@ pub trait ChainExtension { ...@@ -38,7 +38,7 @@ pub trait ChainExtension {
/// Only implemented for `Result<T, E>`. /// Only implemented for `Result<T, E>`.
/// ///
/// Used to check at compile time if the return type of a chain extension method /// Used to check at compile time if the chain extension method return type
/// is a `Result` type using the type system instead of the syntactic structure. /// is a `Result` type using the type system instead of the syntactic structure.
#[doc(hidden)] #[doc(hidden)]
pub trait IsResultType: private::Sealed { pub trait IsResultType: private::Sealed {
...@@ -55,6 +55,6 @@ impl<T, E> IsResultType for Result<T, E> { ...@@ -55,6 +55,6 @@ impl<T, E> IsResultType for Result<T, E> {
} }
mod private { mod private {
/// Seals the `IsResultType` trait so that it cannot be implemented outside of this module. /// Seals the `IsResultType` trait so that it cannot be implemented outside this module.
pub trait Sealed {} pub trait Sealed {}
} }
...@@ -33,7 +33,7 @@ pub enum DispatchError { ...@@ -33,7 +33,7 @@ pub enum DispatchError {
} }
impl DispatchError { impl DispatchError {
/// Converts `self` into an associated `u32` that SRML contracts can handle. /// Converts `self` into an associated `u32` that FRAME contracts can handle.
#[inline] #[inline]
pub fn to_u32(self) -> u32 { pub fn to_u32(self) -> u32 {
DispatchRetCode::from(self).to_u32() DispatchRetCode::from(self).to_u32()
...@@ -56,7 +56,7 @@ impl DispatchRetCode { ...@@ -56,7 +56,7 @@ impl DispatchRetCode {
/// ///
/// # Note /// # Note
/// ///
/// This is useful to communicate back to SRML contracts. /// This is useful to communicate back to FRAME contracts.
#[inline] #[inline]
pub fn to_u32(self) -> u32 { pub fn to_u32(self) -> u32 {
self.0 self.0
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
/// Implemented by contracts in order to override `env().emit_event(..)` /// Implemented by contracts in order to override `env().emit_event(..)`
/// syntax for emitting of ink! contract events. /// syntax for emitting of ink! contract events.
/// ///
/// # Dev Note /// # Developer Note
/// ///
/// Normally we'd try to define traits like these in the compagnion /// Normally we'd try to define traits like these in the companion
/// `ink_lang` crate, however, due to Rust's orphan rules we must /// `ink_lang` crate, however, due to Rust's orphan rules we must
/// define this trait here. /// define this trait here.
pub trait EmitEvent<C> pub trait EmitEvent<C>
......
...@@ -27,7 +27,7 @@ use ink_env::{ ...@@ -27,7 +27,7 @@ use ink_env::{
use ink_storage::traits::SpreadLayout; use ink_storage::traits::SpreadLayout;
/// Trait used to indicate that an ink! trait definition has been checked /// Trait used to indicate that an ink! trait definition has been checked
/// by the `#[ink::trait_definition]` proc. macro. /// by the `#[ink::trait_definition]` procedural macro.
#[doc(hidden)] #[doc(hidden)]
pub unsafe trait CheckedInkTrait<T> {} pub unsafe trait CheckedInkTrait<T> {}
......
...@@ -330,7 +330,7 @@ pub enum CryptoHasher { ...@@ -330,7 +330,7 @@ pub enum CryptoHasher {
pub struct ArrayLayout<F: Form = MetaForm> { pub struct ArrayLayout<F: Form = MetaForm> {
/// The offset key of the array layout. /// The offset key of the array layout.
/// ///
/// This is the same key as the 0-th element of the array layout. /// This is the same key as the element at index 0 of the array layout.
offset: LayoutKey, offset: LayoutKey,
/// The number of elements in the array layout. /// The number of elements in the array layout.
len: u32, len: u32,
...@@ -363,7 +363,7 @@ where ...@@ -363,7 +363,7 @@ where
{ {
/// Returns the offset key of the array layout. /// Returns the offset key of the array layout.
/// ///
/// This is the same key as the 0-th element of the array layout. /// This is the same key as the element at index 0 of the array layout.
pub fn offset(&self) -> &LayoutKey { pub fn offset(&self) -> &LayoutKey {
&self.offset &self.offset
} }
......
...@@ -226,9 +226,9 @@ pub struct ConstructorSpec<F: Form = MetaForm> { ...@@ -226,9 +226,9 @@ pub struct ConstructorSpec<F: Form = MetaForm> {
pub name: Vec<F::String>, pub name: Vec<F::String>,
/// The selector hash of the message. /// The selector hash of the message.
pub selector: Selector, pub selector: Selector,
/// The parameters of the deploy handler. /// The parameters of the deployment handler.
pub args: Vec<MessageParamSpec<F>>, pub args: Vec<MessageParamSpec<F>>,
/// The deploy handler documentation. /// The deployment handler documentation.
pub docs: Vec<F::String>, pub docs: Vec<F::String>,
} }
...@@ -265,12 +265,12 @@ where ...@@ -265,12 +265,12 @@ where
&self.selector &self.selector
} }
/// Returns the parameters of the deploy handler. /// Returns the parameters of the deployment handler.
pub fn args(&self) -> &[MessageParamSpec<F>] { pub fn args(&self) -> &[MessageParamSpec<F>] {
&self.args &self.args
} }
/// Returns the deploy handler documentation. /// Returns the deployment handler documentation.
pub fn docs(&self) -> &[F::String] { pub fn docs(&self) -> &[F::String] {
&self.docs &self.docs
} }
...@@ -278,11 +278,11 @@ where ...@@ -278,11 +278,11 @@ where
/// A builder for constructors. /// A builder for constructors.
/// ///
/// # Dev /// # Developer Note
/// ///
/// Some of the fields are guarded by a type-state pattern to /// Some fields are guarded by a type-state pattern to fail at
/// fail at compile-time instead of at run-time. This is useful /// compile-time instead of at run-time. This is useful to better
/// to better debug code-gen macros. /// debug code-gen macros.
pub struct ConstructorSpecBuilder<Selector> { pub struct ConstructorSpecBuilder<Selector> {
spec: ConstructorSpec, spec: ConstructorSpec,
marker: PhantomData<fn() -> Selector>, marker: PhantomData<fn() -> Selector>,
...@@ -405,7 +405,7 @@ mod state { ...@@ -405,7 +405,7 @@ mod state {
pub struct Mutates; pub struct Mutates;
/// Type state for telling if the message is payable. /// Type state for telling if the message is payable.
pub struct IsPayable; pub struct IsPayable;
/// Type state for the return type of a message. /// Type state for the message return type.
pub struct Returns; pub struct Returns;
} }
...@@ -504,11 +504,11 @@ where ...@@ -504,11 +504,11 @@ where
/// A builder for messages. /// A builder for messages.
/// ///
/// # Dev /// # Developer Note
/// ///
/// Some of the fields are guarded by a type-state pattern to /// Some fields are guarded by a type-state pattern to fail at
/// fail at compile-time instead of at run-time. This is useful /// compile-time instead of at run-time. This is useful to better
/// to better debug code-gen macros. /// debug code-gen macros.
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub struct MessageSpecBuilder<Selector, Mutates, IsPayable, Returns> { pub struct MessageSpecBuilder<Selector, Mutates, IsPayable, Returns> {
spec: MessageSpec, spec: MessageSpec,
...@@ -770,7 +770,7 @@ impl Selector { ...@@ -770,7 +770,7 @@ impl Selector {
/// however, it will miss the potentially important information that it /// however, it will miss the potentially important information that it
/// is being used through a type alias named `Foo`. /// is being used through a type alias named `Foo`.
/// ///
/// In ink! we current experience this problem with environmental types /// In ink! we currently experience this problem with environmental types
/// such as the `Balance` type that is just a type alias to `u128` in the /// such as the `Balance` type that is just a type alias to `u128` in the
/// default setup. Even though it would be useful for third party tools /// default setup. Even though it would be useful for third party tools
/// such as the Polkadot UI to know that we are handling with `Balance` /// such as the Polkadot UI to know that we are handling with `Balance`
...@@ -791,7 +791,7 @@ pub type DisplayName<F> = scale_info::Path<F>; ...@@ -791,7 +791,7 @@ pub type DisplayName<F> = scale_info::Path<F>;
/// fn is_sorted(input: &[i32], pred: Predicate) -> bool; /// fn is_sorted(input: &[i32], pred: Predicate) -> bool;
/// ``` /// ```
/// In this above example `input` would have no displayable name, /// In this above example `input` would have no displayable name,
/// `pred`'s display name is `Predicate` and the display name of /// `pred`s display name is `Predicate` and the display name of
/// the return type is simply `bool`. Note that `Predicate` could /// the return type is simply `bool`. Note that `Predicate` could
/// simply be a type alias to `fn(i32, i32) -> Ordering`. /// simply be a type alias to `fn(i32, i32) -> Ordering`.
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
...@@ -1003,7 +1003,7 @@ impl EventParamSpecBuilder { ...@@ -1003,7 +1003,7 @@ impl EventParamSpecBuilder {
} }
} }
/// Describes the return type of a contract message. /// Describes the contract message return type.
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(transparent)] #[serde(transparent)]
#[serde(bound( #[serde(bound(
......
...@@ -16,7 +16,7 @@ use crate::Key; ...@@ -16,7 +16,7 @@ use crate::Key;
/// A key pointer. /// A key pointer.
/// ///
/// This wraps a base key and provides an interface to mimic pointer arithmetics. /// This wraps a base key and provides an interface to mimic pointer arithmetic.
/// Mainly used to coordinate keys through static storage structures. /// Mainly used to coordinate keys through static storage structures.
#[derive(Debug, Copy, Clone, Eq, PartialEq)] #[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct KeyPtr { pub struct KeyPtr {
......
...@@ -23,7 +23,7 @@ use crate::{ ...@@ -23,7 +23,7 @@ use crate::{
/// The dynamic allocator. /// The dynamic allocator.
/// ///
/// Manages dynamic storage allocations in a very efficient and economic way. /// Manages dynamic storage allocations in a very efficient and economical way.
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, Default, PartialEq, Eq)]
pub struct DynamicAllocator { pub struct DynamicAllocator {
allocations: BitStash, allocations: BitStash,
......
...@@ -32,7 +32,7 @@ use ink_primitives::Key; ...@@ -32,7 +32,7 @@ use ink_primitives::Key;
/// ///
/// Users can use this in order to make certain `SpreadLayout` storage entities /// Users can use this in order to make certain `SpreadLayout` storage entities
/// used in contexts that require a `PackedLayout` storage entity by simply /// used in contexts that require a `PackedLayout` storage entity by simply
/// packing the storage entity witihn a `storage::Box`. /// packing the storage entity within a `storage::Box`.
/// ///
/// Dynamic allocations caused by the creation of `storage::Box` instances do /// Dynamic allocations caused by the creation of `storage::Box` instances do
/// have some limited overhead: /// have some limited overhead:
......
...@@ -34,12 +34,12 @@ const DYNAMIC_ALLOCATOR_KEY_OFFSET: [u8; 32] = [0xFE; 32]; ...@@ -34,12 +34,12 @@ const DYNAMIC_ALLOCATOR_KEY_OFFSET: [u8; 32] = [0xFE; 32];
pub enum ContractPhase { pub enum ContractPhase {
/// Initializes the global dynamic storage allocator from scratch. /// Initializes the global dynamic storage allocator from scratch.
/// ///
/// Upon initialization it will be created from scratch as if the /// Upon initialization, it will be created from scratch as if the
/// contract has been deployed for the first time. /// contract has been deployed for the first time.
Deploy, Deploy,
/// Initializes the global dynamic storage allocator from storage. /// Initializes the global dynamic storage allocator from storage.
/// ///
/// Upon initialization the dynamic storage allocator will be pulled /// Upon initialization, the dynamic storage allocator will be pulled
/// from the contract storage with the assumption that a former /// from the contract storage with the assumption that a former
/// contract deployment has already taken place in the past. /// contract deployment has already taken place in the past.
Call, Call,
...@@ -51,12 +51,12 @@ pub enum ContractPhase { ...@@ -51,12 +51,12 @@ pub enum ContractPhase {
enum DynamicAllocatorState { enum DynamicAllocatorState {
/// The global instance has not yet been initialized. /// The global instance has not yet been initialized.
/// ///
/// Upon initialization it will be created from scratch as if the /// Upon initialization, it will be created from scratch as if the
/// contract has been deployed for the first time. /// contract has been deployed for the first time.
UninitDeploy, UninitDeploy,
/// The global instance has not yet been initialized. /// The global instance has not yet been initialized.
/// ///
/// Upon initialization it will be pulled from the contract storage /// Upon initialization, it will be pulled from the contract storage
/// with the assumption that a former contract deployment has already /// with the assumption that a former contract deployment has already
/// taken place in the past. /// taken place in the past.
UninitCall, UninitCall,
......
...@@ -22,24 +22,24 @@ ...@@ -22,24 +22,24 @@
//! //!
//! # Simplification //! # Simplification
//! //!
//! The contracts pallet is using 256 bit keys for identifying storage cells. //! The contracts pallet is using 256-bit keys for identifying storage cells.
//! This implies a storage space of 2^256 cells which is big enough to say that //! This implies a storage space of `2^256` cells which is big enough to say that
//! there are probably never going to happen collisions anywhere at any time //! there are probably never going to happen collisions anywhere at any time
//! if keys are chosen randomly. Using the built-in crypto hashers on unique //! if keys are chosen randomly. Using the built-in crypto hashers on unique
//! input we can be sure that there are never going to be collisions in this //! input we can be sure that there are never going to be collisions in this
//! space of 2^256 cells. //! space of `2^256` cells.
//! //!
//! This way we can reduce the problem of finding another region in our storage //! This way we can reduce the problem of finding another region in our storage
//! that fits certain requirements (e.g. a minimum size) to the problem of //! that fits certain requirements (e.g. a minimum size) to the problem of
//! finding another uniform slot. Since we are on 32-bit WebAssembly we have //! finding another uniform slot. Since we are on 32-bit WebAssembly we have
//! memory limitations that make it impractical to have more than 2^32 dynamic //! memory limitations that make it impractical to have more than `2^32` dynamic
//! allocated entities and so we can create another limitation for having a //! allocated entities, so we can create another limitation for having a total of
//! total of 2^32 dynamic allocations at any point in time. //! `2^32` dynamic allocations at any point in time.
//! This enables us to have 32-bit keys instead of 256-bit keys. //! This enables us to have 32-bit keys instead of 256-bit keys.
//! //!
//! We can convert such 32-bit keys (represented by e.g. a `u32`) into 256-bit //! We can convert such 32-bit keys (represented by e.g. a `u32`) into 256-bit
//! keys by using one of the built-in crypto hashes that has a 256-bit output, //! keys by using one of the built-in crypto hashes that has a 256-bit output,
//! e.g. KECCAK, SHA2 or BLAKE2. For technical reasons we should prepend the //! e.g. KECCAK, SHA-2 or BLAKE-2. For technical reasons we should prepend the
//! bytes of the 32-bit key by some unique byte sequence, e.g.: //! bytes of the 32-bit key by some unique byte sequence, e.g.:
//! ```no_compile //! ```no_compile
//! let key256 = blake2x256(b"DYNAMICALLY ALLOCATED", bytes(key32)); //! let key256 = blake2x256(b"DYNAMICALLY ALLOCATED", bytes(key32));
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
//! //!
//! # Internals //! # Internals
//! //!
//! As described in [# Simplification] there are 2^32 possible uniform dynamic //! As described in [# Simplification] there are `2^32` possible uniform dynamic
//! allocations available. For each such slot the dynamic allocator stores via //! allocations available. For each such slot the dynamic allocator stores via
//! a single bit in a bitvector if that slot is free or occupied. //! a single bit in a bitvector if that slot is free or occupied.
//! This bitvector is called the `free` list. //! This bitvector is called the `free` list.
...@@ -108,7 +108,7 @@ pub fn free(allocation: DynamicAllocation) { ...@@ -108,7 +108,7 @@ pub fn free(allocation: DynamicAllocation) {
/// in contract instantiations and calls. /// in contract instantiations and calls.
/// - This has to be issued before the first interaction with the global allocator. /// - This has to be issued before the first interaction with the global allocator.
/// - The actual instantiation will happen only upon the first interaction with /// - The actual instantiation will happen only upon the first interaction with
/// the global allocator, e.g. using its `alloc` or `free` calls. Until then /// the global allocator, e.g. using the `alloc` or `free` calls. Until then,
/// it remains uninitialized. /// it remains uninitialized.
/// ///
/// If this function is not called before the first global allocator interaction /// If this function is not called before the first global allocator interaction
......
...@@ -50,7 +50,7 @@ pub(super) enum ChildPosition { ...@@ -50,7 +50,7 @@ pub(super) enum ChildPosition {
/// contain one element (the root element). /// contain one element (the root element).
pub(super) const CHILDREN_PER_NODE: u32 = 2; pub(super) const CHILDREN_PER_NODE: u32 = 2;
/// Returns the index of the `Children` object in which the `n`-th element of /// Returns the index of the `Children` object in which the nth element of
/// the heap is stored. /// the heap is stored.
pub(super) fn get_children_storage_index(n: u32) -> u32 { pub(super) fn get_children_storage_index(n: u32) -> u32 {
if n == 0 { if n == 0 {
...@@ -63,7 +63,7 @@ pub(super) fn get_children_storage_index(n: u32) -> u32 { ...@@ -63,7 +63,7 @@ pub(super) fn get_children_storage_index(n: u32) -> u32 {
(n + padding) / CHILDREN_PER_NODE (n + padding) / CHILDREN_PER_NODE
} }
/// Returns the `ChildPosition` of the `n`-th heap element. /// Returns the `ChildPosition` of the nth heap element.
/// ///
/// For example, the element `3` is found at the child position `0` /// For example, the element `3` is found at the child position `0`
/// (within the `Children` object at storage index `2`). /// (within the `Children` object at storage index `2`).
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
//! Provides an interface around the vector used to store elements of the //! Provides an interface around the vector used to store elements of the
//! [`BinaryHeap`](`super::BinaryHeap`) in storage. This is necessary since //! [`BinaryHeap`](`super::BinaryHeap`) in storage. This is necessary since
//! we don't just store each element in it's own storage cell, but rather //! we don't just store each element in its own storage cell, but rather
//! optimize storage access by putting children together in one storage cell. //! optimize storage access by putting children together in one storage cell.
use super::{ use super::{
...@@ -35,7 +35,7 @@ use crate::{ ...@@ -35,7 +35,7 @@ use crate::{
/// ///
/// Elements of the heap are stored in a vector of `Children` objects, whereby /// Elements of the heap are stored in a vector of `Children` objects, whereby
/// each `Children` object contains two elements. When operating on indices of /// each `Children` object contains two elements. When operating on indices of
/// the `BinaryHeap` this interface transposes heap indices to the child inside /// the `BinaryHeap`, this interface transposes heap indices to the child inside
/// the `Children` object, in which the element is stored. /// the `Children` object, in which the element is stored.
#[derive(Default, PartialEq, Eq, Debug)] #[derive(Default, PartialEq, Eq, Debug)]
pub struct ChildrenVec<T> pub struct ChildrenVec<T>
...@@ -73,7 +73,7 @@ pub(super) struct ChildInfoMut<'a, T> { ...@@ -73,7 +73,7 @@ pub(super) struct ChildInfoMut<'a, T> {
/// This property exists only in `ChildInfoMut`, but not in `ChildInfo`. /// This property exists only in `ChildInfoMut`, but not in `ChildInfo`.
/// The reason is that in the case of pop-ping a child from a `Children` /// The reason is that in the case of pop-ping a child from a `Children`
/// object we need to check if the child count of that object is `0` after /// object we need to check if the child count of that object is `0` after
/// the pop operation. In that case no children are left in the object /// the pop operation. In that case no children are left in the object,
/// and it can be removed altogether from the heap. /// and it can be removed altogether from the heap.
pub child_count: usize, pub child_count: usize,
} }
...@@ -98,7 +98,7 @@ where ...@@ -98,7 +98,7 @@ where
} }
} }
/// Returns the number of elements in the heap, also referred to as its 'length'. /// Returns the number of elements in the heap, also referred to as its length.
#[inline] #[inline]
pub fn len(&self) -> u32 { pub fn len(&self) -> u32 {
*self.len *self.len
......
...@@ -41,8 +41,8 @@ pub use reverse::Reverse; ...@@ -41,8 +41,8 @@ pub use reverse::Reverse;
/// ///
/// The heap is a *max-heap* by default, i.e. the first element is the largest. /// The heap is a *max-heap* by default, i.e. the first element is the largest.
/// Either [`Reverse`] or a custom `Ord` implementation can be used to /// Either [`Reverse`] or a custom `Ord` implementation can be used to
/// make `BinaryHeap` a *min-heap*. This makes `heap.pop()` return the smallest /// make `BinaryHeap` a *min-heap*. This then makes `heap.pop()` return the
/// value instead of the largest one. /// smallest value instead of the largest one.
#[derive(Default, PartialEq, Eq, Debug)] #[derive(Default, PartialEq, Eq, Debug)]
pub struct BinaryHeap<T> pub struct BinaryHeap<T>
where where
...@@ -63,7 +63,7 @@ where ...@@ -63,7 +63,7 @@ where
} }
} }
/// Returns the number of elements in the heap, also referred to as its 'length'. /// Returns the number of elements in the heap, also referred to as its length.
pub fn len(&self) -> u32 { pub fn len(&self) -> u32 {
self.elements.len() self.elements.len()
} }
...@@ -211,8 +211,8 @@ where ...@@ -211,8 +211,8 @@ where
/// If `true`, on `drop()` will sift the peeked value down the tree if after mutation it is no /// If `true`, on `drop()` will sift the peeked value down the tree if after mutation it is no
/// longer the largest value, in order to keep the heap in a consistent state. /// longer the largest value, in order to keep the heap in a consistent state.
/// ///
/// If the peeked value is consumed via `PeekMut::pop()` then this is set to false to prevent /// If the peeked value is consumed via `PeekMut::pop()` then this is set to false in order
/// a redundant reorg which would already have happened via `BinaryHeap::pop()`. /// to prevent a redundant reorg which would already have happened via `BinaryHeap::pop()`.
sift: bool, sift: bool,
} }
......
...@@ -20,7 +20,7 @@ use super::BitStash; ...@@ -20,7 +20,7 @@ use super::BitStash;
/// ///
/// For each odd `x` in `xs` a number of put operations are executed. /// For each odd `x` in `xs` a number of put operations are executed.
/// For each even `x` it is asserted that the previously inserted elements /// For each even `x` it is asserted that the previously inserted elements
/// are in the stash and they are taken out subsequently. /// are in the stash, and they are taken out subsequently.
/// ///
/// The reasoning behind this even/odd sequence is to introduce some /// The reasoning behind this even/odd sequence is to introduce some
/// randomness into when elements are inserted/removed. /// randomness into when elements are inserted/removed.
......
...@@ -50,7 +50,7 @@ pub struct BitStash { ...@@ -50,7 +50,7 @@ pub struct BitStash {
/// represent 256 different states but since we consider 0 we need an extra /// represent 256 different states but since we consider 0 we need an extra
/// 9th bit. This 9th bit tells for every 256-bit chunk if it is full. /// 9th bit. This 9th bit tells for every 256-bit chunk if it is full.
/// ///
/// In theory it is possible to search up to 8192 storage cells for free