Rename Box::into_raw_with_allocator to Box::into_raw_out?

Because Box::into_raw_with_allocator and Box::from_raw_in is pair, so why not rename Box::into_raw_with_allocator to Box::into_raw_out? It should be easier to understand.

Same as Vec.

IMO “out” doesn't make too much sense, because I read methods like Box::new_in as “create new box with value allocated in the given allocator”, and I don't see how I could interpret the word “out” in a similar manner in this context.

I do agree that the current naming seems a bit inconsistent. Since all the other ***_in methods actually do allocate something in the given allocator, but from_raw_in doesn't, it might be a sensible thing to instead rename the from_raw_in method to from_raw_with_allocator.

Also I noticed that Vec uses ***_with_alloc instead of ***_with_allocator. That's also inconsistent with Box. I feel like I might prefer the shorter alloc because allocator is really long. (But on the other hand allocator is slightly more clear, since alloc can also be “allocate” or “allocation”.)

6 Likes

How would that be easier to understand? The name would have no clear meaning, speaking as a native English speaker. If anything, Box::from_raw_in should be renamed to be clearer.

Convert into a raw pointer and take out an allocator. :rofl:

**_in is also ambiguous, I think it’s good for everyone to understand the meaning, the English in programming is just a symbol.

Far less so than out. Regardless, as I said,

In fact, the premise of this thread clearly indicates that the meaning of "from_raw_in" was unclear to at least one user! Count me in (heh) on the idea that it should be renamed to be clearer.

1 Like

Yes,maybe it can be rename to from_raw_with_alloc,and the same is into_raw_with_allocnew_with_alloc

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.