Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "length" as doc alias to len methods #80430

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/alloc/src/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ impl<T> BinaryHeap<T> {
///
/// assert_eq!(heap.len(), 2);
/// ```
#[doc(alias = "length")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
self.data.len()
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,7 @@ impl<K, V> BTreeMap<K, V> {
/// a.insert(1, "a");
/// assert_eq!(a.len(), 1);
/// ```
#[doc(alias = "length")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
pub const fn len(&self) -> usize {
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ impl<T> BTreeSet<T> {
/// v.insert(1);
/// assert_eq!(v.len(), 1);
/// ```
#[doc(alias = "length")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
pub const fn len(&self) -> usize {
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ impl<T> LinkedList<T> {
/// dl.push_back(3);
/// assert_eq!(dl.len(), 3);
/// ```
#[doc(alias = "length")]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ impl<T> VecDeque<T> {
/// v.push_back(1);
/// assert_eq!(v.len(), 1);
/// ```
#[doc(alias = "length")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
count(self.tail, self.head, self.cap())
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ impl String {
/// assert_eq!(fancy_f.len(), 4);
/// assert_eq!(fancy_f.chars().count(), 3);
/// ```
#[doc(alias = "length")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think an additional bytes_len would be good here since it reflects that? I am not sure if anyone would type that out, if we put it it may be hidden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust documentation system doesn't render aliases unless you are directly searching for them, and I don't think anyone would type bytes_len specifically.

#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ impl<T, A: Allocator> Vec<T, A> {
/// let a = vec![1, 2, 3];
/// assert_eq!(a.len(), 3);
/// ```
#[doc(alias = "length")]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
Expand Down
1 change: 1 addition & 0 deletions library/core/src/iter/traits/exact_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub trait ExactSizeIterator: Iterator {
///
/// assert_eq!(5, five.len());
/// ```
#[doc(alias = "length")]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn len(&self) -> usize {
Expand Down
1 change: 1 addition & 0 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl<T> [T] {
/// let a = [1, 2, 3];
/// assert_eq!(a.len(), 3);
/// ```
#[doc(alias = "length")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_slice_len", since = "1.32.0")]
#[inline]
Expand Down
1 change: 1 addition & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl str {
/// assert_eq!("ƒoo".len(), 4); // fancy f!
/// assert_eq!("ƒoo".chars().count(), 3);
/// ```
#[doc(alias = "length")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_str_len", since = "1.32.0")]
#[inline]
Expand Down
1 change: 1 addition & 0 deletions library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ impl<K, V, S> HashMap<K, V, S> {
/// a.insert(1, "a");
/// assert_eq!(a.len(), 1);
/// ```
#[doc(alias = "length")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
self.base.len()
Expand Down
1 change: 1 addition & 0 deletions library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ impl<T, S> HashSet<T, S> {
/// v.insert(1);
/// assert_eq!(v.len(), 1);
/// ```
#[doc(alias = "length")]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ impl OsStr {
/// let os_str = OsStr::new("foo");
/// assert_eq!(os_str.len(), 3);
/// ```
#[doc(alias = "length")]
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
pub fn len(&self) -> usize {
self.inner.inner.len()
Expand Down