Result function

Hi,

I have a function declared as

pub fn get_trans_payload(trans_num_local : u32) -> Result< [u8;32], u16>

The compiler shows error

error[E0107]: wrong number of type arguments: expected 1, found 2
  --> src/get_trans_helper.rs:22:69
   |
22 | pub fn get_trans_payload(trans_num_local : u32) -> Result< [u8;32], u16>
   |                                                                     ^^^ unexpected type argument

what could be the error. I handle the function by calling as shown here

let trans_data_hash_value = get_trans_payload(trans_num_local).expect("Error");

May please give a clue.

Thanks,
S.Gopinath

You have imported a type alias for result. I can't tell which one, but it might look like this:

use std::io::Result;

Yes Alice.

I added

use std::result::Result

But I already use the crate serde_json

use serde_json::{Result,Value};

the compiler reported error as I have two Results and hence I removed
as

use serde_json::Value;

Or let me use with full namespace name ....

Thanks,
S.Gopinath

I use now like this

use std::result::Result as StdResult;
use serde_json::{Result,Value};

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.