api: "YAML JSON TOON Database"
version: "1.0.0"
format: "json"
dataset:
  id: 19
  slug: "rust-language-features"
  title: "Rust Language Features"
  description: "Core Rust programming language concepts: ownership, borrowing, lifetimes, traits, and concurrency."
  category: "Programming Languages"
  category_slug: "programming-languages"
  tags: "rust,systems,programming,memory-safety,concurrency"
  view_count: 0
  created_at: 1777673262
  updated_at: 1777673262
data:
  features:
    - name: "Ownership"
      category: "Memory Management"
      description: "Each value has a single owner; when owner goes out of scope, value is dropped."
      example: "let s1 = String::from(\"hello\"); let s2 = s1; // s1 is no longer valid"
    - name: "Borrowing"
      category: "Memory Management"
      description: "References (&) allow you to refer to some value without taking ownership."
      example: "let r = &s; // immutable borrow\nlet r_mut = &mut s; // mutable borrow (exclusive)"
    - name: "Lifetimes"
      category: "Memory Management"
      description: "Annotations ensure all references are valid; compiler enforces lifetime rules."
      example: "fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { if x.len() > y.len() { x } else { y } }"
    - name: "Traits"
      category: "Abstraction"
      description: "Define shared behavior; similar to interfaces in other languages. Use generics with trait bounds."
      example: "trait Summary { fn summarize(&self) -> String; }\nimpl Summary for NewsArticle { ... }"
    - name: "Pattern Matching"
      category: "Control Flow"
      description: "Match expressions check enum variants, destructure structs, and bind variables."
      example: "match value { Some(x) => x, None => 0, Err(e) => panic!(\"{}\", e) }"
    - name: "Concurrency (Fearless)"
      category: "Concurrency"
      description: "Thread-safe by compile-time checks: Send and Sync traits guarantee no data races at runtime."
      example: "let handle = thread::spawn(|| { for _ in 0..10 { println!(\"thread\"); } });\nhandle.join().unwrap();"
    - name: "Error Handling (Result<T,E>)"
      category: "Error Handling"
      description: "Enums Result<T,E> and Option<T> force explicit handling; no null or unchecked exceptions."
      example: "let f: Result<File> = File::open(\"file.txt\");\nmatch f { Ok(file) => ..., Err(e) => eprintln!(\"{}\", e) }"
    - name: "Zero-Cost Abstractions"
      category: "Performance"
      description: "High-level constructs compile to assembly as efficient as hand-written C; no runtime overhead."
      example: "Iterators: v.iter().map(|x| x * 2).filter(|x| x > 10).collect::<Vec<_>>();"
