|
|
|
|
|
by ragnese
2123 days ago
|
|
> Does Rust have something like C++'s const methods? Where you can have a method that mutates a member, but doesn't logically mutate from the caller's perspective? Yes! "Interior mutatbility" is the term to search for. In Rust, you'd wrap the field in a RefCell<T>. Many connection-pool implementations use interior mutability to manage the connections transparently to the caller. Interior mutability is basically what, e.g. OCaml, does by default. In Rust, it's opt-in. Yeah, DB ops are always a sticking point for figuring out how to write my APIs. |
|