admin管理员组

文章数量:1123042

In rust, is there difference between <Type>::mothod() AND Type::method() in Rust? How to simply implement some example to see easily the difference?

example: .rs#L33

  • rocket swagger github sample

In rust, is there difference between <Type>::mothod() AND Type::method() in Rust? How to simply implement some example to see easily the difference?

example: https://github.com/GREsau/okapi/blob/d3bc6583dd828d37dc22f010ca8d51bfd1866a0a/rocket-okapi/src/response/responder_impls.rs#L33

  • rocket swagger github sample
Share Improve this question edited 1 hour ago cafce25 27k5 gold badges41 silver badges52 bronze badges asked 2 hours ago 김종현김종현 431 silver badge3 bronze badges 1
  • Take a look: github.com/rust-lang/rust/issues/88799 . – Eugene Sh. Commented 2 hours ago
Add a comment  | 

1 Answer 1

Reset to default 1

They mean the same thing. However, Type::method() can only be used when Type is also a path. Other types may require using < > like:

  • <[u8]>::method()
  • <&str>::method()
  • <(u8, u8)>::method()
  • <Vec<u8>>::method() (though Vec::<u8>::method() does work too)

本文标签: syntaxDifference between ltTypegtmethod() AND Typemethod() in RustStack Overflow