sos-os / alarm

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

singly-linked list impls for `UnsafeRef` #37

Closed hawkw closed 6 years ago

hawkw commented 6 years ago

follow-on from #8.

this is going to look pretty similar to the code I added in a15318754af30f1ffc64c1f40a8f77d217ad324d.

hawkw commented 6 years ago

suspect @amanjeev may want this one.

amanjeev commented 6 years ago

Thank you for adding me to this repo. I assigned this to myself.

hawkw commented 6 years ago

@amanjeev fantastic, I figured you might be interested in this issue! 🙂

I'm trying to add anyone who's made a significant contribution as repo collaborators so they can be assigned to issues and to review PRs. You'll still need approval from me to merge to master. However, when I add a CODEOWNERS file, I'll probably add you as an owner for the singly-linked list module, so you'll automatically be added as a reviewer for that code.

amanjeev commented 6 years ago

Hehe thank you! I am actually interested in this entire peoject. The name SOS spoke to me. :-)

amanjeev commented 6 years ago

Does it makes sense to have FromIter in singly's case?

I have added it but it I am confused whether it should add in reverse order or not. For the time being I have left it as-is and in the test I have --

...
        let mut nlist = UnsafeList::from_iter(list_a.rev());  // adding in reverse on your own...
...
hawkw commented 6 years ago

@amanjeev I think that's okay; what I would probably do is add a note in the RustDoc comments for the singly::List type (i.e. somewhere in here) saying that, as the singly-linked list only provides stack operations, FromIterator will return a new list in reverse order.

The alternative --- creating a temporary vector to store the iterator's contents in, and then push them in reverse order --- won't work in #[no_std] environments, since we can't allocate Vecs, so I think doing it this way is fine, as long as it's documented.