Open jwerle opened 4 years ago
sure, open a PR please
looks like its heap allocated. std is heap free, since zz's main goal is to be usable for systems without dynamic memory.
For good design on heapless data structures look at japarics heapless. I asked for the publication which hopefully has more things to learn from. https://github.com/japaric/heapless/issues/146
Stuff @whitequark does is also interesting to read
https://lab.whitequark.org/notes/2016-12-17/owning-collections-in-heap-less-rust/
This is a great read. Thank you. I'll remove heap allocations today! I think the ergonomics of the list will be pretty straightforward for stack allocations:
new+16 mut list = zxlist::init(); // a list that can container 16 items
list.rpush("hello");
list.rpop(); // "hello"
I've noticed your usage of make()
for constructor functions. Is that the convention that should be followed? I'll convert my init()
constructors to make()
if so
yep, that api looks good.
note https://github.com/zetzit/zz/issues/53. for discussion on generic list types.
convention for constructors is that it needs to take a new self pointer, that is "Type mut new*self". new doesnt mean anything yet, but if you dont add it, it'll break later when i finish memory initialization trackin.
there's no convention for the function name. you could have multiple constructors that construct different states, like default, none, etc. Think of it as "what state is the type in after the constructor is called"
i wonder if @richfelker would have more reading material on designing heapless data structures. Rich does incredibly readable C code, so any input would be appreciated.
sized void should make this possible now
I have a small list implementation here that we could port over