Skip to content

Commit

Permalink
docs: Improve doc formatting with backticks
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys committed Sep 17, 2024
1 parent 6328647 commit 5b0ed20
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ impl<K, V, S> IndexMap<K, V, S> {

/// Get a key-value pair by index
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
Expand All @@ -1158,7 +1158,7 @@ impl<K, V, S> IndexMap<K, V, S> {

/// Get a key-value pair by index
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
pub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)> {
Expand All @@ -1167,7 +1167,7 @@ impl<K, V, S> IndexMap<K, V, S> {

/// Get an entry in the map by index for in-place manipulation.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
pub fn get_index_entry(&mut self, index: usize) -> Option<IndexedEntry<'_, K, V>> {
Expand All @@ -1179,7 +1179,7 @@ impl<K, V, S> IndexMap<K, V, S> {

/// Returns a slice of key-value pairs in the given range of indices.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
pub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Slice<K, V>> {
Expand All @@ -1190,7 +1190,7 @@ impl<K, V, S> IndexMap<K, V, S> {

/// Returns a mutable slice of key-value pairs in the given range of indices.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
pub fn get_range_mut<R: RangeBounds<usize>>(&mut self, range: R) -> Option<&mut Slice<K, V>> {
Expand Down Expand Up @@ -1245,7 +1245,7 @@ impl<K, V, S> IndexMap<K, V, S> {

/// Remove the key-value pair by index
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Like [`Vec::swap_remove`], the pair is removed by swapping it with the
/// last element of the map and popping it off. **This perturbs
Expand All @@ -1258,7 +1258,7 @@ impl<K, V, S> IndexMap<K, V, S> {

/// Remove the key-value pair by index
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Like [`Vec::remove`], the pair is removed by shifting all of the
/// elements that follow it, preserving their relative order.
Expand Down
2 changes: 1 addition & 1 deletion src/map/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait MutableKeys: private::Sealed {

/// Return mutable reference to key and value at an index.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
fn get_index_mut2(&mut self, index: usize) -> Option<(&mut Self::Key, &mut Self::Value)>;
Expand Down
8 changes: 4 additions & 4 deletions src/map/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,29 @@ impl<K, V> Slice<K, V> {

/// Get a key-value pair by index.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
pub fn get_index(&self, index: usize) -> Option<(&K, &V)> {
self.entries.get(index).map(Bucket::refs)
}

/// Get a key-value pair by index, with mutable access to the value.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
pub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)> {
self.entries.get_mut(index).map(Bucket::ref_mut)
}

/// Returns a slice of key-value pairs in the given range of indices.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
pub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Self> {
let range = try_simplify_range(range, self.entries.len())?;
self.entries.get(range).map(Slice::from_slice)
}

/// Returns a mutable slice of key-value pairs in the given range of indices.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
pub fn get_range_mut<R: RangeBounds<usize>>(&mut self, range: R) -> Option<&mut Self> {
let range = try_simplify_range(range, self.entries.len())?;
self.entries.get_mut(range).map(Slice::from_mut_slice)
Expand Down
8 changes: 4 additions & 4 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ impl<T, S> IndexSet<T, S> {

/// Get a value by index
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
pub fn get_index(&self, index: usize) -> Option<&T> {
Expand All @@ -992,7 +992,7 @@ impl<T, S> IndexSet<T, S> {

/// Returns a slice of values in the given range of indices.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
pub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Slice<T>> {
Expand All @@ -1017,7 +1017,7 @@ impl<T, S> IndexSet<T, S> {

/// Remove the value by index
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Like [`Vec::swap_remove`], the value is removed by swapping it with the
/// last element of the set and popping it off. **This perturbs
Expand All @@ -1030,7 +1030,7 @@ impl<T, S> IndexSet<T, S> {

/// Remove the value by index
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Like [`Vec::remove`], the value is removed by shifting all of the
/// elements that follow it, preserving their relative order.
Expand Down
2 changes: 1 addition & 1 deletion src/set/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait MutableValues: private::Sealed {

/// Return mutable reference to the value at an index.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
///
/// Computes in **O(1)** time.
fn get_index_mut2(&mut self, index: usize) -> Option<&mut Self::Value>;
Expand Down
4 changes: 2 additions & 2 deletions src/set/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ impl<T> Slice<T> {

/// Get a value by index.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
pub fn get_index(&self, index: usize) -> Option<&T> {
self.entries.get(index).map(Bucket::key_ref)
}

/// Returns a slice of values in the given range of indices.
///
/// Valid indices are *0 <= index < self.len()*
/// Valid indices are `0 <= index < self.len()`.
pub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Self> {
let range = try_simplify_range(range, self.entries.len())?;
self.entries.get(range).map(Self::from_slice)
Expand Down

0 comments on commit 5b0ed20

Please sign in to comment.