diff --git a/dump/src/lib.rs b/dump/src/lib.rs index 7a7b9a5b7..6ca3e000e 100644 --- a/dump/src/lib.rs +++ b/dump/src/lib.rs @@ -198,7 +198,7 @@ impl From for KindDump { #[cfg(test)] pub(crate) mod test { use std::fs::File; - use std::io::{Seek, SeekFrom}; + use std::io::Seek; use std::str::FromStr; use big_s::S; @@ -410,7 +410,7 @@ pub(crate) mod test { // create the dump let mut file = tempfile::tempfile().unwrap(); dump.persist_to(&mut file).unwrap(); - file.seek(SeekFrom::Start(0)).unwrap(); + file.rewind().unwrap(); file } diff --git a/dump/src/reader/v5/mod.rs b/dump/src/reader/v5/mod.rs index 35bdcb453..3a22ca0a9 100644 --- a/dump/src/reader/v5/mod.rs +++ b/dump/src/reader/v5/mod.rs @@ -33,7 +33,7 @@ //! use std::fs::{self, File}; -use std::io::{BufRead, BufReader, ErrorKind, Seek, SeekFrom}; +use std::io::{BufRead, BufReader, ErrorKind, Seek}; use std::path::Path; use serde::{Deserialize, Serialize}; @@ -178,7 +178,7 @@ impl V5Reader { } pub fn keys(&mut self) -> Result> + '_>> { - self.keys.seek(SeekFrom::Start(0))?; + self.keys.rewind()?; Ok(Box::new( (&mut self.keys).lines().map(|line| -> Result<_> { Ok(serde_json::from_str(&line?)?) }), )) diff --git a/milli/src/update/index_documents/helpers/grenad_helpers.rs b/milli/src/update/index_documents/helpers/grenad_helpers.rs index 03f15945a..eb66a28fe 100644 --- a/milli/src/update/index_documents/helpers/grenad_helpers.rs +++ b/milli/src/update/index_documents/helpers/grenad_helpers.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; use std::fs::File; -use std::io::{self, Seek, SeekFrom}; +use std::io::{self, Seek}; use std::time::Instant; use grenad::{CompressionType, Sorter}; @@ -66,7 +66,7 @@ pub fn sorter_into_reader( pub fn writer_into_reader(writer: grenad::Writer) -> Result> { let mut file = writer.into_inner()?; - file.seek(SeekFrom::Start(0))?; + file.rewind()?; grenad::Reader::new(file).map_err(Into::into) } diff --git a/milli/src/update/index_documents/transform.rs b/milli/src/update/index_documents/transform.rs index 68ef2b7ee..9e07e78ad 100644 --- a/milli/src/update/index_documents/transform.rs +++ b/milli/src/update/index_documents/transform.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use std::fs::File; -use std::io::{Read, Seek, SeekFrom}; +use std::io::{Read, Seek}; use fxhash::FxHashMap; use heed::RoTxn; @@ -510,7 +510,7 @@ impl<'a, 'i> Transform<'a, 'i> { let mut original_documents = writer.into_inner()?; // We then extract the file and reset the seek to be able to read it again. - original_documents.seek(SeekFrom::Start(0))?; + original_documents.rewind()?; // We create a final writer to write the new documents in order from the sorter. let mut writer = create_writer( @@ -522,7 +522,7 @@ impl<'a, 'i> Transform<'a, 'i> { // into this writer, extract the file and reset the seek to be able to read it again. self.flattened_sorter.write_into_stream_writer(&mut writer)?; let mut flattened_documents = writer.into_inner()?; - flattened_documents.seek(SeekFrom::Start(0))?; + flattened_documents.rewind()?; let mut new_external_documents_ids_builder: Vec<_> = self.new_external_documents_ids_builder.into_iter().collect(); @@ -650,10 +650,10 @@ impl<'a, 'i> Transform<'a, 'i> { // Once we have written all the documents, we extract // the file and reset the seek to be able to read it again. let mut original_documents = original_writer.into_inner()?; - original_documents.seek(SeekFrom::Start(0))?; + original_documents.rewind()?; let mut flattened_documents = flattened_writer.into_inner()?; - flattened_documents.seek(SeekFrom::Start(0))?; + flattened_documents.rewind()?; let output = TransformOutput { primary_key,