LayerXcom / zero-chain

A privacy-preserving blockchain on Substrate
https://layerxcom.github.io/zerochain-book/
GNU General Public License v3.0
260 stars 42 forks source link

define type #161

Closed ashWhiteHat closed 2 years ago

ashWhiteHat commented 2 years ago

I defined the type to fix the following error.

error[E0282]: type annotations needed
   --> modules/indices/src/lib.rs:128:7
    |
128 |         let i = (try_index % enum_set_size).as_();
    |             ^ consider giving `i` a type

error[E0282]: type annotations needed
   --> modules/indices/src/lib.rs:156:8
    |
156 |             let item_index = (try_index % enum_set_size).as_();
    |                 ^^^^^^^^^^ consider giving `item_index` a type

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0282`.
error: could not compile `srml-indices`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

I defined set_index.as_() as usize to avoid following error.

error[E0282]: type annotations needed
   --> modules/indices/src/lib.rs:179:45
    |
179 |         let index = T::AccountIndex::sa(set_index.as_() as usize * ENUM_SET_SIZE + set.len());
    |                                         ----------^^^--
    |                                         |         |
    |                                         |         cannot infer type for type parameter `T` declared on the trait `As`
    |                                         this method call resolves to `T`
    |
    = note: type must be known at this point

error: aborting due to previous error

For more information about this error, try `rustc --explain E0282`.
error: could not compile `srml-indices`