197g / 197g/static-alloc

Eccentric `FixedVec` interfaces–A wish list

Đang mở
#11 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement help wanted
Ngôn ngữ chính
Rust
Star
62
Fork
11
Merge trung bình
3 giờ 45 phút
Pull request đã merge (30 ngày)
5

Mô tả

Not managing the allocation within `FixedVec` makes some rather outlandish interfaces necessary but also possible. Each should get forked into a separate issue when it gets a better draft or is being worked on. This is a quick sketch/wish list.

* ~~`impl DoubleEndedIterator for Drain<'_, T> { }`~~ (closed in #19)
* `fn FixedVec::extend_from_within(&mut self, idx: impl SliceIndex<[T]>)`
`fn FixedVec::fill_from_within(&mut self, f: impl FnOnce(&[T]) -> impl Iterator)`
The elements can be borrowed when extend the `FixedVec` as we *never* have to relocate them. That's quite awesome.
* `Drain::skip(&mut self)`. Move an element to the start, then advance over it as if it were not part of the original `drain(..)` invocation. This would be a useful precursor to `DrainFilter` as well. An symmetric operation may put it in-front of the tail but needs some naming discussion (`skip_back` is confusing when double ended iterator should provide the same for the other side).
* ```rust
struct SpliceVec<'a, T> {
// A vector view on the contents but forgotten instead of dropped.
vec: ManuallyDrop>,
// Unused tail and capacity of the underlying vec.
tail_len: usize,
tail_capacity: usize,
}

impl FixedVec<'_, T> {
splice_vec(&mut self) -> SpliceVec<'_, T>;
}

impl<'a, T> Deref for SpliceVec<'a, T> {
type Target = FixedVec<'a, T>;
// ..
}
```

A splice that works strictly in-place. The elements in the tail of the original `FixedVec` may be manually shifted backwards to provide more capacity to the splice. No more work is involved exactly if the vector within the `Splice` is empty when it is dropped.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

The issue describes several potential extensions to the FixedVec type in the static-alloc crate. Start by examining the existing FixedVec and Drain implementations in the source code to understand the current interfaces. Look for the struct definitions and method signatures mentioned. The goal is to design and implement one of the proposed features, such as extend_from_within or a SpliceVec type, ensuring they work in-place without relocating elements. Testing would involve adding new unit tests to verify the behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust
Lĩnh vực
backend-api-design
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.