Skip to content
New issue

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

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

Already on GitHub? # to your account

Update custom whitespace API #289

Merged
merged 1 commit into from
Mar 7, 2023
Merged

Update custom whitespace API #289

merged 1 commit into from
Mar 7, 2023

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Mar 6, 2023

The old API was designed to work around the fact that the plist and quick-xml crates had different APIs for specifying custom indent behaviour. The plist crate has since been updated to match the API of quick-xml, which means that we can do the same.

@cmyr cmyr force-pushed the whitespace-api branch from 8b78a57 to 605a848 Compare March 6, 2023 20:00
The old API was designed to work around the fact that the plist and
quick-xml crates had different APIs for specifying custom indent
behaviour. The plist crate has since been updated to match the API of
quick-xml, which means that we can do the same.
@cmyr cmyr force-pushed the whitespace-api branch from 605a848 to 5ffe8a2 Compare March 7, 2023 15:30
@cmyr
Copy link
Member Author

cmyr commented Mar 7, 2023

@RickyDaMa feel free to give this a review if you like! I'm going to hold the release a day because I think we can get a release of the plist crate done, and then we can update quick-xml.

Copy link
Collaborator

@RickyDaMa RickyDaMa left a comment

Choose a reason for hiding this comment

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

Looks good to me! Releasing later is fine, but in time for Thursday would be preferable for me

The only thing about this PR that gives me pause is the paths of the constants WriteOptions::SPACE doesn't seem quite right - it doesn't read intuitively, you have to look at the documentation.

You could maybe do something like

pub mod indent_chars {
    /// The ASCII value of the space character (0x20)
    pub const SPACE: u8 = b' ';
    /// The ASCII value of the tab character (0x09)
    pub const TAB: u8 = b'\t';
}

so that the path is indent_chars::SPACE instead, but it's a tiny nitpick

@cmyr
Copy link
Member Author

cmyr commented Mar 7, 2023

My desire was to not require an additional namespace or import for these, and so they're provided here as a convenience. In general I think the pattern of defining constants on the type where they're used is at least modestly idiomatic? I could get fancy and define a custom enum or something but I think that's overthinking a fairly niche feature. :)

@cmyr cmyr merged commit 3d869f9 into master Mar 7, 2023
@cmyr cmyr deleted the whitespace-api branch March 7, 2023 21:01
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants