sos-os / alarm

ALARM: Another Library for Allocating and Releasing Memory
Apache License 2.0
8 stars 6 forks source link

Iter::extend implementation for singly-linked list #38

Open hawkw opened 6 years ago

hawkw commented 6 years ago

implementation for boxed lists can be based on 1dcb155eb5150be342c3abc1c0fe0f7fd26b09e3, and for UnsafeRef can be based on a15318754af30f1ffc64c1f40a8f77d217ad324d (these commits add implementations for doubly-linked lists).

https://github.com/hawkw/alarm/blob/2b0614ae6253ba44ffab2f6b8d3556bee003935b/intruder_alarm/src/doubly/mod.rs#L428-L464

the implementation for lists of UnsafeRefs depends on #37

leshow commented 6 years ago

these are implemented already I think. Can I ask why we'd want to use UnsafeRef when we have Option<NonNull>, I was under the impression the latter is optimized to be zero-sized when it's None. Under what circumstances do we want to give up that safety?

hawkw commented 6 years ago

An UnsafeRef is just a NonNull<T> without the Option --- it's for use as an owning reference to a T, which should always exist. It's not wrapped in an Option because we don't expect it to ever be empty and want to enforce that