Skip to content
New issue

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

Make Read and Write generics friendlier to dynamic dispatch #380

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

r-ml
Copy link
Contributor

@r-ml r-ml commented Mar 6, 2024

By relaxing size constraint.
Avoid double indirection. Instead of having to pass &mut &mut dyn AsyncWrite, we can pass &mut dyn AsyncWrite, for example. The use case for dynamic dispatch is object-safe traits. Static dispatch is unaffected.

tokio and std do the same thing, for example tokio::io::copy and std::io::copy.

Example of the problem and desired outcome.

By relaxing size constraint.

Avoid double indirection. Instead of having to pass
`&mut &mut dyn AsyncWrite`, we can pass `&mut dyn AsyncWrite`, for
example. The use case for dynamic dispatch is object-safe traits.

Static dispatch is unaffected.
@r-ml r-ml force-pushed the dynamic-dispatch-friendly branch from a7c9ef6 to e9804eb Compare March 6, 2024 01:20
@durch durch changed the base branch from master to develop June 14, 2024 20:30
@durch durch merged commit 3493966 into durch:develop Jun 14, 2024
1 check passed
@durch
Copy link
Owner

durch commented Jun 14, 2024

@r-ml nice one! Thank you!

durch pushed a commit that referenced this pull request Jun 14, 2024
By relaxing size constraint.

Avoid double indirection. Instead of having to pass
`&mut &mut dyn AsyncWrite`, we can pass `&mut dyn AsyncWrite`, for
example. The use case for dynamic dispatch is object-safe traits.

Static dispatch is unaffected.
durch pushed a commit that referenced this pull request Jun 14, 2024
By relaxing size constraint.

Avoid double indirection. Instead of having to pass
`&mut &mut dyn AsyncWrite`, we can pass `&mut dyn AsyncWrite`, for
example. The use case for dynamic dispatch is object-safe traits.

Static dispatch is unaffected.
durch pushed a commit that referenced this pull request Jun 14, 2024
By relaxing size constraint.

Avoid double indirection. Instead of having to pass
`&mut &mut dyn AsyncWrite`, we can pass `&mut dyn AsyncWrite`, for
example. The use case for dynamic dispatch is object-safe traits.

Static dispatch is unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants