๐Ÿฆ„ Rust Generic Structs

= a struct, with a generic type

Constant parameters

You can pass a constant parameter to a generic struct like so:

struct Person<const AGE: i8> {
	age = AGE
}

impl <const AGE: i8> {
	fn new (AGE: i8) -> Person<AGE> {
		Person { age: AGE}
	}
}

Example

struct Person<T> {
	name: T
}

Impl can be type specific:

impl Person<String> {
	...
}