Skip to content

Instantly share code, notes, and snippets.

View sffc's full-sized avatar

Shane F. Carr sffc

View GitHub Profile
@sffc
sffc / car_race.rs
Created February 12, 2025 09:24
Examples from Comprehensive Rust @ University of Bergen, January 2025
#[derive(Debug)]
struct CarRace {
name: String,
laps: Vec<i32>,
}
impl CarRace {
// No receiver, a static method
fn new(name: &str) -> Self {
Self { name: String::from(name), laps: Vec::new() }