Type Aliases

Simfony currently doesn't support Rust-like structs for organizing data.

#![allow(unused)]
fn main() {
struct User {
  active: bool,
  id: u256,
  sign_in_count: u64,
}
}

Simfony programmers have to handle long tuples of unlabeled data, which can get messy.

#![allow(unused)]
fn main() {
(bool, u256, u64)
}

To help with the situation, programmers can define custom type aliases. Aliases define a new name for an existing type. In contrast, structs define an entirely new type, so aliases are different from structs. However, aliases still help us to make the code more readable.

#![allow(unused)]
fn main() {
type User = (bool, u256, u64);
}

There is also a list of builtin type aliases. These aliases can be used without defining them.

Builtin AliasDefinition
Amount1Either<(u1, u256), u64>
Asset1Either<(u1, u256), u256>
Confidential1(u1, u256)
Ctx8(List<u8, 64>, (u64, u256))
Distanceu16
Durationu16
ExplicitAmountu256
ExplicitAssetu256
ExplicitNonceu256
Feu256
Ge(u256, u256)
Gej((u256, u256), u256)
Heightu32
Locku32
Messageu256
Message64[u8; 64]
NonceEither<(u1, u256), u256>
Outpoint(u256, u32)
Point(u1, u256)
Pubkeyu256
Scalaru256
Signature[u8; 64]
Timeu32
TokenAmount1Either<(u1, u256), u64>