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 Spanned::new(Range<usize>, T) #664

Merged
merged 1 commit into from
Dec 19, 2023
Merged

Conversation

dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Dec 19, 2023

I looked for why this might not exist and found #368, which is concerned with whether Range<usize> is really the right representation for the field type or if it should hold something else, like a custom Span type defined by serde_spanned.

The same concern might apply to a new constructor, and if so, an approach that doesn't preclude construction with a better type in the future might be preferred. For example Spanned::new(value).with_range(range).

Without some API to construct a Spanned at a given range, I do not know of any way to deserialize an untagged enum containing Spanned fields. Context: dtolnay/serde-untagged#5

@epage epage merged commit 60c4e9b into toml-rs:main Dec 19, 2023
15 checks passed
@dtolnay dtolnay deleted the spannednew branch December 19, 2023 21:33
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