To be clear, I myself do find cloning reference counted pointers annoying (in my case it is Arc, not Rc, but I think that’s about the same thing).
The current one I’m facing is about hyper (or, actually, around a middleware that starts hyper servers based on configuration). Let’s say I have some global data I want to share to each request handler, I have code something like this (forgive any possible typos and such):
let data_srv = Arc::clone(&data);
Server::bind("127.0.0.1:8000")
.serve(move || {
let data = Arc::clone(&data_srv);
server_fn(move |req| {
req_handler(req, &data)
})
})
With the middleware thing, I actually get additional closure layer and additional Arc::clone(&data) layer.
This is not a big deal and when I have to write the code, I just write it (just adding clones until the compiler stops complaining).
However, I feel like this code is awkward. I would prefer to have the code more streamlined. I do acknowledge there’s a think that could be improved.
On the other hand, while the code looks hairy and is awkward to write, reading it needs minimal mind-power to reason about, the clumsiness is there in plain sight.
I prefer to err on the side of code that is ugly to look at, but doesn’t hide the ugliness. It does what it says on the box. If I want to err on the side of ergonomics and ease of use at the cost of clarity what happens and bad failure cases, I’m OK with picking a different language. There’s a big selection of those.