Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Rust

Idiom #276 Insert an element in a set

Insert an element e into the set x.

use std::collections::HashSet
x.insert(e);

x has type mut HashSet

returns false if the set already had the value present, true otherwise
#include <set>
x.insert(e);

New implementation...