We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
&dyn Trait
&(dyn Trait + Send)
the Send bound in &(dyn Trait + Send) is useless as &T is only Send for T: Sync. We may still rely on that Send bound in other ways however:
Send
&T
T: Sync
use std::rc::Rc; use std::thread; trait Trait { fn foo(&self) where Self: Send; } impl<T: Clone + 'static> Trait for T { fn foo(&self) where Self: Send, { let clone: T = self.clone(); thread::spawn(move || clone.clone()); } } fn main() { let rc = Rc::new(String::from("hello")); let x: &dyn Trait = &rc; loop { println!("strong count: {}", Rc::strong_count(&rc)); let y: &(dyn Trait + Send) = unsafe { std::mem::transmute(x) }; y.foo(); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
the
Send
bound in&(dyn Trait + Send)
is useless as&T
is onlySend
forT: Sync
. We may still rely on thatSend
bound in other ways however:The text was updated successfully, but these errors were encountered: