Re:Why did we choose Rust to develop TiKV?
by Koshkin on Wednesday September 27, 2017 @09:38AM
(#15347653)
They don't, and it is (or should be) considered bad practice for functions, in general, to take/return smart pointers. Normally these should only be used as variables or class members; functions, on the other hand, should take/return raw pointers (except some special cases) or, better yet, references (except when there is a need to check for null value).
[ Parent
| on HN ]
Re:Why did we choose Rust to develop TiKV?
by Tyr42 on Wednesday September 27, 2017 @11:27AM
(#15348744)
I disagree? Functions which allocate things returning unique_ptr is much clearer than returning a raw pointer. Clear ownership being passed, as opposed to maybe just having a view into some internal buffer.
I mean, if you only view functions as being called for side effects, then yeah maybe. But if you're constructing a data pipeline, unique_ptr in and out makes a lot of sense.
Re:Why did we choose Rust to develop TiKV?
by Koshkin on Wednesday September 27, 2017 @01:03PM
(#15349822)
Sure, and that is a special case I was referring to. (Another one would be a class factory method returning a unique pointer to an interface.)
In general, though, passing a unique_ptr around is a bit cumbersome as this requires calling std::move way too often.