1
Fork 0

Add popcount and popcnt as doc aliases for count_ones methods.

Integer types have a `count_ones` method that end up calling
`intrinsics::ctpop`.
On some architectures, that intrinsic is translated as a corresponding
CPU instruction know as "popcount" or "popcnt".

This PR makes it so that searching for those names in rustdoc shows those methods.

CC https://blog.rust-lang.org/2020/11/19/Rust-1.48.html#adding-search-aliases
This commit is contained in:
Simon Sapin 2020-12-16 23:51:18 +01:00
parent b32e6e6ac8
commit f365de353a
3 changed files with 6 additions and 0 deletions

View file

@ -92,6 +92,8 @@ $EndFeature, "
"),
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[doc(alias = "popcount")]
#[doc(alias = "popcnt")]
#[inline]
pub const fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() }
}