News for hackers. Stuff that matters.
Re:Should Small Rust Structs be Passed by-copy or by-borrow? by 411111111111111 on Saturday December 31, 2022 @04:29PM (#34200971)
This is about rust through and this isn't really possible there (at least to my knowledge). You should get a compiler error if you attempt this.

I got very little experience in rust either though, so there might be a way I'm just not aware of to circumvent this check

Re:Should Small Rust Structs be Passed by-copy or by-borrow? by maxbond on Saturday December 31, 2022 @09:23PM (#34202945)
Indeed, you can use interior mutability to accomplish this:

https://doc.rust-lang.org/reference/interior-mutability.html

Usually (read: near universally) something that provides interior mutability will implement a runtime check to protect you (eg, a lock), but you could make a footgun if you were cavalier about it. And recent I misused a framework (I kept a value returned by the framework around that should've been dropped) without realizing it was holding locks internal to the framework, and ended up with a tricky to diagnose deadlock (though only tricky before I hadn't read the documentation as closely as I should've).