maraiah: clippy
parent
666b9a78ec
commit
cbd4ef0171
|
@ -61,7 +61,7 @@ pub fn read_bits_l(b: &[u8], cr_bit: usize, width: u8) -> ResultS<u64>
|
|||
}
|
||||
|
||||
// FIXME: change this to u64::reverse_bits when stabilized
|
||||
fn reverse_bits(v: u64) -> u64
|
||||
const fn reverse_bits(v: u64) -> u64
|
||||
{
|
||||
let v = v >> 1 & 0x5555_5555_5555_5555 | ((v & 0x5555_5555_5555_5555) << 1);
|
||||
let v = v >> 2 & 0x3333_3333_3333_3333 | ((v & 0x3333_3333_3333_3333) << 2);
|
||||
|
|
|
@ -31,12 +31,12 @@ macro_rules! c_bitfield
|
|||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err>
|
||||
{
|
||||
let mut flags = $t::empty();
|
||||
let mut flags = Self::empty();
|
||||
|
||||
for s in s.split('|') {
|
||||
match s {
|
||||
$(
|
||||
stringify!($f) => flags.insert($t::$f),
|
||||
stringify!($f) => flags.insert(Self::$f),
|
||||
)+
|
||||
"(none)" => (),
|
||||
_ => return Err(Self::Err::new(stringify!($t)))
|
||||
|
|
|
@ -65,7 +65,8 @@ impl ParseEnumError
|
|||
/// assert_eq!(format!("{}", ParseEnumError::new("TypeName")),
|
||||
/// "could not parse TypeName");
|
||||
/// ```
|
||||
pub fn new(t: &'static str) -> Self
|
||||
#[inline]
|
||||
pub const fn new(t: &'static str) -> Self
|
||||
{
|
||||
Self(t)
|
||||
}
|
||||
|
@ -83,7 +84,8 @@ impl ParseFlagError
|
|||
/// assert_eq!(format!("{}", ParseFlagError::new("TypeName")),
|
||||
/// "could not parse TypeName");
|
||||
/// ```
|
||||
pub fn new(t: &'static str) -> Self
|
||||
#[inline]
|
||||
pub const fn new(t: &'static str) -> Self
|
||||
{
|
||||
Self(t)
|
||||
}
|
||||
|
|
|
@ -178,16 +178,19 @@ macro_rules! define_fixed_types {
|
|||
|
||||
/// Return the memory representation of this integer as a byte array
|
||||
/// in big-endian (network) byte order.
|
||||
#[allow(clippy::missing_const_for_fn)] // HACK: clippy is wrong
|
||||
#[inline]
|
||||
pub fn to_be_bytes(self) -> [u8; $bytes] {self.0.to_be_bytes()}
|
||||
|
||||
/// Return the memory representation of this integer as a byte array
|
||||
/// in little-endian byte order.
|
||||
#[allow(clippy::missing_const_for_fn)] // HACK: clippy is wrong
|
||||
#[inline]
|
||||
pub fn to_le_bytes(self) -> [u8; $bytes] {self.0.to_le_bytes()}
|
||||
|
||||
/// Create a value from its representation as a byte array in
|
||||
/// big-endian byte order.
|
||||
#[allow(clippy::missing_const_for_fn)] // HACK: clippy is wrong
|
||||
#[inline]
|
||||
pub fn from_be_bytes(b: [u8; $bytes]) -> $t
|
||||
{
|
||||
|
@ -196,6 +199,7 @@ macro_rules! define_fixed_types {
|
|||
|
||||
/// Create a value from its representation as a byte array in
|
||||
/// little-endian byte order.
|
||||
#[allow(clippy::missing_const_for_fn)] // HACK: clippy is wrong
|
||||
#[inline]
|
||||
pub fn from_le_bytes(b: [u8; $bytes]) -> $t
|
||||
{
|
||||
|
|
|
@ -13,7 +13,8 @@ pub mod tga;
|
|||
///
|
||||
/// assert_eq!(r5g5b5_to_rgb8(0x2345), Color8::new(64, 208, 40));
|
||||
/// ```
|
||||
pub fn r5g5b5_to_rgb8(rgb: u16) -> Color8
|
||||
#[inline]
|
||||
pub const fn r5g5b5_to_rgb8(rgb: u16) -> Color8
|
||||
{
|
||||
let r = (rgb >> 10) as u8 & 0x1f;
|
||||
let g = (rgb >> 5) as u8 & 0x1f;
|
||||
|
@ -31,7 +32,8 @@ pub fn r5g5b5_to_rgb8(rgb: u16) -> Color8
|
|||
/// assert_eq!(r5g5b5_to_rgb16(0x2345),
|
||||
/// Color16::new(0x4000, 0xD000, 0x2800));
|
||||
/// ```
|
||||
pub fn r5g5b5_to_rgb16(rgb: u16) -> Color16
|
||||
#[inline]
|
||||
pub const fn r5g5b5_to_rgb16(rgb: u16) -> Color16
|
||||
{
|
||||
let r = rgb >> 10 & 0x1f;
|
||||
let g = rgb >> 5 & 0x1f;
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#![deny(clippy::explicit_iter_loop)]
|
||||
#![deny(clippy::fallible_impl_from)]
|
||||
#![deny(clippy::filter_map)]
|
||||
#![deny(clippy::filter_map_next)]
|
||||
#![deny(clippy::find_map)]
|
||||
#![deny(clippy::float_arithmetic)]
|
||||
#![deny(clippy::float_cmp_const)]
|
||||
#![deny(clippy::invalid_upcast_comparisons)]
|
||||
|
@ -41,6 +43,7 @@
|
|||
#![deny(clippy::map_flatten)]
|
||||
#![deny(clippy::match_same_arms)]
|
||||
#![deny(clippy::mem_forget)]
|
||||
#![deny(clippy::missing_const_for_fn)]
|
||||
#![deny(clippy::multiple_inherent_impl)]
|
||||
#![deny(clippy::mut_mut)]
|
||||
#![deny(clippy::mutex_integer)]
|
||||
|
@ -51,6 +54,8 @@
|
|||
#![deny(clippy::panicking_unwrap)]
|
||||
#![deny(clippy::print_stdout)]
|
||||
#![deny(clippy::pub_enum_variant_names)]
|
||||
#![deny(clippy::redundant_clone)]
|
||||
#![deny(clippy::redundant_closure_for_method_calls)]
|
||||
#![deny(clippy::replace_consts)]
|
||||
#![deny(clippy::result_map_unwrap_or_else)]
|
||||
#![deny(clippy::result_unwrap_used)]
|
||||
|
|
|
@ -123,31 +123,32 @@ impl EntryData
|
|||
|
||||
pub fn len(&self) -> usize
|
||||
{
|
||||
let ret = if self.has_epnt() {1} else {0} +
|
||||
if self.has_fxpx() {1} else {0} +
|
||||
if self.has_lins() {1} else {0} +
|
||||
if self.has_lite() {1} else {0} +
|
||||
if self.has_mnpx() {1} else {0} +
|
||||
if self.has_minf() {1} else {0} +
|
||||
if self.has_name() {1} else {0} +
|
||||
if self.has_note() {1} else {0} +
|
||||
if self.has_objs() {1} else {0} +
|
||||
if self.has_pict() {1} else {0} +
|
||||
if self.has_pnts() {1} else {0} +
|
||||
if self.has_poly() {1} else {0} +
|
||||
if self.has_prpx() {1} else {0} +
|
||||
if self.has_pxpx() {1} else {0} +
|
||||
if self.has_sids() {1} else {0} +
|
||||
if self.has_wppx() {1} else {0} +
|
||||
if self.has_ambi() {1} else {0} +
|
||||
if self.has_bonk() {1} else {0} +
|
||||
if self.has_iidx() {1} else {0} +
|
||||
if self.has_medi() {1} else {0} +
|
||||
if self.has_plac() {1} else {0} +
|
||||
if self.has_plat() {1} else {0} +
|
||||
self.num_unknown();
|
||||
ret
|
||||
self.num_unknown() +
|
||||
usize::from(self.has_epnt()) +
|
||||
usize::from(self.has_fxpx()) +
|
||||
usize::from(self.has_lins()) +
|
||||
usize::from(self.has_lite()) +
|
||||
usize::from(self.has_mnpx()) +
|
||||
usize::from(self.has_minf()) +
|
||||
usize::from(self.has_name()) +
|
||||
usize::from(self.has_note()) +
|
||||
usize::from(self.has_objs()) +
|
||||
usize::from(self.has_pict()) +
|
||||
usize::from(self.has_pnts()) +
|
||||
usize::from(self.has_poly()) +
|
||||
usize::from(self.has_prpx()) +
|
||||
usize::from(self.has_pxpx()) +
|
||||
usize::from(self.has_sids()) +
|
||||
usize::from(self.has_wppx()) +
|
||||
usize::from(self.has_ambi()) +
|
||||
usize::from(self.has_bonk()) +
|
||||
usize::from(self.has_iidx()) +
|
||||
usize::from(self.has_medi()) +
|
||||
usize::from(self.has_plac()) +
|
||||
usize::from(self.has_plat())
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {self.len() == 0}
|
||||
}
|
||||
|
||||
/// The abstract type of an entry.
|
||||
|
|
|
@ -55,7 +55,7 @@ impl Header
|
|||
|
||||
/// Returns `true` if the data is in Marathon 1 format.
|
||||
#[inline]
|
||||
pub fn old_data(&self) -> bool {self.ver_data() == 0}
|
||||
pub const fn old_data(&self) -> bool {self.ver_data() == 0}
|
||||
|
||||
/// Returns `true` if the Map file is in Marathon 1 format.
|
||||
#[inline]
|
||||
|
@ -89,19 +89,25 @@ impl Header
|
|||
impl Map
|
||||
{
|
||||
/// The header for this map.
|
||||
pub fn head(&self) -> &Header {&self.head}
|
||||
#[inline]
|
||||
pub const fn head(&self) -> &Header {&self.head}
|
||||
|
||||
/// The data section of this map.
|
||||
#[inline]
|
||||
pub fn data(&self) -> &[u8] {&self.data[..]}
|
||||
|
||||
/// The directory section of this map.
|
||||
#[inline]
|
||||
pub fn dir(&self) -> &[u8] {&self.data[self.dir_beg()..self.dir_end()]}
|
||||
|
||||
/// The number of entries in the directory.
|
||||
pub fn num_ent(&self) -> usize {self.num_ent}
|
||||
#[inline]
|
||||
pub const fn num_ent(&self) -> usize {self.num_ent}
|
||||
|
||||
fn dir_beg(&self) -> usize {self.dir_ofs}
|
||||
#[inline]
|
||||
const fn dir_beg(&self) -> usize {self.dir_ofs}
|
||||
|
||||
#[inline]
|
||||
fn dir_end(&self) -> usize
|
||||
{
|
||||
self.dir_ofs + self.head.size_entry() * self.num_ent
|
||||
|
|
|
@ -80,7 +80,8 @@ impl Bitmap
|
|||
impl<'a, 'b> ImageShp<'a, 'b>
|
||||
{
|
||||
/// Creates an `ImageShp` with the given bitmap.
|
||||
pub fn new(bmp: &'a Bitmap, clut: &'b [clut::ColorShp]) -> Self
|
||||
#[inline]
|
||||
pub const fn new(bmp: &'a Bitmap, clut: &'b [clut::ColorShp]) -> Self
|
||||
{
|
||||
Self{bmp, clut}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue