• candidate #1: `std::clone::Clone`


    struct Rec {
    width : u32,
    length : u32
    }
    fn process(rec1: Rec) -> Rec {
            let mut rec2 = rec1;
            rec2.width = 10;
        rec2.length = 11;
            rec2
    }
    fn main() {
                    let rec = Rec{width : 4, length : 16};
                    // rec.width = 100;
                    // rec.length = 10;
                     println!("{},{}", rec.width, rec.length);
                     let mut rec2 =rec.clone();
                     rec2.width = 100;
                     rec2.length = 10;
                     println!("{},{}", rec2.width, rec2.length);
                     let rec3 = process(rec);
                     println!("{},{}", rec3.width, rec3.length);
    }
    [root@bogon clone]# cargo build
       Compiling own v0.1.0 (/data2/rust/clone)
    error[E0599]: no method named `clone` found for struct `Rec` in the current scope
       --> src/main.rs:16:22
        |
    1   | struct Rec {
        | ---------- method `clone` not found for this
    ...
    16  |          let mut rec2 =rec.clone();
        |                            ^^^^^ method not found in `Rec`
        |
        = help: items from traits can only be used if the trait is implemented and in scope
        = note: the following trait defines an item `clone`, perhaps you need to implement it:
                candidate #1: `std::clone::Clone`
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0599`.
    error: could not compile `own`.
    
    To learn more, run the command again with --verbose
  • 相关阅读:
    开始系统的研究区块链技术了
    基于Centos7的比特币源码编译
    WTForms
    flask-session
    抽屉之Tornado实战(5)--点赞与评论树
    零碎知识点
    flask信号
    MetaClass
    flask系列
    flask源码剖析--请求流程
  • 原文地址:https://www.cnblogs.com/dream397/p/14194735.html
Copyright © 2020-2023  润新知