Calling trait static method from another static method (rust)

后端 未结 2 919
北恋
北恋 2021-01-06 07:13

Can you call a trait static method implemented by types from another trait static method implemented in the trait? For example:

trait SqlTable {
  fn table_         


        
2条回答
  •  甜味超标
    2021-01-06 08:14

    • Yes, you can call a trait static method [implemented by types] from another trait static method [implemented in the trait].
    • Static methods are always called on a trait like SomeTrait::some_method().
    • Where there is no Self or self in [a trait] function signature, it is not callable at present. The standard workaround until UFCS comes is to take an argument _: Option and pass it None::.

    See original question for code that (as of today) compiles.

提交回复
热议问题