Skip to content

smartstring breaks std::string::String? #7

Open
@miquels

Description

@miquels

smartstring 0.2.3.
rust 1.44.1

this fails:

$ cat main.rs
use smartstring;

fn main() {
    println!("{}", "Hello".to_string() + &(" World".to_string()));
}

in a weird way:

$ cargo run
   Compiling smartstring-test v0.1.0 (/home/mikevs/devel/rust/smartstring-test)
warning: unused import: `smartstring`
 --> src/main.rs:1:5
  |
1 | use smartstring;
  |     ^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0277]: cannot add `&std::string::String` to `std::string::String`
 --> src/main.rs:4:40
  |
4 |     println!("{}", "Hello".to_string() + &(" World".to_string()));
  |                                        ^ no implementation for `std::string::String + &std::string::String`
  |
  = help: the trait `std::ops::Add<&std::string::String>` is not implemented for `std::string::String`

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
error: could not compile `smartstring-test`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions