Move fields from Buffer
into a BufferData
struct
#86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As noted by others in #39, keeping
Buffer
s around is cumbersome because it borrowsFontSystem
. This PR tries to solve that by makingBuffer
a wrapper around a newBufferData
struct that contains all data previously owned byBuffer
.Buffer::from_data
andBuffer::into_data
allow converting betweenBuffer
andBufferData
.Users of
Buffer
shouldn't need to change anything, becauseBuffer
references are coerced toBufferData
references viaDeref
/DerefMut
.Note: This is only a first step towards better ergonomics, because moving
BufferData
intoBuffer
can be itself pretty cumbersome and may require suboptimal code like usingOption<BufferData>
.I envision the following steps for a follow-up:
Buffer
borrowBufferData
instead of owning it. The idea is that users would always storeBufferData
instead ofBuffer
and create a temporaryBuffer
when they need to work with it.Buffer
, we could instead renameBuffer
toOwnedBuffer
, and add something like this: