Conversation
|
What is the use case for this? |
I was working on an API boundary, and ended up with a function signature that looked like: which felt a bit redundant to me, as a This also allows for better ergonomics, as you can pass The most compelling piece of prior art (in my opinion) is |
There are no pointers in this code. Just references and they are zero cost in Rust, unless I'm missing something. The current expected approach is to use fn fill_path(pixmap: PixmapMut) {
pixmap.fill(Color::TRANSPARENT);
} |
|
But fn fill_path(mut pixmap: PixmapMut) {
pixmap.fill(Color::TRANSPARENT);
}would.
Unless the function is inlined, Rust references basically always compile down to pointers. So @robbie01 is indeed correct that it reduces the amount of indirection. It just likely won't last long as |
|
Good point. I don't remember why I have ended up using
That's strange. I thought that the only source of implicit indirection in Rust is trait objects. |
|
Ideally, we should follow some Rust API guidelines here, if there are any. I'm not sure what is "the correct" way of handling "mutable pointer wrappers". |
Also add PixmapRef::as_ref for parity
This allows you to get
PixmapMuts all the way down, which can simplify structs and function signatures.This also adds
PixmapRef::as_reffor parity, which is just aCopyalias.