Allow `Waker::from` to accept trait object `Arc<dyn Wake>`
Open
Nobody has claimed this yet.
C-feature-request
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I don't know it this issue is duplicate.
Consider this code snippet
use std::{sync::Arc, task::{Wake, Waker}};
trait Foo: Send + Sync {}
impl Wake for dyn Foo {
fn wake(self: Arc<Self>) {
todo!()
}
}
struct Object;
impl Foo for Object {}
fn main() {
let foo = Arc::new(Object) as Arc<dyn Foo>;
Waker::from(foo);
}
Currently this code doesn't work, Because Waker::from cannot be used with Arc<dyn Wake>
It would be ideal if Waker::from could support W: ?Sized objects by relaxing the Sized bound on W.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open library/alloc/src/task.rs at the linked Waker::from implementation and reproduce the provided Rust snippet on stable to confirm the current failure. Trace the conversion's bounds and update it so Arc is accepted; done when the snippet compiles and existing standard-library checks remain passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100