Collections compatibility with Serde
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 157
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 1
Description
Would it be feasible to have the bumpalo Vec type work with serde? That way we can handle deserializing variable length sequences of references to borrowed data. That would be a big improvement over using the global allocator.
Here are three example types. The first is not Deserialize with serde, because it requires borrowing a slice of references to strings, which is a variable-length data structure. The second is Deserialize with serde, but it causes expensive heap allocations. The third could be possible using bumpalo.
```rust
#[derive(Serialize, Deserialize)]
struct NotSerde<'a> {
#[serde(borrow)]
items: &'a [&'a str],
}
struct YesSerdeButRequiresHeapAllocation<'a> {
#[serde(borrow)]
items: Vec<&'a str>,
}
struct YesSerdeWithBumpalo<'a> {
#[serde(borrow)]
items: bumpalo::collections::Vec<'a, &'a str>,
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by examining bumpalo::collections::Vec and the Serde borrowing requirements shown in the issue. Determine how variable-length sequences of borrowed references could deserialize into that collection without using the global allocator. Done means the provided YesSerdeWithBumpalo shape is supported and the behavior is covered by relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100