Code Monkey home page Code Monkey logo

Comments (3)

123zmz123 avatar 123zmz123 commented on June 27, 2024

image
请问作者,我知道x y 是pattern variable, 但是为何传入的时候要加*号,个人能力有限找遍了rust文档没有定位到答案,谢谢

from luago-book.

zxh0 avatar zxh0 commented on June 27, 2024

你好。可以试着去掉*,编译一下,看看编译错误应该就理解了:

$ cargo build
   Compiling ch05 v0.1.0 (luago-book/code/rust/ch05)
error[E0308]: mismatched types
   --> src/state/arith_ops.rs:104:55
    |
104 |                     return Some(LuaValue::Integer(iop(x, y)));
    |                                                       ^
    |                                                       |
    |                                                       expected `i64`, found `&i64`
    |                                                       help: consider dereferencing the borrow: `*x`

error[E0308]: mismatched types
   --> src/state/arith_ops.rs:104:58
    |
104 |                     return Some(LuaValue::Integer(iop(x, y)));
    |                                                          ^
    |                                                          |
    |                                                          expected `i64`, found `&i64`
    |                                                          help: consider dereferencing the borrow: `*y`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: could not compile `ch05`

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

from luago-book.

123zmz123 avatar 123zmz123 commented on June 27, 2024

谢谢提醒😃

from luago-book.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.