pub trait FromRef<S> {
// Required method
fn from_ref(state: &S) -> &Self;
}Expand description
A part of the app state that State can extract on its own, e.g. State<&Db> for an
AppState with a db field.
It borrows: a part is a field of the state, which views borrow and
hooks and loads clone. Every state is a part of itself.
use egui_kit::extract::FromRef;
#[derive(Clone)]
struct AppState {
db: Db,
}
#[derive(Clone)]
struct Db;
impl FromRef<AppState> for Db {
fn from_ref(state: &AppState) -> &Db {
&state.db
}
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".