Structs: A Set of Integers


The following intset program introduces Rust's struct. It defines an IntSet type, a set of integers that holds each value at most once, and stores the values in a Vec<i32>.

The impl IntSet block shows three kinds of functions:

The #[derive(Debug)] attribute on the struct has the compiler generate the code needed to print an IntSet with the {:?} format, as in println!("{:?}", a).

This zip file contains the complete crate.

src/main.rs