-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Consider creating a version of struct with different defaults (class?) #10357
Comments
Nominating |
I like this. It seems weird (and an abstraction leak) for a type to be either copyable or not based on information (private fields) that you can't see. |
I'm strongly against doing this. It would make built-in types even more special-cased and further reduce the ability to define full replacements in the standard library. A built-in type shouldn't be able to do anything a library type can't do. |
Hmm, possibly? Depends if it were just a matter of defaults, or More and more I am coming to the opinion that we need a distinct
whereas a struct would be what we know and love today. The last point is something that's been rattling around in my brain |
I think allowing implicit copies is by far the common case, so while it makes sense to have |
@thestinger, you have a point. On the other hand, with the rule that a struct is implicitly copyable if its fields are, it means that for a struct with private fields,we're telling people to look at private declarations to figure out whether it's copyable. But they shouldn't be looking at that! It's private for a reason! Doesn't that bother you a little bit? |
The documentation generator could tag types that have move semantics. I agree it's currently a problem, but I think it's a rustdoc problem :). |
It should also tag whether types are Freeze and/or Send. |
I don't think that memory safety is the only reason for a type to be not implicitly copyable and I am not at all sure that "most" types ought to be copyable. I think that'll depend quite a bit on the specifics -- many types ought not to be copied for semantic reasons. |
I don't think anyone has yet mentioned on this bug: there is the If you add that as a field to a struct, it becomes non-copyable. |
We can leave the semantics as they are for 1.0, and worry about adding something like the |
|
If anybody is still interested in this, an official RFC should be filed. https://github.com/rust-lang/rfcs/blob/master/active/0001-rfc-process.md |
Stop doc_markdown requiring backticks on links to external websites Fixes rust-lang#10302 This lint currently checks that any link should be enclosed with `backticks` if the title looks like a lang item. This PR changes the lint to only run on internal links. External links, indicated by `http` or `https`, are skipped. This PR also reorganises `pulldown_cmark` imports to bypass the clippy lint enforcing 100 line functions. --- changelog: Stop doc_markdown requiring backticks on links to external websites
Issue #8380 highlights the fact that via implicitly copyability we have a similar situation to C++ copy constructors: one must "opt out" of copyability. Perhaps we can do better? One thought is to have structs with private fields by not implicitly copyable.
UPDATE: Changing title to reflect a desire for something that works like a struct but with distinct defaults. See this comment
The text was updated successfully, but these errors were encountered: