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

rollup extant PRs + BufReadExt uses '&mut self' + serde feature restructuring #114

Merged
merged 6 commits into from
Jul 11, 2022

Conversation

BurntSushi
Copy link
Owner

@BurntSushi BurntSushi commented Jul 11, 2022

Ref #40

TethysSvensson and others added 3 commits July 11, 2022 11:07
Now that bstr has an 'alloc' feature, we need to rethink how we setup
the serde feature flags. Previously, all we had was 'std' and 'no std'.
But now we have 'std', 'alloc only' and 'core only'. In particular, 'no
std' is split into 'alloc only' and 'core only', since neither one bring
in std. To reflect this trichotomy, we rename 'serde1' to 'serde1-std',
and split 'serde1-nostd' into 'serde1-alloc' and 'serde1-core'.

Closes #111
This matches what std::str::Utf8Error has, and it seems like a common
sense impl.

We do not add a 'Copy' impl however, since that seems like a backcompat
hazard. Although, it does seem unlikely that this error type will ever
*not* be 'Copy', it's not clear to me that 'Copy' makes semantic sense
for this type.

Closes #113
Previously we were accessing BString's inner field. This commit changes
it so that everyone is forced to go through a method. Honestly, it's
kind of a questionable change, but I think I stylistically prefer this.
The only reason these didn't exist is probably because I built bstr
before (or too close to) when TryFrom was stabilized. But TryFrom has
been available for quite some time, so it's good sense to add these
impls now.

Closes #112
Previously, they consumed 'self', but there is no particular reason why
they need to do that. Instead, we can borrow self mutably.

The two methods that return iterators do continue to consume 'self'
though, which matches the style used by 'std' for 'BufRead'.
This adds a convenience constructor for building a BStr slice directly
from anything that impls AsRef<[u8]>. This is analogous to, e.g.,
Path::new from std.

While this constructor is redundant, it is often convenient because of
its concreteness. Alternatives rely on generics via trait impls, which
don't always work seamlessly.

Closes #110
@BurntSushi BurntSushi merged commit b89d995 into master Jul 11, 2022
@BurntSushi BurntSushi deleted the ag/rollup branch July 11, 2022 18:37
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