this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix clippy issues (#681)

# Objective

Fix the clippy errors in the CI

# Solution

- Run `cargo +stable clippy --workspace --no-deps --all-features
--all-targets --fix -- -D warnings` multiple times
- Add `#[allow(clippy::large_stack_arrays)]`
https://github.com/valence-rs/valence/blob/8f3f84d557dacddd7faddb2ad724185ecee2e482/crates/valence_generated/build/block.rs#L695
- Replace every triple slash comment in `valence_generated` and
`valence_entity` with `#[doc]`
- Replace eliding `'a` lifetimes in `stresser.rs` with a single `'_`

authored by

Cheezer1656 and committed by
GitHub
58633af7 8f3f84d5

+238 -245
+1 -1
benches/packet.rs
··· 21 21 let encoder = PacketEncoder::new(); 22 22 23 23 const BLOCKS_AND_BIOMES: [u8; 2000] = [0x80; 2000]; 24 - const SKY_LIGHT_ARRAYS: [FixedArray<u8, 2048>; 26] = [FixedArray([0xff; 2048]); 26]; 24 + static SKY_LIGHT_ARRAYS: [FixedArray<u8, 2048>; 26] = [FixedArray([0xff; 2048]); 26]; 25 25 26 26 let chunk_data_packet = ChunkDataS2c { 27 27 pos: ChunkPos::new(123, 456),
+1 -1
crates/java_string/src/cesu8.rs
··· 242 242 243 243 #[inline] 244 244 fn dec_surrogate(second: u8, third: u8) -> u32 { 245 - 0xd000 | u32::from(second & CONT_MASK) << 6 | u32::from(third & CONT_MASK) 245 + 0xd000 | (u32::from(second & CONT_MASK) << 6) | u32::from(third & CONT_MASK) 246 246 } 247 247 248 248 #[inline]
+6 -6
crates/java_string/src/char.rs
··· 202 202 *a = code as u8; 203 203 } 204 204 (2, [a, b, ..]) => { 205 - *a = (code >> 6 & 0x1f) as u8 | TAG_TWO_B; 205 + *a = ((code >> 6) & 0x1f) as u8 | TAG_TWO_B; 206 206 *b = (code & 0x3f) as u8 | TAG_CONT; 207 207 } 208 208 (3, [a, b, c, ..]) => { 209 - *a = (code >> 12 & 0x0f) as u8 | TAG_THREE_B; 210 - *b = (code >> 6 & 0x3f) as u8 | TAG_CONT; 209 + *a = ((code >> 12) & 0x0f) as u8 | TAG_THREE_B; 210 + *b = ((code >> 6) & 0x3f) as u8 | TAG_CONT; 211 211 *c = (code & 0x3f) as u8 | TAG_CONT; 212 212 } 213 213 (4, [a, b, c, d, ..]) => { 214 - *a = (code >> 18 & 0x07) as u8 | TAG_FOUR_B; 215 - *b = (code >> 12 & 0x3f) as u8 | TAG_CONT; 216 - *c = (code >> 6 & 0x3f) as u8 | TAG_CONT; 214 + *a = ((code >> 18) & 0x07) as u8 | TAG_FOUR_B; 215 + *b = ((code >> 12) & 0x3f) as u8 | TAG_CONT; 216 + *c = ((code >> 6) & 0x3f) as u8 | TAG_CONT; 217 217 *d = (code & 0x3f) as u8 | TAG_CONT; 218 218 } 219 219 _ => panic!(
+24 -27
crates/java_string/src/iter.rs
··· 140 140 } 141 141 delegate!(Iterator for EscapeDebug<'a> => char); 142 142 delegate!(FusedIterator for EscapeDebug<'a>); 143 - impl<'a> Display for EscapeDebug<'a> { 143 + impl Display for EscapeDebug<'_> { 144 144 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 145 145 self.clone().try_for_each(|c| f.write_char(c)) 146 146 } ··· 153 153 } 154 154 delegate!(Iterator for EscapeDefault<'a> => char); 155 155 delegate!(FusedIterator for EscapeDefault<'a>); 156 - impl<'a> Display for EscapeDefault<'a> { 156 + impl Display for EscapeDefault<'_> { 157 157 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 158 158 self.clone().try_for_each(|c| f.write_char(c)) 159 159 } ··· 166 166 } 167 167 delegate!(Iterator for EscapeUnicode<'a> => char); 168 168 delegate!(FusedIterator for EscapeUnicode<'a>); 169 - impl<'a> Display for EscapeUnicode<'a> { 169 + impl Display for EscapeUnicode<'_> { 170 170 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { 171 171 self.clone().try_for_each(|c| f.write_char(c)) 172 172 } ··· 187 187 pub(crate) inner: slice::Iter<'a, u8>, 188 188 } 189 189 190 - impl<'a> Iterator for Chars<'a> { 190 + impl Iterator for Chars<'_> { 191 191 type Item = JavaCodePoint; 192 192 193 193 #[inline] ··· 203 203 #[inline] 204 204 fn size_hint(&self) -> (usize, Option<usize>) { 205 205 let len = self.inner.len(); 206 - // `(len + 3)` can't overflow, because we know that the `slice::Iter` 207 - // belongs to a slice in memory which has a maximum length of 208 - // `isize::MAX` (that's well below `usize::MAX`). 209 - ((len + 3) / 4, Some(len)) 206 + (len.div_ceil(4), Some(len)) 210 207 } 211 208 212 209 #[inline] ··· 225 222 } 226 223 } 227 224 228 - impl<'a> DoubleEndedIterator for Chars<'a> { 225 + impl DoubleEndedIterator for Chars<'_> { 229 226 #[inline] 230 227 fn next_back(&mut self) -> Option<Self::Item> { 231 228 // SAFETY: `JavaStr` invariant says `self.inner` is a semi-valid UTF-8 string ··· 256 253 pub(crate) inner: Chars<'a>, 257 254 } 258 255 259 - impl<'a> Iterator for CharIndices<'a> { 256 + impl Iterator for CharIndices<'_> { 260 257 type Item = (usize, JavaCodePoint); 261 258 262 259 #[inline] ··· 290 287 } 291 288 } 292 289 293 - impl<'a> DoubleEndedIterator for CharIndices<'a> { 290 + impl DoubleEndedIterator for CharIndices<'_> { 294 291 #[inline] 295 292 fn next_back(&mut self) -> Option<(usize, JavaCodePoint)> { 296 293 self.inner.next_back().map(|ch| { ··· 337 334 } 338 335 } 339 336 340 - impl<'a, P> DoubleEndedIterator for Matches<'a, P> 337 + impl<P> DoubleEndedIterator for Matches<'_, P> 341 338 where 342 339 P: JavaStrPattern, 343 340 { ··· 373 370 } 374 371 } 375 372 376 - impl<'a, P> DoubleEndedIterator for RMatches<'a, P> 373 + impl<P> DoubleEndedIterator for RMatches<'_, P> 377 374 where 378 375 P: JavaStrPattern, 379 376 { ··· 414 411 } 415 412 } 416 413 417 - impl<'a, P> DoubleEndedIterator for MatchIndices<'a, P> 414 + impl<P> DoubleEndedIterator for MatchIndices<'_, P> 418 415 where 419 416 P: JavaStrPattern, 420 417 { ··· 449 446 } 450 447 } 451 448 452 - impl<'a, P> DoubleEndedIterator for RMatchIndices<'a, P> 449 + impl<P> DoubleEndedIterator for RMatchIndices<'_, P> 453 450 where 454 451 P: JavaStrPattern, 455 452 { ··· 693 690 } 694 691 } 695 692 696 - impl<'a, P> DoubleEndedIterator for Split<'a, P> 693 + impl<P> DoubleEndedIterator for Split<'_, P> 697 694 where 698 695 P: JavaStrPattern, 699 696 { ··· 703 700 } 704 701 } 705 702 706 - impl<'a, P> FusedIterator for Split<'a, P> where P: JavaStrPattern {} 703 + impl<P> FusedIterator for Split<'_, P> where P: JavaStrPattern {} 707 704 708 705 #[derive(Clone, Debug)] 709 706 pub struct RSplit<'a, P> { ··· 734 731 } 735 732 } 736 733 737 - impl<'a, P> DoubleEndedIterator for RSplit<'a, P> 734 + impl<P> DoubleEndedIterator for RSplit<'_, P> 738 735 where 739 736 P: JavaStrPattern, 740 737 { ··· 744 741 } 745 742 } 746 743 747 - impl<'a, P> FusedIterator for RSplit<'a, P> where P: JavaStrPattern {} 744 + impl<P> FusedIterator for RSplit<'_, P> where P: JavaStrPattern {} 748 745 749 746 #[derive(Clone, Debug)] 750 747 pub struct SplitTerminator<'a, P> { ··· 775 772 } 776 773 } 777 774 778 - impl<'a, P> DoubleEndedIterator for SplitTerminator<'a, P> 775 + impl<P> DoubleEndedIterator for SplitTerminator<'_, P> 779 776 where 780 777 P: JavaStrPattern, 781 778 { ··· 785 782 } 786 783 } 787 784 788 - impl<'a, P> FusedIterator for SplitTerminator<'a, P> where P: JavaStrPattern {} 785 + impl<P> FusedIterator for SplitTerminator<'_, P> where P: JavaStrPattern {} 789 786 790 787 #[derive(Clone, Debug)] 791 788 pub struct RSplitTerminator<'a, P> { ··· 816 813 } 817 814 } 818 815 819 - impl<'a, P> DoubleEndedIterator for RSplitTerminator<'a, P> 816 + impl<P> DoubleEndedIterator for RSplitTerminator<'_, P> 820 817 where 821 818 P: JavaStrPattern, 822 819 { ··· 826 823 } 827 824 } 828 825 829 - impl<'a, P> FusedIterator for RSplitTerminator<'a, P> where P: JavaStrPattern {} 826 + impl<P> FusedIterator for RSplitTerminator<'_, P> where P: JavaStrPattern {} 830 827 831 828 #[derive(Clone, Debug)] 832 829 pub struct SplitInclusive<'a, P> { ··· 857 854 } 858 855 } 859 856 860 - impl<'a, P> DoubleEndedIterator for SplitInclusive<'a, P> 857 + impl<P> DoubleEndedIterator for SplitInclusive<'_, P> 861 858 where 862 859 P: JavaStrPattern, 863 860 { ··· 867 864 } 868 865 } 869 866 870 - impl<'a, P> FusedIterator for SplitInclusive<'a, P> where P: JavaStrPattern {} 867 + impl<P> FusedIterator for SplitInclusive<'_, P> where P: JavaStrPattern {} 871 868 872 869 #[derive(Clone, Debug)] 873 870 pub struct SplitN<'a, P> { ··· 910 907 } 911 908 } 912 909 913 - impl<'a, P> FusedIterator for SplitN<'a, P> where P: JavaStrPattern {} 910 + impl<P> FusedIterator for SplitN<'_, P> where P: JavaStrPattern {} 914 911 915 912 #[derive(Clone, Debug)] 916 913 pub struct RSplitN<'a, P> { ··· 953 950 } 954 951 } 955 952 956 - impl<'a, P> FusedIterator for RSplitN<'a, P> where P: JavaStrPattern {} 953 + impl<P> FusedIterator for RSplitN<'_, P> where P: JavaStrPattern {} 957 954 958 955 #[derive(Clone, Debug)] 959 956 pub struct SplitAsciiWhitespace<'a> {
+5 -5
crates/java_string/src/owned.rs
··· 394 394 del_bytes: usize, 395 395 } 396 396 397 - impl<'a> Drop for SetLenOnDrop<'a> { 397 + impl Drop for SetLenOnDrop<'_> { 398 398 #[inline] 399 399 fn drop(&mut self) { 400 400 let new_len = self.idx - self.del_bytes; ··· 959 959 } 960 960 } 961 961 962 - impl<'a> From<JavaString> for Cow<'a, JavaStr> { 962 + impl From<JavaString> for Cow<'_, JavaStr> { 963 963 #[inline] 964 964 fn from(value: JavaString) -> Self { 965 965 Cow::Owned(value) ··· 1240 1240 } 1241 1241 } 1242 1242 1243 - impl<'a> PartialEq<JavaString> for &'a str { 1243 + impl PartialEq<JavaString> for &str { 1244 1244 #[inline] 1245 1245 fn eq(&self, other: &JavaString) -> bool { 1246 1246 *self == other ··· 1282 1282 } 1283 1283 } 1284 1284 1285 - impl<'a> PartialEq<JavaString> for Cow<'a, str> { 1285 + impl PartialEq<JavaString> for Cow<'_, str> { 1286 1286 #[inline] 1287 1287 fn eq(&self, other: &JavaString) -> bool { 1288 1288 self == &other[..] ··· 1296 1296 } 1297 1297 } 1298 1298 1299 - impl<'a> PartialEq<JavaString> for Cow<'a, JavaStr> { 1299 + impl PartialEq<JavaString> for Cow<'_, JavaStr> { 1300 1300 #[inline] 1301 1301 fn eq(&self, other: &JavaString) -> bool { 1302 1302 self == &other[..]
+1 -1
crates/java_string/src/serde.rs
··· 163 163 164 164 struct JavaCodePointVisitor; 165 165 166 - impl<'de> Visitor<'de> for JavaCodePointVisitor { 166 + impl Visitor<'_> for JavaCodePointVisitor { 167 167 type Value = JavaCodePoint; 168 168 169 169 fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
+11 -11
crates/java_string/src/slice.rs
··· 1679 1679 } 1680 1680 } 1681 1681 1682 - impl<'a> AddAssign<&JavaStr> for Cow<'a, JavaStr> { 1682 + impl AddAssign<&JavaStr> for Cow<'_, JavaStr> { 1683 1683 #[inline] 1684 1684 fn add_assign(&mut self, rhs: &JavaStr) { 1685 1685 if !rhs.is_empty() { ··· 1881 1881 } 1882 1882 } 1883 1883 1884 - impl<'a, 'b> PartialEq<&'b JavaStr> for Cow<'a, str> { 1884 + impl<'b> PartialEq<&'b JavaStr> for Cow<'_, str> { 1885 1885 #[inline] 1886 1886 fn eq(&self, other: &&'b JavaStr) -> bool { 1887 1887 self == *other 1888 1888 } 1889 1889 } 1890 1890 1891 - impl<'a, 'b> PartialEq<&'b JavaStr> for Cow<'a, JavaStr> { 1891 + impl<'b> PartialEq<&'b JavaStr> for Cow<'_, JavaStr> { 1892 1892 #[inline] 1893 1893 fn eq(&self, other: &&'b JavaStr) -> bool { 1894 1894 self == *other 1895 1895 } 1896 1896 } 1897 1897 1898 - impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b JavaStr { 1898 + impl<'a> PartialEq<Cow<'a, str>> for &JavaStr { 1899 1899 #[inline] 1900 1900 fn eq(&self, other: &Cow<'a, str>) -> bool { 1901 1901 *self == other ··· 1909 1909 } 1910 1910 } 1911 1911 1912 - impl<'a, 'b> PartialEq<Cow<'a, JavaStr>> for &'b JavaStr { 1912 + impl<'a> PartialEq<Cow<'a, JavaStr>> for &JavaStr { 1913 1913 #[inline] 1914 1914 fn eq(&self, other: &Cow<'a, JavaStr>) -> bool { 1915 1915 *self == other ··· 1923 1923 } 1924 1924 } 1925 1925 1926 - impl<'a> PartialEq<String> for &'a JavaStr { 1926 + impl PartialEq<String> for &JavaStr { 1927 1927 #[inline] 1928 1928 fn eq(&self, other: &String) -> bool { 1929 1929 *self == other ··· 1944 1944 } 1945 1945 } 1946 1946 1947 - impl<'a> PartialEq<JavaString> for &'a JavaStr { 1947 + impl PartialEq<JavaString> for &JavaStr { 1948 1948 #[inline] 1949 1949 fn eq(&self, other: &JavaString) -> bool { 1950 1950 *self == other ··· 1958 1958 } 1959 1959 } 1960 1960 1961 - impl<'a> PartialEq<JavaStr> for Cow<'a, str> { 1961 + impl PartialEq<JavaStr> for Cow<'_, str> { 1962 1962 #[inline] 1963 1963 fn eq(&self, other: &JavaStr) -> bool { 1964 1964 match self { ··· 1968 1968 } 1969 1969 } 1970 1970 1971 - impl<'a> PartialEq<JavaStr> for Cow<'a, JavaStr> { 1971 + impl PartialEq<JavaStr> for Cow<'_, JavaStr> { 1972 1972 #[inline] 1973 1973 fn eq(&self, other: &JavaStr) -> bool { 1974 1974 match self { ··· 1985 1985 } 1986 1986 } 1987 1987 1988 - impl<'a> PartialEq<JavaStr> for &'a str { 1988 + impl PartialEq<JavaStr> for &str { 1989 1989 #[inline] 1990 1990 fn eq(&self, other: &JavaStr) -> bool { 1991 1991 self.as_bytes() == &other.inner ··· 2006 2006 } 2007 2007 } 2008 2008 2009 - impl<'a> PartialEq<JavaStr> for &'a JavaStr { 2009 + impl PartialEq<JavaStr> for &JavaStr { 2010 2010 #[inline] 2011 2011 fn eq(&self, other: &JavaStr) -> bool { 2012 2012 self.inner == other.inner
+2 -2
crates/java_string/src/validations.rs
··· 49 49 // so the iterator must produce a value here. 50 50 let z = unsafe { *bytes.next().unwrap_unchecked() }; 51 51 let y_z = utf8_acc_cont_byte((y & CONT_MASK).into(), z); 52 - ch = init << 12 | y_z; 52 + ch = (init << 12) | y_z; 53 53 if x >= 0xf0 { 54 54 // [x y z w] case 55 55 // use only the lower 3 bits of `init` 56 56 // SAFETY: `bytes` produces an UTF-8-like string, 57 57 // so the iterator must produce a value here. 58 58 let w = unsafe { *bytes.next().unwrap_unchecked() }; 59 - ch = (init & 7) << 18 | utf8_acc_cont_byte(y_z, w); 59 + ch = ((init & 7) << 18) | utf8_acc_cont_byte(y_z, w); 60 60 } 61 61 } 62 62
+3 -3
crates/valence_advancement/src/lib.rs
··· 87 87 criteria_query: Query<'w, 's, &'static AdvancementCriteria>, 88 88 } 89 89 90 - impl<'w, 's> UpdateAdvancementCachedBytesQuery<'w, 's> { 90 + impl UpdateAdvancementCachedBytesQuery<'_, '_> { 91 91 fn write( 92 92 &self, 93 93 a_identifier: &Advancement, ··· 201 201 queries: &'a SingleAdvancementUpdateQuery<'w, 's>, 202 202 } 203 203 204 - impl<'w, 's, 'a> Encode for AdvancementUpdateEncodeS2c<'w, 's, 'a> { 204 + impl Encode for AdvancementUpdateEncodeS2c<'_, '_, '_> { 205 205 fn encode(&self, w: impl Write) -> anyhow::Result<()> { 206 206 let SingleAdvancementUpdateQuery { 207 207 advancement_bytes: advancement_bytes_query, ··· 264 264 } 265 265 } 266 266 267 - impl<'w, 's, 'a> Packet for AdvancementUpdateEncodeS2c<'w, 's, 'a> { 267 + impl Packet for AdvancementUpdateEncodeS2c<'_, '_, '_> { 268 268 const ID: i32 = packet_id::ADVANCEMENT_UPDATE_S2C; 269 269 const NAME: &'static str = "AdvancementUpdateEncodeS2c"; 270 270 const SIDE: PacketSide = PacketSide::Clientbound;
+2 -3
crates/valence_anvil/src/lib.rs
··· 568 568 } 569 569 let compress_buf = compress_cursor.into_inner(); 570 570 571 - // additional 5 bytes for exact chunk size + compression type, then add 572 - // SECTOR_SIZE - 1 for rounding up 573 - let num_sectors_needed = (compress_buf.len() + 5 + SECTOR_SIZE - 1) / SECTOR_SIZE; 571 + // additional 5 bytes for exact chunk size + compression type 572 + let num_sectors_needed = (compress_buf.len() + 5).div_ceil(SECTOR_SIZE); 574 573 let (start_sector, num_sectors) = if num_sectors_needed >= 256 { 575 574 if options.skip_oversized_chunks { 576 575 return Err(RegionError::OversizedChunk);
+5 -5
crates/valence_entity/build.rs
··· 608 608 } 609 609 610 610 systems.extend([quote! { 611 - /// Special case for `living::Absorption`. 612 - /// Updates the `AbsorptionAmount` component of the player entity. 611 + #[doc = "Special case for `living::Absorption`."] 612 + #[doc = "Updates the `AbsorptionAmount` component of the player entity."] 613 613 fn update_living_and_player_absorption( 614 614 mut query: Query<(&living::Absorption, &mut player::AbsorptionAmount), Changed<living::Absorption>> 615 615 ) { ··· 618 618 } 619 619 } 620 620 621 - /// Special case for `living::Attributes`. 621 + #[doc = "Special case for `living::Attributes`."] 622 622 fn update_living_attributes( 623 623 mut query: Query<( 624 624 &mut attributes::TrackedEntityAttributes, ··· 676 676 677 677 #modules 678 678 679 - /// Identifies the type of an entity. 680 - /// As a component, the entity kind should not be modified. 679 + #[doc = "Identifies the type of an entity."] 680 + #[doc = "As a component, the entity kind should not be modified."] 681 681 #[derive(Component, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, ::derive_more::Deref)] 682 682 pub struct EntityKind(i32); 683 683
+3 -3
crates/valence_entity/src/active_status_effects.rs
··· 70 70 pub fn no_effect(&self, effect: StatusEffect) -> bool { 71 71 self.current_effects 72 72 .get(&effect) 73 - .map_or(true, |effects| effects.is_empty()) 73 + .is_none_or(|effects| effects.is_empty()) 74 74 } 75 75 76 76 /// Returns true if there is an effect of the given type. 77 77 pub fn has_effect(&self, effect: StatusEffect) -> bool { 78 78 self.current_effects 79 79 .get(&effect) 80 - .map_or(false, |effects| !effects.is_empty()) 80 + .is_some_and(|effects| !effects.is_empty()) 81 81 } 82 82 83 83 /// Returns true if there are no effects. ··· 440 440 self.status_effect().instant() 441 441 || self 442 442 .remaining_duration() 443 - .map_or(false, |duration| duration <= 0) 443 + .is_some_and(|duration| duration <= 0) 444 444 } 445 445 } 446 446
+1 -1
crates/valence_entity/src/hitbox.rs
··· 300 300 EntityKind::GOAT => { 301 301 if pose_query 302 302 .get(entity) 303 - .map_or(false, |v| v.0 == Pose::LongJumping) 303 + .is_ok_and(|v| v.0 == Pose::LongJumping) 304 304 { 305 305 [0.63, 0.91, 0.63] 306 306 } else {
+6 -6
crates/valence_generated/build/attributes.rs
··· 79 79 } 80 80 81 81 Ok(quote!( 82 - /// An attribute modifier operation. 82 + #[doc = "An attribute modifier operation."] 83 83 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 84 84 pub enum EntityAttributeOperation { 85 - /// Adds the modifier to the base value. 85 + #[doc = "Adds the modifier to the base value."] 86 86 Add, 87 - /// Multiplies the modifier with the base value. 87 + #[doc = "Multiplies the modifier with the base value."] 88 88 MultiplyBase, 89 - /// Multiplies the modifier with the total value. 89 + #[doc = "Multiplies the modifier with the total value."] 90 90 MultiplyTotal, 91 91 } 92 92 93 93 impl EntityAttributeOperation { 94 - /// Converts from a raw [`u8`]. 94 + #[doc = "Converts from a raw [`u8`]."] 95 95 pub fn from_raw(raw: u8) -> Option<Self> { 96 96 match raw { 97 97 0 => Some(Self::Add), ··· 101 101 } 102 102 } 103 103 104 - /// Converts to a raw [`u8`]. 104 + #[doc = "Converts to a raw [`u8`]."] 105 105 pub fn to_raw(self) -> u8 { 106 106 match self { 107 107 Self::Add => 0,
+70 -69
crates/valence_generated/build/block.rs
··· 580 580 Ok(quote! { 581 581 use valence_math::{Aabb, DVec3}; 582 582 583 - /// Represents the state of a block. This does not include block entity data such as 584 - /// the text on a sign, the design on a banner, or the content of a spawner. 583 + #[doc = "Represents the state of a block. This does not include block entity data such as"] 584 + #[doc = "the text on a sign, the design on a banner, or the content of a spawner."] 585 585 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)] 586 586 pub struct BlockState(u16); 587 587 588 588 impl BlockState { 589 - /// Returns the default block state for a given block type. 589 + #[doc = "Returns the default block state for a given block type."] 590 590 pub const fn from_kind(kind: BlockKind) -> Self { 591 591 match kind { 592 592 #kind_to_state_arms 593 593 } 594 594 } 595 595 596 - /// Constructs a block state from a raw block state ID. 597 - /// 598 - /// If the given ID is invalid, `None` is returned. 596 + #[doc = "Constructs a block state from a raw block state ID."] 597 + #[doc = ""] 598 + #[doc = "If the given ID is invalid, `None` is returned."] 599 599 pub const fn from_raw(id: u16) -> Option<Self> { 600 600 if id <= #max_state_id { 601 601 Some(Self(id)) ··· 604 604 } 605 605 } 606 606 607 - /// Returns the [`BlockKind`] of this block state. 607 + #[doc = "Returns the [`BlockKind`] of this block state."] 608 608 pub const fn to_kind(self) -> BlockKind { 609 609 match self.0 { 610 610 #state_to_kind_arms ··· 612 612 } 613 613 } 614 614 615 - /// Converts this block state to its underlying raw block state ID. 616 - /// 617 - /// The original block state can be recovered with [`BlockState::from_raw`]. 615 + #[doc = "Converts this block state to its underlying raw block state ID."] 616 + #[doc = ""] 617 + #[doc = "The original block state can be recovered with [`BlockState::from_raw`]."] 618 618 pub const fn to_raw(self) -> u16 { 619 619 self.0 620 620 } 621 621 622 - /// Returns the maximum block state ID. 622 + #[doc = "Returns the maximum block state ID."] 623 623 pub const fn max_raw() -> u16 { 624 624 #max_state_id 625 625 } 626 626 627 - /// Returns the wall variant of the block state. 628 - /// 629 - /// If the given block state doesn't have a wall variant, `None` is returned. 627 + #[doc = "Returns the wall variant of the block state."] 628 + #[doc = ""] 629 + #[doc = "If the given block state doesn't have a wall variant, `None` is returned."] 630 630 pub const fn wall_block_id(self) -> Option<Self> { 631 631 match self { 632 632 #state_to_wall_variant_arms ··· 634 634 } 635 635 } 636 636 637 - /// Gets the value of the property with the given name from this block. 638 - /// 639 - /// If this block does not have the property, then `None` is returned. 637 + #[doc = "Gets the value of the property with the given name from this block."] 638 + #[doc = ""] 639 + #[doc = "If this block does not have the property, then `None` is returned."] 640 640 pub const fn get(self, name: PropName) -> Option<PropValue> { 641 641 match self.to_kind() { 642 642 #get_arms ··· 644 644 } 645 645 } 646 646 647 - /// Sets the value of a property on this block, returning the modified block. 648 - /// 649 - /// If this block does not have the given property or the property value is invalid, 650 - /// then the original block is returned unchanged. 647 + #[doc = "Sets the value of a property on this block, returning the modified block."] 648 + #[doc = ""] 649 + #[doc = "If this block does not have the given property or the property value is invalid,"] 650 + #[doc = "then the original block is returned unchanged."] 651 651 #[must_use] 652 652 pub const fn set(self, name: PropName, val: PropValue) -> Self { 653 653 match self.to_kind() { ··· 656 656 } 657 657 } 658 658 659 - /// If this block is `air`, `cave_air` or `void_air`. 659 + #[doc = "If this block is `air`, `cave_air` or `void_air`."] 660 660 pub const fn is_air(self) -> bool { 661 661 matches!( 662 662 self, ··· 666 666 667 667 // TODO: is_solid 668 668 669 - /// If this block is water or lava. 669 + #[doc = "If this block is water or lava."] 670 670 pub const fn is_liquid(self) -> bool { 671 671 matches!(self.to_kind(), BlockKind::Water | BlockKind::Lava) 672 672 } ··· 692 692 } 693 693 } 694 694 695 + #[allow(clippy::large_stack_arrays)] 695 696 const SHAPES: [Aabb; #shape_count] = [ 696 697 #(#shapes,)* 697 698 ]; ··· 727 728 #default_block_states 728 729 } 729 730 730 - /// An enumeration of all block kinds. 731 + #[doc = "An enumeration of all block kinds."] 731 732 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 732 733 pub enum BlockKind { 733 734 #(#block_kind_variants,)* 734 735 } 735 736 736 737 impl BlockKind { 737 - /// Construct a block kind from its snake_case name. 738 - /// 739 - /// Returns `None` if the name is invalid. 738 + #[doc = "Construct a block kind from its snake_case name."] 739 + #[doc = ""] 740 + #[doc = "Returns `None` if the name is invalid."] 740 741 pub fn from_str(name: &str) -> Option<Self> { 741 742 match name { 742 743 #block_kind_from_str_arms ··· 744 745 } 745 746 } 746 747 747 - /// Get the snake_case name of this block kind. 748 + #[doc = "Get the snake_case name of this block kind."] 748 749 pub const fn to_str(self) -> &'static str { 749 750 match self { 750 751 #block_kind_to_str_arms 751 752 } 752 753 } 753 754 754 - /// Returns the default block state for a given block kind. 755 + #[doc = "Returns the default block state for a given block kind."] 755 756 pub const fn to_state(self) -> BlockState { 756 757 BlockState::from_kind(self) 757 758 } 758 759 759 - /// Returns a slice of all properties this block kind has. 760 + #[doc = "Returns a slice of all properties this block kind has."] 760 761 pub const fn props(self) -> &'static [PropName] { 761 762 match self { 762 763 #block_kind_props_arms ··· 770 771 } 771 772 } 772 773 773 - /// Converts a block kind to its corresponding item kind. 774 - /// 775 - /// [`ItemKind::Air`] is used to indicate the absence of an item. 774 + #[doc = "Converts a block kind to its corresponding item kind."] 775 + #[doc = ""] 776 + #[doc = "[`ItemKind::Air`] is used to indicate the absence of an item."] 776 777 pub const fn to_item_kind(self) -> ItemKind { 777 778 let id = match self { 778 779 #block_kind_to_item_kind_arms ··· 785 786 } 786 787 } 787 788 788 - /// Constructs a block kind from an item kind. 789 - /// 790 - /// If the given item does not have a corresponding block, `None` is returned. 789 + #[doc = "Constructs a block kind from an item kind."] 790 + #[doc = ""] 791 + #[doc = "If the given item does not have a corresponding block, `None` is returned."] 791 792 pub const fn from_item_kind(item: ItemKind) -> Option<Self> { 792 793 // The "default" blocks are ordered before the other variants. 793 794 // For instance, `torch` comes before `wall_torch` so this match ··· 799 800 } 800 801 } 801 802 802 - /// Constructs a block kind from a raw block kind ID. 803 - /// 804 - /// If the given ID is invalid, `None` is returned. 803 + #[doc = "Constructs a block kind from a raw block kind ID."] 804 + #[doc = ""] 805 + #[doc = "If the given ID is invalid, `None` is returned."] 805 806 pub const fn from_raw(id: u16) -> Option<Self> { 806 807 match id { 807 808 #block_kind_from_raw_arms ··· 809 810 } 810 811 } 811 812 812 - /// Converts this block kind to its underlying raw block state ID. 813 - /// 814 - /// The original block kind can be recovered with [`BlockKind::from_raw`]. 813 + #[doc = "Converts this block kind to its underlying raw block state ID."] 814 + #[doc = ""] 815 + #[doc = "The original block kind can be recovered with [`BlockKind::from_raw`]."] 815 816 pub const fn to_raw(self) -> u16 { 816 817 self as u16 817 818 } 818 819 819 - /// An array of all block kinds. 820 + #[doc = "An array of all block kinds."] 820 821 pub const ALL: [Self; #block_kind_count] = [#(Self::#block_kind_variants,)*]; 821 822 } 822 823 823 - /// The default block kind is `air`. 824 + #[doc = "The default block kind is `air`."] 824 825 impl Default for BlockKind { 825 826 fn default() -> Self { 826 827 Self::Air 827 828 } 828 829 } 829 830 830 - /// Contains all possible block state property names. 831 - /// 832 - /// For example, `waterlogged`, `facing`, and `half` are all property names. 831 + #[doc = "Contains all possible block state property names."] 832 + #[doc = ""] 833 + #[doc = "For example, `waterlogged`, `facing`, and `half` are all property names."] 833 834 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 834 835 pub enum PropName { 835 836 #(#prop_name_variants,)* 836 837 } 837 838 838 839 impl PropName { 839 - /// Construct a property name from its snake_case name. 840 - /// 841 - /// Returns `None` if the given name is not valid. 840 + #[doc = "Construct a property name from its snake_case name."] 841 + #[doc = ""] 842 + #[doc = "Returns `None` if the given name is not valid."] 842 843 pub fn from_str(name: &str) -> Option<Self> { 843 844 // TODO: match on str in const fn. 844 845 match name { ··· 847 848 } 848 849 } 849 850 850 - /// Get the snake_case name of this property name. 851 + #[doc = "Get the snake_case name of this property name."] 851 852 pub const fn to_str(self) -> &'static str { 852 853 match self { 853 854 #prop_name_to_str_arms 854 855 } 855 856 } 856 857 857 - /// An array of all property names. 858 + #[doc = "An array of all property names."] 858 859 pub const ALL: [Self; #prop_name_count] = [#(Self::#prop_name_variants,)*]; 859 860 } 860 861 861 - /// Contains all possible values that a block property might have. 862 - /// 863 - /// For example, `upper`, `true`, and `2` are all property values. 862 + #[doc = "Contains all possible values that a block property might have."] 863 + #[doc = ""] 864 + #[doc = "For example, `upper`, `true`, and `2` are all property values."] 864 865 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 865 866 pub enum PropValue { 866 867 #(#prop_value_variants,)* 867 868 } 868 869 869 870 impl PropValue { 870 - /// Construct a property value from its snake_case name. 871 - /// 872 - /// Returns `None` if the given name is not valid. 871 + #[doc = "Construct a property value from its snake_case name."] 872 + #[doc = ""] 873 + #[doc = "Returns `None` if the given name is not valid."] 873 874 pub fn from_str(name: &str) -> Option<Self> { 874 875 match name { 875 876 #prop_value_from_str_arms ··· 877 878 } 878 879 } 879 880 880 - /// Get the snake_case name of this property value. 881 + #[doc = "Get the snake_case name of this property value."] 881 882 pub const fn to_str(self) -> &'static str { 882 883 match self { 883 884 #prop_value_to_str_arms 884 885 } 885 886 } 886 887 887 - /// Converts a `u16` into a numeric property value. 888 - /// Returns `None` if the given number does not have a 889 - /// corresponding property value. 888 + #[doc = "Converts a `u16` into a numeric property value."] 889 + #[doc = "Returns `None` if the given number does not have a"] 890 + #[doc = "corresponding property value."] 890 891 pub const fn from_u16(n: u16) -> Option<Self> { 891 892 match n { 892 893 #prop_value_from_u16_arms ··· 894 895 } 895 896 } 896 897 897 - /// Converts this property value into a `u16` if it is numeric. 898 - /// Returns `None` otherwise. 898 + #[doc = "Converts this property value into a `u16` if it is numeric."] 899 + #[doc = "Returns `None` otherwise."] 899 900 pub const fn to_u16(self) -> Option<u16> { 900 901 match self { 901 902 #prop_value_to_u16_arms ··· 903 904 } 904 905 } 905 906 906 - /// Converts a `bool` to a `True` or `False` property value. 907 + #[doc = "Converts a `bool` to a `True` or `False` property value."] 907 908 pub const fn from_bool(b: bool) -> Self { 908 909 if b { 909 910 Self::True ··· 912 913 } 913 914 } 914 915 915 - /// Converts a `True` or `False` property value to a `bool`. 916 - /// 917 - /// Returns `None` if this property value is not `True` or `False` 916 + #[doc = "Converts a `True` or `False` property value to a `bool`."] 917 + #[doc = ""] 918 + #[doc = "Returns `None` if this property value is not `True` or `False`"] 918 919 pub const fn to_bool(self) -> Option<bool> { 919 920 match self { 920 921 Self::True => Some(true), ··· 923 924 } 924 925 } 925 926 926 - /// An array of all property values. 927 + #[doc = "An array of all property values."] 927 928 pub const ALL: [Self; #prop_value_count] = [#(Self::#prop_value_variants,)*]; 928 929 } 929 930
+1 -1
crates/valence_generated/build/chunk_view.rs
··· 30 30 let array_len = MAX_VIEW_DIST as usize + 1; 31 31 32 32 quote! { 33 - /// The maximum view distance for a `ChunkView`. 33 + #[doc = "The maximum view distance for a `ChunkView`."] 34 34 pub const MAX_VIEW_DIST: u8 = #MAX_VIEW_DIST; 35 35 36 36 pub const EXTRA_VIEW_RADIUS: i32 = #EXTRA_VIEW_RADIUS;
+31 -31
crates/valence_generated/build/item.rs
··· 173 173 .collect::<TokenStream>(); 174 174 175 175 Ok(quote! { 176 - /// Represents an item from the game 176 + #[doc = "Represents an item from the game"] 177 177 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)] 178 178 #[repr(u16)] 179 179 pub enum ItemKind { ··· 181 181 #(#item_kind_variants,)* 182 182 } 183 183 184 - /// Contains food information about an item. 185 - /// 186 - /// Only food items have a food component. 184 + #[doc = "Contains food information about an item."] 185 + #[doc = ""] 186 + #[doc = "Only food items have a food component."] 187 187 #[derive(Clone, Copy, PartialEq, PartialOrd, Debug)] 188 188 pub struct FoodComponent { 189 189 pub hunger: u16, ··· 194 194 } 195 195 196 196 impl ItemKind { 197 - /// Constructs a item kind from a raw item ID. 198 - /// 199 - /// If the given ID is invalid, `None` is returned. 197 + #[doc = "Constructs a item kind from a raw item ID."] 198 + #[doc = ""] 199 + #[doc = "If the given ID is invalid, `None` is returned."] 200 200 pub const fn from_raw(id: u16) -> Option<Self> { 201 201 match id { 202 202 #item_kind_from_raw_id_arms ··· 204 204 } 205 205 } 206 206 207 - /// Gets the raw item ID from the item kind 207 + #[doc = "Gets the raw item ID from the item kind"] 208 208 pub const fn to_raw(self) -> u16 { 209 209 match self { 210 210 #item_kind_to_raw_id_arms 211 211 } 212 212 } 213 213 214 - /// Construct an item kind for its snake_case name. 215 - /// 216 - /// Returns `None` if the name is invalid. 214 + #[doc = "Construct an item kind for its snake_case name."] 215 + #[doc = ""] 216 + #[doc = "Returns `None` if the name is invalid."] 217 217 #[allow(clippy::should_implement_trait)] 218 218 pub fn from_str(name: &str) -> Option<ItemKind> { 219 219 match name { ··· 222 222 } 223 223 } 224 224 225 - /// Gets the snake_case name of this item kind. 225 + #[doc = "Gets the snake_case name of this item kind."] 226 226 pub const fn to_str(self) -> &'static str { 227 227 match self { 228 228 #item_kind_to_str_arms 229 229 } 230 230 } 231 231 232 - /// Gets the translation key of this item kind. 232 + #[doc = "Gets the translation key of this item kind."] 233 233 pub const fn translation_key(self) -> &'static str { 234 234 match self { 235 235 #item_kind_to_translation_key_arms 236 236 } 237 237 } 238 238 239 - /// Returns the maximum stack count. 239 + #[doc = "Returns the maximum stack count."] 240 240 pub const fn max_stack(self) -> i8 { 241 241 match self { 242 242 #item_kind_to_max_stack_arms 243 243 } 244 244 } 245 245 246 - /// Returns a food component which stores hunger, saturation etc. 247 - /// 248 - /// If the item kind can't be eaten, `None` will be returned. 246 + #[doc = "Returns a food component which stores hunger, saturation etc."] 247 + #[doc = ""] 248 + #[doc = "If the item kind can't be eaten, `None` will be returned."] 249 249 pub const fn food_component(self) -> Option<FoodComponent> { 250 250 match self { 251 251 #item_kind_to_food_component_arms ··· 253 253 } 254 254 } 255 255 256 - /// Returns the maximum durability before the item will break. 257 - /// 258 - /// If the item doesn't have durability, `0` is returned. 256 + #[doc = "Returns the maximum durability before the item will break."] 257 + #[doc = ""] 258 + #[doc = "If the item doesn't have durability, `0` is returned."] 259 259 pub const fn max_durability(self) -> u16 { 260 260 match self { 261 261 #item_kind_to_max_durability_arms ··· 263 263 } 264 264 } 265 265 266 - /// Returns the enchantability of the item kind. 267 - /// 268 - /// If the item doesn't have durability, `0` is returned. 266 + #[doc = "Returns the enchantability of the item kind."] 267 + #[doc = ""] 268 + #[doc = "If the item doesn't have durability, `0` is returned."] 269 269 pub const fn enchantability(self) -> u8 { 270 270 match self { 271 271 #item_kind_to_enchantability_arms ··· 273 273 } 274 274 } 275 275 276 - /// Returns if the item can survive in fire/lava. 276 + #[doc = "Returns if the item can survive in fire/lava."] 277 277 pub const fn fireproof(self) -> bool { 278 278 #[allow(clippy::match_like_matches_macro)] 279 279 match self { ··· 283 283 } 284 284 285 285 /* 286 - /// Constructs an item kind from a block kind. 287 - /// 288 - /// [`ItemKind::Air`] is used to indicate the absence of an item. 286 + #[doc = "Constructs an item kind from a block kind."] 287 + #[doc = ""] 288 + #[doc = "[`ItemKind::Air`] is used to indicate the absence of an item."] 289 289 pub const fn from_block_kind(kind: BlockKind) -> Self { 290 290 kind.to_item_kind() 291 291 } 292 292 293 - /// Constructs a block kind from an item kind. 294 - /// 295 - /// If the given item kind doesn't have a corresponding block kind, `None` is returned. 293 + #[doc = "Constructs a block kind from an item kind."] 294 + #[doc = ""] 295 + #[doc = "If the given item kind doesn't have a corresponding block kind, `None` is returned."] 296 296 pub const fn to_block_kind(self) -> Option<BlockKind> { 297 297 BlockKind::from_item_kind(self) 298 298 }*/ 299 299 300 - /// An array of all item kinds. 300 + #[doc = "An array of all item kinds."] 301 301 pub const ALL: [Self; #item_kind_count] = [#(Self::#item_kind_variants,)*]; 302 302 } 303 303 })
+10 -10
crates/valence_generated/build/sound.rs
··· 74 74 Ok(quote! { 75 75 use valence_ident::{Ident, ident}; 76 76 77 - /// Represents a sound from the game 77 + #[doc = "Represents a sound from the game"] 78 78 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 79 79 pub enum Sound { 80 80 #(#sound_variants,)* 81 81 } 82 82 83 83 impl Sound { 84 - /// Constructs a sound from a raw item ID. 85 - /// 86 - /// If the given ID is invalid, `None` is returned. 84 + #[doc = "Constructs a sound from a raw item ID."] 85 + #[doc = ""] 86 + #[doc = "If the given ID is invalid, `None` is returned."] 87 87 pub const fn from_raw(id: u16) -> Option<Self> { 88 88 match id { 89 89 #sound_from_raw_id_arms ··· 91 91 } 92 92 } 93 93 94 - /// Gets the raw sound ID from the sound 94 + #[doc = "Gets the raw sound ID from the sound"] 95 95 pub const fn to_raw(self) -> u16 { 96 96 match self { 97 97 #sound_to_raw_id_arms 98 98 } 99 99 } 100 100 101 - /// Construct a sound from its snake_case name. 102 - /// 103 - /// Returns `None` if the name is invalid. 101 + #[doc = "Construct a sound from its snake_case name."] 102 + #[doc = ""] 103 + #[doc = "Returns `None` if the name is invalid."] 104 104 pub fn from_ident(id: Ident<&str>) -> Option<Self> { 105 105 match id.as_str() { 106 106 #sound_from_ident_arms ··· 108 108 } 109 109 } 110 110 111 - /// Gets the identifier of this sound. 111 + #[doc = "Gets the identifier of this sound."] 112 112 pub const fn to_ident(self) -> Ident<&'static str> { 113 113 match self { 114 114 #sound_to_ident_arms 115 115 } 116 116 } 117 117 118 - /// An array of all sounds. 118 + #[doc = "An array of all sounds."] 119 119 pub const ALL: [Self; #sound_count] = [#(Self::#sound_variants,)*]; 120 120 } 121 121 })
+23 -23
crates/valence_generated/build/status_effects.rs
··· 173 173 use valence_ident::{Ident, ident}; 174 174 use super::attributes::{EntityAttribute, EntityAttributeOperation}; 175 175 176 - /// Represents an attribute modifier. 176 + #[doc = "Represents an attribute modifier."] 177 177 #[derive(Debug, Clone, Copy, PartialEq)] 178 178 pub struct AttributeModifier { 179 - /// The attribute that this modifier modifies. 179 + #[doc = "The attribute that this modifier modifies."] 180 180 pub attribute: EntityAttribute, 181 - /// The operation that this modifier applies. 181 + #[doc = "The operation that this modifier applies."] 182 182 pub operation: EntityAttributeOperation, 183 - /// The value of this modifier. 183 + #[doc = "The value of this modifier."] 184 184 pub value: f64, 185 - /// The UUID of this modifier. 185 + #[doc = "The UUID of this modifier."] 186 186 pub uuid: Uuid, 187 187 } 188 188 189 - /// Represents a status effect category 189 + #[doc = "Represents a status effect category"] 190 190 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 191 191 pub enum StatusEffectCategory { 192 192 Beneficial, ··· 194 194 Neutral, 195 195 } 196 196 197 - /// Represents a status effect from the game 197 + #[doc = "Represents a status effect from the game"] 198 198 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] 199 199 pub enum StatusEffect { 200 200 #(#effect_variants,)* 201 201 } 202 202 203 203 impl StatusEffect { 204 - /// Constructs a effect from a raw item ID. 205 - /// 206 - /// If the given ID is invalid, `None` is returned. 204 + #[doc = "Constructs a effect from a raw item ID."] 205 + #[doc = ""] 206 + #[doc = "If the given ID is invalid, `None` is returned."] 207 207 pub const fn from_raw(id: u16) -> Option<Self> { 208 208 match id { 209 209 #effect_from_raw_id_arms ··· 211 211 } 212 212 } 213 213 214 - /// Gets the raw effect ID from the effect 214 + #[doc = "Gets the raw effect ID from the effect"] 215 215 pub const fn to_raw(self) -> u16 { 216 216 match self { 217 217 #effect_to_raw_id_arms 218 218 } 219 219 } 220 220 221 - /// Construct a effect from its snake_case name. 222 - /// 223 - /// Returns `None` if the name is invalid. 221 + #[doc = "Construct a effect from its snake_case name."] 222 + #[doc = ""] 223 + #[doc = "Returns `None` if the name is invalid."] 224 224 pub fn from_ident(id: Ident<&str>) -> Option<Self> { 225 225 match id.as_str() { 226 226 #effect_from_ident_arms ··· 228 228 } 229 229 } 230 230 231 - /// Gets the identifier of this effect. 231 + #[doc = "Gets the identifier of this effect."] 232 232 pub const fn to_ident(self) -> Ident<&'static str> { 233 233 match self { 234 234 #effect_to_ident_arms 235 235 } 236 236 } 237 237 238 - /// Gets the name of this effect. 239 - /// Same as [`StatusEffect::to_ident`], but doesn't take ownership. 238 + #[doc = "Gets the name of this effect."] 239 + #[doc = "Same as [`StatusEffect::to_ident`], but doesn't take ownership."] 240 240 pub const fn name(&self) -> Ident<&'static str> { 241 241 match self { 242 242 #effect_to_ident_arms 243 243 } 244 244 } 245 245 246 - /// Gets the translation key of this effect. 246 + #[doc = "Gets the translation key of this effect."] 247 247 pub const fn translation_key(&self) -> &'static str { 248 248 match self { 249 249 #effect_to_translation_key_arms 250 250 } 251 251 } 252 252 253 - /// Gets the category of this effect. 253 + #[doc = "Gets the category of this effect."] 254 254 pub const fn category(&self) -> StatusEffectCategory { 255 255 match self { 256 256 #effect_to_category_arms 257 257 } 258 258 } 259 259 260 - /// Gets the color of this effect. 260 + #[doc = "Gets the color of this effect."] 261 261 pub const fn color(&self) -> u32 { 262 262 match self { 263 263 #effect_to_color_arms 264 264 } 265 265 } 266 266 267 - /// Gets whether this effect is instant. 267 + #[doc = "Gets whether this effect is instant."] 268 268 pub const fn instant(&self) -> bool { 269 269 match self { 270 270 #effect_to_instant_arms 271 271 } 272 272 } 273 273 274 - /// Gets the attribute modifiers of this effect. 274 + #[doc = "Gets the attribute modifiers of this effect."] 275 275 pub fn attribute_modifiers(&self) -> Vec<AttributeModifier> { 276 276 match self { 277 277 #effect_to_attribute_modifiers_arms ··· 279 279 } 280 280 } 281 281 282 - /// An array of all effects. 282 + #[doc = "An array of all effects."] 283 283 pub const ALL: [Self; #effect_count] = [#(Self::#effect_variants,)*]; 284 284 } 285 285 })
+3 -3
crates/valence_ident/src/lib.rs
··· 126 126 } 127 127 } 128 128 129 - impl<'a> Ident<Cow<'a, str>> { 129 + impl Ident<Cow<'_, str>> { 130 130 pub fn borrowed(&self) -> Ident<Cow<str>> { 131 131 Ident::new_unchecked(Cow::Borrowed(self.as_str())) 132 132 } ··· 200 200 } 201 201 } 202 202 203 - impl<'a> From<Ident<String>> for Ident<Cow<'a, str>> { 203 + impl From<Ident<String>> for Ident<Cow<'_, str>> { 204 204 fn from(value: Ident<String>) -> Self { 205 205 Self { 206 206 string: value.string.into(), ··· 272 272 } 273 273 } 274 274 275 - impl<'a> TryFrom<String> for Ident<Cow<'a, str>> { 275 + impl TryFrom<String> for Ident<Cow<'_, str>> { 276 276 type Error = IdentError; 277 277 278 278 fn try_from(value: String) -> Result<Self, Self::Error> {
-3
crates/valence_inventory/src/lib.rs
··· 631 631 632 632 inventory.changed = 0; 633 633 inv_state.slots_changed = 0; 634 - 635 - // Skip updating the cursor item because we just updated the whole inventory. 636 - continue; 637 634 } else if inventory.changed != 0 { 638 635 // Send the modified slots. 639 636
+4 -4
crates/valence_inventory/src/validate.rs
··· 166 166 ); 167 167 } else { 168 168 // If the user clicked on an empty slot for example 169 - if packet.slot_changes.len() == 0 { 169 + if packet.slot_changes.is_empty() { 170 170 let count_deltas = calculate_net_item_delta(packet, &window, cursor_item); 171 171 ensure!( 172 172 count_deltas == 0, ··· 216 216 } 217 217 ClickMode::ShiftClick => { 218 218 // If the user clicked on an empty slot for example 219 - if packet.slot_changes.len() == 0 { 219 + if packet.slot_changes.is_empty() { 220 220 let count_deltas = calculate_net_item_delta(packet, &window, cursor_item); 221 221 ensure!( 222 222 count_deltas == 0, ··· 265 265 } 266 266 267 267 ClickMode::Hotbar => { 268 - if packet.slot_changes.len() == 0 { 268 + if packet.slot_changes.is_empty() { 269 269 let count_deltas = calculate_net_item_delta(packet, &window, cursor_item); 270 270 ensure!( 271 271 count_deltas == 0, ··· 308 308 } 309 309 ClickMode::CreativeMiddleClick => {} 310 310 ClickMode::DropKey => { 311 - if packet.slot_changes.len() == 0 { 311 + if packet.slot_changes.is_empty() { 312 312 let count_deltas = calculate_net_item_delta(packet, &window, cursor_item); 313 313 ensure!( 314 314 count_deltas == 0,
+3 -3
crates/valence_nbt/src/serde/de.rs
··· 262 262 } 263 263 } 264 264 265 - impl<'de> IntoDeserializer<'de, Error> for Compound { 265 + impl IntoDeserializer<'_, Error> for Compound { 266 266 type Deserializer = Self; 267 267 268 268 fn into_deserializer(self) -> Self::Deserializer { ··· 332 332 } 333 333 } 334 334 335 - impl<'de> IntoDeserializer<'de, Error> for Value { 335 + impl IntoDeserializer<'_, Error> for Value { 336 336 type Deserializer = Self; 337 337 338 338 fn into_deserializer(self) -> Self::Deserializer { ··· 384 384 } 385 385 } 386 386 387 - impl<'de> IntoDeserializer<'de, Error> for List { 387 + impl IntoDeserializer<'_, Error> for List { 388 388 type Deserializer = Self; 389 389 390 390 fn into_deserializer(self) -> Self::Deserializer {
+2 -2
crates/valence_protocol/src/bit_set.rs
··· 16 16 "bit index of {idx} out of range for bitset with {BIT_COUNT} bits" 17 17 ); 18 18 19 - self.0[idx / 8] >> (idx % 8) & 1 == 1 19 + (self.0[idx / 8] >> (idx % 8)) & 1 == 1 20 20 } 21 21 22 22 pub fn set_bit(&mut self, idx: usize, val: bool) { ··· 50 50 } 51 51 52 52 const fn check_counts(bits: usize, bytes: usize) { 53 - assert!((bits + 7) / 8 == bytes) 53 + assert!(bits.div_ceil(8) == bytes) 54 54 } 55 55 56 56 impl<const BIT_COUNT: usize, const BYTE_COUNT: usize> fmt::Debug
+2 -2
crates/valence_protocol/src/impls/pointer.rs
··· 53 53 } 54 54 } 55 55 56 - impl<'a, B> Encode for Cow<'a, B> 56 + impl<B> Encode for Cow<'_, B> 57 57 where 58 58 B: ToOwned + Encode + ?Sized, 59 59 { ··· 62 62 } 63 63 } 64 64 65 - impl<'a, 'b, B> Decode<'a> for Cow<'b, B> 65 + impl<'a, B> Decode<'a> for Cow<'_, B> 66 66 where 67 67 B: ToOwned + ?Sized, 68 68 B::Owned: Decode<'a>,
+2 -2
crates/valence_protocol/src/packets/play/chat_message_s2c.rs
··· 30 30 PartiallyFiltered, 31 31 } 32 32 33 - impl<'a> Encode for ChatMessageS2c<'a> { 33 + impl Encode for ChatMessageS2c<'_> { 34 34 fn encode(&self, mut w: impl Write) -> anyhow::Result<()> { 35 35 self.sender.encode(&mut w)?; 36 36 self.index.encode(&mut w)?; ··· 103 103 pub signature: Option<&'a [u8; 256]>, 104 104 } 105 105 106 - impl<'a> Encode for MessageSignature<'a> { 106 + impl Encode for MessageSignature<'_> { 107 107 fn encode(&self, mut w: impl Write) -> anyhow::Result<()> { 108 108 VarInt(self.message_id + 1).encode(&mut w)?; 109 109
+1 -1
crates/valence_protocol/src/packets/play/player_list_s2c.rs
··· 14 14 pub entries: Cow<'a, [PlayerListEntry<'a>]>, 15 15 } 16 16 17 - impl<'a> Encode for PlayerListS2c<'a> { 17 + impl Encode for PlayerListS2c<'_> { 18 18 fn encode(&self, mut w: impl Write) -> anyhow::Result<()> { 19 19 self.actions.0.encode(&mut w)?; 20 20
+1 -1
crates/valence_server/src/layer/chunk/chunk.rs
··· 249 249 } 250 250 } 251 251 252 - impl<'a> IntoBlock for BlockRef<'a> { 252 + impl IntoBlock for BlockRef<'_> { 253 253 fn into_block(self) -> Block { 254 254 Block { 255 255 state: self.state,
+1 -1
crates/valence_server/src/layer/chunk/paletted_container.rs
··· 237 237 238 238 impl<T: Copy + Eq + Default, const LEN: usize, const HALF_LEN: usize> Indirect<T, LEN, HALF_LEN> { 239 239 pub(super) fn get(&self, idx: usize) -> T { 240 - let palette_idx = self.indices[idx / 2] >> (idx % 2 * 4) & 0b1111; 240 + let palette_idx = (self.indices[idx / 2] >> (idx % 2 * 4)) & 0b1111; 241 241 self.palette[palette_idx as usize] 242 242 } 243 243
+1 -1
crates/valence_server/src/layer/entity.rs
··· 228 228 pos: ChunkPos, 229 229 } 230 230 231 - impl<'a> WritePacket for ViewWriter<'a> { 231 + impl WritePacket for ViewWriter<'_> { 232 232 fn write_packet_fallible<P>(&mut self, packet: &P) -> anyhow::Result<()> 233 233 where 234 234 P: Packet + Encode,
+4 -4
crates/valence_text/src/color.rs
··· 285 285 286 286 if let &[b'#', r0, r1, g0, g1, b0, b1] = value.as_bytes() { 287 287 Ok(RgbColor { 288 - r: to_num(r0)? << 4 | to_num(r1)?, 289 - g: to_num(g0)? << 4 | to_num(g1)?, 290 - b: to_num(b0)? << 4 | to_num(b1)?, 288 + r: (to_num(r0)? << 4) | to_num(r1)?, 289 + g: (to_num(g0)? << 4) | to_num(g1)?, 290 + b: (to_num(b0)? << 4) | to_num(b1)?, 291 291 }) 292 292 } else { 293 293 Err(ColorError) ··· 309 309 310 310 struct ColorVisitor; 311 311 312 - impl<'de> Visitor<'de> for ColorVisitor { 312 + impl Visitor<'_> for ColorVisitor { 313 313 type Value = Color; 314 314 315 315 fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
+4 -4
crates/valence_text/src/into_text.rs
··· 256 256 value.into_owned() 257 257 } 258 258 } 259 - impl<'a, 'b> IntoText<'a> for &'a Cow<'b, Text> { 259 + impl<'a> IntoText<'a> for &'a Cow<'_, Text> { 260 260 fn into_cow_text(self) -> Cow<'a, Text> { 261 261 self.clone() 262 262 } ··· 277 277 value.into_text() 278 278 } 279 279 } 280 - impl<'a, 'b> IntoText<'b> for &'a String { 280 + impl<'b> IntoText<'b> for &String { 281 281 fn into_cow_text(self) -> Cow<'b, Text> { 282 282 Cow::Owned(Text::text(self.clone())) 283 283 } ··· 298 298 value.into_text() 299 299 } 300 300 } 301 - impl<'a> IntoText<'static> for &'a Cow<'static, str> { 301 + impl IntoText<'static> for &Cow<'static, str> { 302 302 fn into_cow_text(self) -> Cow<'static, Text> { 303 303 Cow::Owned(Text::text(self.clone())) 304 304 } ··· 332 332 } 333 333 } 334 334 335 - impl<'a, 'b, 'c, T: IntoText<'a> + Clone, const N: usize> IntoText<'c> for &'b [T; N] { 335 + impl<'a, 'c, T: IntoText<'a> + Clone, const N: usize> IntoText<'c> for &[T; N] { 336 336 fn into_cow_text(self) -> Cow<'c, Text> { 337 337 let mut txt = Text::text(""); 338 338
+2 -3
crates/valence_text/src/lib.rs
··· 494 494 this.0.underlined, 495 495 this.0.italic, 496 496 ] 497 - .iter() 498 - .any(|m| *m == Some(false)) 497 + .contains(&Some(false)) 499 498 || this.0.color == Some(Color::Reset) 500 499 { 501 500 // Reset and print sum of old and new modifiers ··· 553 552 } 554 553 } 555 554 556 - impl<'a> From<Text> for Cow<'a, Text> { 555 + impl From<Text> for Cow<'_, Text> { 557 556 fn from(value: Text) -> Self { 558 557 Cow::Owned(value) 559 558 }
+1 -1
tools/packet_inspector/src/tri_checkbox.rs
··· 43 43 } 44 44 } 45 45 46 - impl<'a> Widget for TriCheckbox<'a> { 46 + impl Widget for TriCheckbox<'_> { 47 47 fn ui(self, ui: &mut Ui) -> Response { 48 48 let TriCheckbox { checked, text } = self; 49 49
+1 -1
tools/stresser/src/stresser.rs
··· 24 24 pub read_buffer_size: usize, 25 25 } 26 26 27 - pub async fn make_session<'a>(params: &SessionParams<'a>) -> anyhow::Result<()> { 27 + pub async fn make_session(params: &SessionParams<'_>) -> anyhow::Result<()> { 28 28 let sock_addr = params.socket_addr; 29 29 let sess_name = params.session_name; 30 30 let rb_size = params.read_buffer_size;