[Rust] typeof のようにその値の型が知りたいとき

[Rust] typeof のようにその値の型が知りたいとき

 

fn main() {
let mut my_number = 32.90;
my_number.what_is_this();
}

 

持っていないメソッドを実行する

   Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `what_is_this` found for type `{float}` in the current scope
 --> src/main.rs:3:11
  |
3 | my_number.what_is_this();
  |           ^^^^^^^^^^^^ method not found in `{float}`

error: aborting due to previous error

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

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

怒られてfloatの中にそのようなメソッドはないと言われる
floatだとわかる

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です