Skip to content

Commit a66a002

Browse files
Fix warnings - unnecessary casts and utilizing values method on iterator.
1 parent 6ae87b2 commit a66a002

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

crates/readstat/src/rs_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl ReadStatData {
340340
.set_row_offset(Some(self.chunk_row_start.try_into().unwrap()))?
341341
.parse_sas7bdat(ppath, ctx);
342342

343-
match FromPrimitive::from_i32(error as i32) {
343+
match FromPrimitive::from_i32(error) {
344344
Some(ReadStatError::READSTAT_OK) => Ok(()),
345345
Some(e) => Err(From::from(format!(
346346
"Error when attempting to parse sas7bdat: {:#?}",

crates/readstat/src/rs_metadata.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ impl ReadStatMetadata {
5353
// build up Schema
5454
let fields: Vec<Field> = self
5555
.vars
56-
.iter()
57-
.map(|(_idx, vm)| {
56+
.values()
57+
.map(|vm| {
5858
let var_dt = match &vm.var_type {
5959
ReadStatVarType::String
6060
| ReadStatVarType::StringRef
@@ -141,7 +141,7 @@ impl ReadStatMetadata {
141141
}
142142
*/
143143

144-
match FromPrimitive::from_i32(error as i32) {
144+
match FromPrimitive::from_i32(error) {
145145
Some(ReadStatError::READSTAT_OK) => {
146146
// if successful, initialize schema
147147
self.schema = self.initialize_schema();

crates/readstat/src/rs_parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl ReadStatParser {
3131
&set_metadata_handler_error
3232
);
3333

34-
match FromPrimitive::from_i32(set_metadata_handler_error as i32) {
34+
match FromPrimitive::from_i32(set_metadata_handler_error) {
3535
Some(ReadStatError::READSTAT_OK) => Ok(self),
3636
Some(e) => Err(From::from(format!(
3737
"Unable to set metdata handler: {:#?}",
@@ -57,7 +57,7 @@ impl ReadStatParser {
5757
&set_row_limit_error
5858
);
5959

60-
match FromPrimitive::from_i32(set_row_limit_error as i32) {
60+
match FromPrimitive::from_i32(set_row_limit_error) {
6161
Some(ReadStatError::READSTAT_OK) => Ok(self),
6262
Some(e) => Err(From::from(format!("Unable to set row limit: {:#?}", e))),
6363
None => Err(From::from(
@@ -83,7 +83,7 @@ impl ReadStatParser {
8383
&set_row_offset_error
8484
);
8585

86-
match FromPrimitive::from_i32(set_row_offset_error as i32) {
86+
match FromPrimitive::from_i32(set_row_offset_error) {
8787
Some(ReadStatError::READSTAT_OK) => Ok(self),
8888
Some(e) => Err(From::from(format!("Unable to set row limit: {:#?}", e))),
8989
None => Err(From::from(
@@ -107,7 +107,7 @@ impl ReadStatParser {
107107
&set_variable_handler_error
108108
);
109109

110-
match FromPrimitive::from_i32(set_variable_handler_error as i32) {
110+
match FromPrimitive::from_i32(set_variable_handler_error) {
111111
Some(ReadStatError::READSTAT_OK) => Ok(self),
112112
Some(e) => Err(From::from(format!(
113113
"Unable to set variable handler: {:#?}",
@@ -131,7 +131,7 @@ impl ReadStatParser {
131131
&set_value_handler_error
132132
);
133133

134-
match FromPrimitive::from_i32(set_value_handler_error as i32) {
134+
match FromPrimitive::from_i32(set_value_handler_error) {
135135
Some(ReadStatError::READSTAT_OK) => Ok(self),
136136
Some(e) => Err(From::from(format!("Unable to set value handler: {:#?}", e))),
137137
None => Err(From::from(

crates/readstat/src/rs_write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl ReadStatWriter {
644644
let mut f = std::fs::File::create(p)?;
645645

646646
// Get variable names
647-
let vars: Vec<String> = d.vars.iter().map(|(_, m)| m.var_name.clone()).collect();
647+
let vars: Vec<String> = d.vars.values().map(|m| m.var_name.clone()).collect();
648648

649649
// write
650650
let options = csv_arrow2::write::SerializeOptions::default();
@@ -671,7 +671,7 @@ impl ReadStatWriter {
671671
}
672672

673673
// Get variable names
674-
let vars: Vec<String> = d.vars.iter().map(|(_, m)| m.var_name.clone()).collect();
674+
let vars: Vec<String> = d.vars.values().map(|m| m.var_name.clone()).collect();
675675

676676
// write
677677
let options = csv_arrow2::write::SerializeOptions::default();

0 commit comments

Comments
 (0)