-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Allow slices to be used in field #46445
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
37d76b4
to
0463168
Compare
I'm not sure that these changes are backwards-compatible, and also seem to go against the reason for using a trait object (making the output code small). Why are we making this change? What specifically does it allow; what are the tradeoffs? Overall, I don't think I'm the best reviewer for this, maybe r? @dtolnay Looks like Travis failed, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the gstreamer-sys change, would it work to use &&self.v[..]
instead of &self.v as &[i32]
? Playground
@dtolnay: it would indeed, but sounds more like a trick. :-/ At least, with this, it'd be more "logical" (if we could combine trait objects, it'd be even simpler). @Mark-Simulacrum: It fails because a test supposed to fail is now passing. Also, I have no issue having a debate over this PR. It was just a fix for a specific situation after all. |
I would prefer to stick with |
That'd be awesome! Any follow-up issue for dynamically sized trait objects? |
Hmm, it may be rust-lang/rfcs#2035 with something like |
Another possible fix would be a deref coercion where use std::fmt::Debug;
fn f(_trait_object: &Debug) {}
fn main() {
f("str"); // does not compile today. would coerce to &&str
f(&[1][..]); // does not compile today. would coerce to &&[{integer}]
} That would also make |
No description provided.