I'm trying to learn how to do locks in Rust the way they work in Go. With Go I can do something like:
type Info struct {
sync.RWMutex
height uint64
verify bool
}
If I have some function/method acting on info I can do this:
func (i *Info) DoStuff(myType Data) error {
i.Lock()
//do my stuff
}
It seems like what I need is the sync.RWMutex, so this is what I have tried:
pub struct Info {
pub lock: sync.RWMutex,
pub height: u64,
pub verify: bool,
}
Is this the correct approach? How would I proceed from here?