Relative Content

Tag Archive for rusttypes

Enforcing type transitions at compile-time in Rust

I want to create a mechanism that ensures resources are released, similar to how we can use drop. However I want to enforce more complex constraints using Rust’s type system. I would like to ensure that the user satisfies some constraints before they can drop their object. One way we could with files is we could have a type File<T: ResourceState> with

execute(&mut *transaction) vs. execute(&mut transaction)

I’m curious what the difference is between execute(&mut *transaction) and execute(&mut transaction) in my example since I didn’t think that transaction was a pointer to begin with but for some reason execute(&mut *transaction) satisfies the trait point while execute(&mut transaction) does not.