Associated Types
Front
Active users
1
All-time users
1
Favorites
0
Last updated
1 year ago
Date created
Sep 7, 2023
Rust Concepts
(15 cards)
Associated Types
A way to associate a type placeholder with a trait, making it more generic.
Ex: trait Iterator { type Item; fn next(&mut self) -> Option<Self::Item>; }
async/await
Syntax for writing asynchronous code in Rust. Introduced in Rust 1.39. Async traits are not supported currently by default
Ex: async fn fetch_data() -> Result<Data, Error> { ... }
Lifetimes
Annotations to relate the lifetimes of multiple references.
Ex: fn longest<'a>(s1: &'a str, s2: &'a str) -> &'a str
Fn
, FnMut
, and FnOnce
Traits
Traits representing different types of function pointers and closures.
Ex: fn call_with_one<F>(func: F) where F: Fn(i32) -> i32 { func(1) }
Attributes
Metadata applied to modules, functions, or items. Can be used for conditional compilation, linting, etc.
Ex: #[derive(Debug)] struct MyStruct;
PhantomData<T>
A zero-sized type used to mark certain generic types in structs without storing them.
Ex: struct Wrapper<T> { data: u32, phantom: PhantomData<T> }
Rc<T>
and Arc<T>
Reference-counted types. Rc is for single-threaded scenarios, while Arc is atomic and can be used in multi-threaded contexts.
Ex: let rc = Rc::new(vec![1.0, 2.0, 3.0]);
Concurrency
Rust's approach to thread safety. Ensures data races can't happen by design.
Ex: let handle = thread::spawn(move || { ... });
unsafe
Keyword
A keyword to denote operations that bypass Rust's safety checks. Used for FFI, raw pointers, and more.
Ex: unsafe { some_unsafe_function() };
Pattern Matching
Allows deconstructing values and checking their shapes.
Ex: match value { Some(x) => println!("{}", x), None => (), }
Pin<T>
A pointer type to ensure the data it points to will never be moved again. Essential for certain async operations.
Ex: let mut pinned = Box::pin(data);
Box<T>
A heap-allocated pointer. Useful for transferring ownership without copying the data.
Ex: let b = Box::new(5);
Drop
Trait
Allows customization of what happens when a value goes out of scope.
Ex: impl Drop for MyType { fn drop(&mut self) { println!("Dropped!"); } }
Generics
Allows writing code that is abstracted over types.
Ex: struct Point<T> { x: T, y: T }
Deref
and DerefMut
Traits
Allows overloading of dereference operators. Enables custom pointer types to behave like references.
Ex: impl Deref for MyType { type Target = T; ... }
Ash API Reference
(0 cards)
Winit API Reference
(7 cards)
Event (winit)
An enum in winit representing various events, including window events, device events, and user input events.
KeyboardInput
Represents a keyboard input event in winit. Contains information about the state of the key (pressed or released) and which key was affected.
ControlFlow
Determines how the winit event loop should proceed after processing events. Has variants like Poll (continuously run) and Wait (wait for events).
ElementState
Represents the state of a button or key in winit. Has two variants: Pressed and Released. Used to determine the current state of a keyboard key or mouse button.
WindowEvent
An enum in winit representing events specifically related to the window, such as resizing, moving, or closing.
EventLoop
The main event loop provided by winit. Responsible for handling all events and driving the application forward.
VirtualKeyCode
An enum in winit representing all possible keys on a keyboard. Allows checking for specific keys, like VirtualKeyCode::A for the "A" key.
Vulkan API
(0 cards)
GPU Programming Concepts
(0 cards)