Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

rust typedef

// A type alias defines a new name for an existing type. 
// Type aliases are declared with the keyword type. 
// Every value has a single, specific type, but may 
// implement several different traits, or be compatible
// with several different type constraints.
type Point = (u8, u8);
let p: Point = (41, 68);

// A type alias to a tuple-struct or unit-struct cannot 
// be used to qualify that type's constructor:
struct MyStruct(u32);

use MyStruct as UseAlias;
type TypeAlias = MyStruct;

let _ = UseAlias(5); // OK
let _ = TypeAlias(5); // Doesn't work
 
PREVIOUS NEXT
Tagged: #rust #typedef
ADD COMMENT
Topic
Name
9+6 =