rust - How do I extract a value from a tuple struct? -
i have object of struct 1 field external library, defined as: pub struct someid(pub i64);
using println!
print object shows this, example: someid(123)
i created own struct:
#[derive(debug)] pub struct { pub id: i64, }
and i'm trying put value external struct someid
field id
in struct something
:
let test = { id: ?? };
or extract value struct someid
:
let test: i64 = ??;
you should try
let test = { id: external_struct.0 };
or, second question,:
let test = external_struct.0;
these structs , of form , struct structname(variables...)
called tuple structs , acts similar tuples
in rust.
Comments
Post a Comment