There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

lolcatnip ,

Looks like the author missed my main complaint about Rust mutexes, which is that the lock method returns a Result. There should be a try_unlock method for when someone actually wants to handle the rather obscure failure case, and the name lock should be used for a method that panics on failure but returns a value that doesn’t need to be unwrapped first. I see the current arrangement as being about as sensible as having array subscripting return a Result to handle the case of a failed bounds check.

r00ty Admin ,
r00ty avatar

I started playing with rust last week (just converting a couple of C# projects so far), and I'm going to say that once you understand that mutexes/rwlocks are wrappers around the actual data, it (to me at least) feels better.

Don't get me wrong, it's an absolute headache for anyone that's acquired intermediate or better skill in one of the Cx languages. The paradigm shift is still hitting me hard. But this was one of the differences I actually think is an improvement in probably most use cases.

5C5C5C ,

It’s a massive win, and I would question the credibility of any systems programmer that doesn’t recognize that as soon as they understand the wrapper arrangement. I would have to assume that such people are going around making egregious errors in how they’re using mutexes in their C-like code, and are the reason Rust is such an important language to roll out everywhere.

The only time I’ve ever needed a Mutex<()> so far with Rust is when I had to interop with a C library which itself was not thread safe (unprotected use of global variables), so I needed to lock the placeholder mutex each time I called one of the C functions.

noddy ,

Wrapping a value in a mutex just makes sense. After learning a bit of Rust I made a similar mutex wrapper in C++ when I had to protect a class member in a C++ project. I just had to change the type in the declaration, and bam the compiler tells me about all places this member was accessed. Much easier than using some buggy ‘find all references’, potentially forgetting a few places.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • lifeLocal
  • goranko
  • All magazines