Skip to content

Why isn't the Copy trait implemented for String? #123263

Closed
@Cr0a3

Description

@Cr0a3

Why isn't the Copy trait implemented for the type String?

I tried this code:

#[derive(Copy, Clone)]
enum MyEnum {
  abc(String),
}

But i got following error:

error[E0204]: the trait `Copy` cannot be implemented for this type
 --> src\test.rs:1:17
  |
1 | #[derive(Clone, Copy)]
  |                 ^^^^
...
w |     Abc(String),
  |           ------ this field does not implement `Copy`
  |
  = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-discussionCategory: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions