Skip to content

Use lifetime GAT for Source::Slice#332

Merged
jeertmans merged 2 commits intomaciejhirsz:masterfrom
kmicklas:gat-slice
Aug 17, 2023
Merged

Use lifetime GAT for Source::Slice#332
jeertmans merged 2 commits intomaciejhirsz:masterfrom
kmicklas:gat-slice

Conversation

@kmicklas
Copy link
Contributor

This is required to write a Source impl for any type whose slice is a custom type and not a bare reference. For example, see ropey::RopeSlice.

Relates to #222.

@jeertmans
Copy link
Collaborator

Nice, thanks! I have read about GAT, but not actually used them.

do you have an example code that would now work with the new change, and that would not work previously?

@kmicklas
Copy link
Contributor Author

I think the change in tests/src/lib.rs is indicative of the types of changes that would be required in user code. In general I wouldn't expect too many incompatibilities in user code (i.e. using default Sources) since the current Slice definitions and the new ones both resolve to &str/&[u8] for the appropriate lifetime.

The bigger source of breakages would be that this invalidates any Source impl.

@jeertmans
Copy link
Collaborator

Could you update Rust's MSRV so that it passes the tests? You can use cargo-msrv for that purpose :-)

@jeertmans jeertmans merged commit ea31a43 into maciejhirsz:master Aug 17, 2023
@kmicklas kmicklas deleted the gat-slice branch August 17, 2023 19:58
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