Skip to content

refactor: dont need ref and ref mut#580

Merged
jmcnamara merged 3 commits into
tafia:masterfrom
sftse:no-refs
Nov 16, 2025
Merged

refactor: dont need ref and ref mut#580
jmcnamara merged 3 commits into
tafia:masterfrom
sftse:no-refs

Conversation

@sftse
Copy link
Copy Markdown
Contributor

@sftse sftse commented Nov 11, 2025

Not strictly necessary, but while reviewing #559 noticed a lot of ref and ref mut use which is a mostly superfluous mechanism to express whether the pattern should be borrowing or take ownership. Since RFC2005 landed it is a pattern that is harder to explain than using intuition and the &/&mut sigils.

@sftse
Copy link
Copy Markdown
Contributor Author

sftse commented Nov 11, 2025

Last commit removes some unused error conversions. I don't know for what these conversions from Infallible errors were used for, but they give compile warnings in the beta CI run.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors pattern matching across the codebase to remove the legacy ref and ref mut keywords in favor of modern Rust match ergonomics introduced in RFC2005. The changes improve code readability and align with contemporary Rust idioms.

Key changes:

  • Removes ref and ref mut from match patterns in XML event handling
  • Updates match expressions to leverage automatic dereferencing (e.g., match *selfmatch self)
  • Adjusts function calls to explicitly pass references where needed after pattern ownership changes
  • Removes unused from_err! macro for std::string::ParseError and adds from_err! for std::str::ParseBoolError

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/xlsx/mod.rs Removed ref from XML event patterns, removed from_err! for ParseError, converted if let Some(ref mut s) to if let Some(s) = &mut
src/xlsx/cells_reader.rs Removed ref from event patterns and adjusted function calls to pass explicit references
src/xlsb/mod.rs Removed ref from XML event pattern matching
src/ods.rs Removed ref from event patterns, replaced ParseError from_err! with ParseBool, simplified error conversions
src/de.rs Changed match *self to match self and removed ref from field patterns
src/datatype.rs Updated Display and PartialEq implementations to use match ergonomics
src/auto.rs Removed ref and ref mut from enum variant patterns
examples/excel_to_csv.rs Updated match expression to use automatic dereferencing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ods.rs
Comment thread src/xlsx/mod.rs
@sftse
Copy link
Copy Markdown
Contributor Author

sftse commented Nov 12, 2025

@jqnatividad Looked at the suggested fixes by copilot. While I agree that in its current form the *Error::Parse(std::string::ParseError) variant is not very useful, maybe using it to abstract over ParseBool, ParseInt, ParseBool is a better use for it. The current granularity doesn't seem very useful, I can't see somebody matching on one error variant but not on the others.

@jmcnamara
Copy link
Copy Markdown
Collaborator

@sftse Overall this looks fine to me. Could you please resolve/close the Copilot reviews with a comment about why each isn't relevant or required. Let me know when it is ready to merge.

@sftse
Copy link
Copy Markdown
Contributor Author

sftse commented Nov 16, 2025

GTM

@jmcnamara jmcnamara merged commit 6cf8454 into tafia:master Nov 16, 2025
11 checks passed
@jmcnamara
Copy link
Copy Markdown
Collaborator

Merged. Thanks.

@sftse sftse deleted the no-refs branch November 21, 2025 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants