Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bom_sniffing option to DecodeReaderBytesBuilder #5

Merged
merged 3 commits into from
Mar 3, 2019
Merged

Add bom_sniffing option to DecodeReaderBytesBuilder #5

merged 3 commits into from
Mar 3, 2019

Conversation

LesnyRumcajs
Copy link
Contributor

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks so much. This was easier to implement than I thought. :-)

I left a couple small nits, but after that, this should be good to go.

src/lib.rs Outdated
let has_detected = !self.bom_override && encoding.is_some();

// No need to do BOM detection if we opt out of it or have an explicit encoding.
let has_detected = !self.bom_sniffing || !self.bom_override && encoding.is_some();
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add parens here to indicate precedent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

src/lib.rs Outdated
/// the encoding with BOM.
///
/// When this is disabled and an explicit encoding is not set, the decoder will treat the input
/// as raw bytes.
Copy link
Owner

Choose a reason for hiding this comment

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

I would add, "The bytes will be passed through unchanged, including any BOM that may be present."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

src/lib.rs Outdated
let has_detected = !self.bom_override && encoding.is_some();

// No need to do BOM detection if we opt out of it or have an explicit encoding.
let has_detected = !self.bom_sniffing || (!self.bom_override && encoding.is_some());
Copy link
Owner

@BurntSushi BurntSushi Mar 3, 2019

Choose a reason for hiding this comment

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

Sorry, I just noticed this: can you make sure all new code introduced in this is wrapped to 79 columns inclusive? It should follow the existing style of the code. This line in particular is longer than 79. The comments introduced below are also longer than 79 columns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I wanted to use cargo fmt at first but didn't know if this repository follows it's rules. Perhaps this tool can be used in the future?

Copy link
Owner

Choose a reason for hiding this comment

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

It'd be nice, but no, I don't think rustfmt is in a place yet for me to adopt it. It does too many sub-optimal things with the formatting.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Awesome!

@BurntSushi BurntSushi merged commit b840b09 into BurntSushi:master Mar 3, 2019
@BurntSushi
Copy link
Owner

This PR is now in encoding_rs_io 0.1.5 on crates.io. I've also bumped the dependency in ripgrep for you: BurntSushi/ripgrep@0913972

@LesnyRumcajs
Copy link
Contributor Author

@BurntSushi Great, thanks. I will work on the "plumbing" part now. :)

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.

2 participants