upvote
Yes. duck takes ownership of the vector by moving it into its internal storage.

As a bonus, if you tried passing in an lvalue, it will reject the input unless you add the "copyable" trait, so it ends up mitigating some hidden copies.

reply
Well, you’ve certainly convinced me to read your library.

Thanks for the blog post.

reply
No problem! Hope you enjoy :)
reply
Is there another option? Or were you asking if it leaks memory?

Maybe you were asking if it implements custom destructors? GC?

reply
> Or were you asking if it leaks memory?

yeah,

If variable c where of type void* instead of duck<Container>, the assignment on line 13 would leak the memory used by the vector<int>.

reply