Skip to content

Instantly share code, notes, and snippets.

@MabezDev
Created January 7, 2020 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MabezDev/ecbf8546fc59a55ea404513be15868e3 to your computer and use it in GitHub Desktop.
Save MabezDev/ecbf8546fc59a55ea404513be15868e3 to your computer and use it in GitHub Desktop.
use rtfm::Mutex; // or mutex_trait
pub enum Operation<T: Mutex<T = ...> {
FileSystem(T) // Note: can't use impl Mutex<T = Filesystem> here, so we have to introduce the T type param
// ...
}
// If the `Operation` enum is buried deep within a type, it poisens that type with the same type parameter
pub struct Server<T: Mutex<T = ...> {
op: Operation<T>
}
// question: is it possible to avoid the generic type parameter when using any Mutex with rtfm?
// internally, rtfm uses resource proxies that implement the Mutex trait.
// Is it safe to use these types or are they considered an implementation detail?
// I'm guessing the latter as `mod Resources` is private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment