Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Aug 12, 2024
1 parent 74a2bf2 commit 67ca10f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/header/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ impl From<Header> for Builder {
}

fn number_of_points_hash_map<T: Copy + Into<u64>>(slice: &[T]) -> HashMap<u8, u64> {
use std::u8;
assert!(slice.len() < u8::MAX as usize);
slice
.iter()
Expand Down
10 changes: 0 additions & 10 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,6 @@ impl Header {
}

fn header_size(&self) -> Result<u16> {
use std::u16;

let header_size = self.version.header_size() as usize + self.padding.len();
if header_size > u16::MAX as usize {
Err(Error::TooLarge(header_size).into())
Expand All @@ -591,8 +589,6 @@ impl Header {
}

fn offset_to_point_data(&self) -> Result<u32> {
use std::u32;

let vlr_len = self.vlrs.iter().fold(0, |acc, vlr| acc + vlr.len(false));
let offset = self.header_size()? as usize + vlr_len + self.vlr_padding.len();
if offset > u32::MAX as usize {
Expand All @@ -603,8 +599,6 @@ impl Header {
}

fn number_of_variable_length_records(&self) -> Result<u32> {
use std::u32;

let n = self.vlrs().len();
if n > u32::MAX as usize {
Err(Error::TooManyVlrs(n).into())
Expand All @@ -615,7 +609,6 @@ impl Header {

fn number_of_points_raw(&self) -> Result<u32> {
use crate::feature::LargeFiles;
use std::u32;

if self.number_of_points > u64::from(u32::MAX) {
if self.version.supports::<LargeFiles>() {
Expand All @@ -634,7 +627,6 @@ impl Header {

fn number_of_points_by_return_raw(&self) -> Result<[u32; 5]> {
use crate::feature::LargeFiles;
use std::u32;

let mut number_of_points_by_return = [0; 5];
for (&i, &n) in &self.number_of_points_by_return {
Expand Down Expand Up @@ -664,8 +656,6 @@ impl Header {
}

fn evlr(&self) -> Result<Option<raw::header::Evlr>> {
use std::u32;

let n = self.evlrs.len();
if n == 0 {
Ok(None)
Expand Down
7 changes: 4 additions & 3 deletions src/laz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ fn create_laszip_vlr(laszip_vlr: &LazVlr) -> std::io::Result<Vlr> {
/// struct that knows how to decompress LAZ
///
/// Decompression is done in 2 steps:
/// 1) call the decompressor that reads & decompress the next point
/// and put its data in an in-memory buffer
/// 2) read the buffer to get the decompress point
///
/// 1. call the decompressor that reads & decompress the next point
/// and put its data in an in-memory buffer
/// 2. read the buffer to get the decompress point
pub(crate) struct CompressedPointReader<Decompressor> {
/// decompressor that does the actual job
decompressor: Decompressor,
Expand Down
4 changes: 2 additions & 2 deletions src/point/classification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::{point::Error, Result};
/// Here's how we deal with that change:
///
/// - If the point format doesn't support the overlap bit, the classification is overwritten with
/// the code for overlap points (12). On ingest, points with an overlap classification are given
/// the `Unclassified` code and `Point::is_overlap` is set to `true`.
/// the code for overlap points (12). On ingest, points with an overlap classification are given
/// the `Unclassified` code and `Point::is_overlap` is set to `true`.
/// - If the point format does support the overlap bit, that is preferred.
///
/// Because of this change, trying to create a classification with code 12 is an error:
Expand Down
2 changes: 1 addition & 1 deletion src/raw/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl Header {
///
/// - The file signature is not exactly "LASF".
/// - The point data format is not recognized. Note that version mismatches *are* allowed (e.g.
/// color points for las 1.1).
/// color points for las 1.1).
/// - The point data record length is less than the minimum length of the point data format.
///
/// # Examples
Expand Down
1 change: 0 additions & 1 deletion src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ impl Transform {

pub(crate) fn inverse_with_rounding_mode(&self, n: f64, r: RoundingMode) -> Result<i32> {
use crate::Error;
use std::i32;

fn round(n: f64, r: RoundingMode) -> f64 {
match r {
Expand Down
10 changes: 3 additions & 7 deletions src/vlr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,16 @@ impl Vlr {
/// vlr.data = vec![0; u16::MAX as usize + 1 ];
/// assert!(vlr.has_large_data());
pub fn has_large_data(&self) -> bool {
use std::u16;
self.data.len() > u16::MAX as usize
}

fn record_length_after_header(&self, is_extended: bool) -> Result<raw::vlr::RecordLength> {
if is_extended {
Ok(raw::vlr::RecordLength::Evlr(self.data.len() as u64))
} else if self.data.len() > u16::MAX as usize {
Err(Error::TooLong(self.data.len()).into())
} else {
use std::u16;
if self.data.len() > u16::MAX as usize {
Err(Error::TooLong(self.data.len()).into())
} else {
Ok(raw::vlr::RecordLength::Vlr(self.data.len() as u16))
}
Ok(raw::vlr::RecordLength::Vlr(self.data.len() as u16))
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ pub enum Error {
}

pub(crate) fn write_point_to<W: std::io::Write>(
mut dst: &mut W,
dst: W,
point: Point,
header: &Header,
) -> Result<()> {
point
.into_raw(header.transforms())
.and_then(|raw_point| raw_point.write_to(&mut dst, header.point_format()))?;
.and_then(|raw_point| raw_point.write_to(dst, header.point_format()))?;
Ok(())
}

Expand Down Expand Up @@ -139,7 +139,7 @@ impl<W: std::io::Write + Debug + Send> PointWriter<W> for UncompressedPointWrite
}

pub(crate) fn write_header_and_vlrs_to<W: std::io::Write>(
mut dest: &mut W,
mut dest: W,
header: &Header,
) -> Result<()> {
header
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<W: 'static + std::io::Write + Seek + Debug + Send> Writer<W> {
};

for raw_evlr in raw_evlrs {
raw_evlr?.write_to(&mut self.point_writer.get_mut())?;
raw_evlr?.write_to(self.point_writer.get_mut())?;
}

let _ = self
Expand Down

0 comments on commit 67ca10f

Please sign in to comment.