Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }
Expand description

Structure to represent a nonlinear factor graph

Main usage will be via add_factor to add new factors to the graph. Also of note is the linearize function that returns a linear (aka Gaussian) factor graph.

Since the graph represents a nonlinear least-squares problem, during optimization it will be iteratively linearized about a set of variables and solved iteratively.

   assign_symbols,
   containers::{Graph, FactorBuilder},
   residuals::PriorResidual,
   robust::GemanMcClure,
   traits::*,
   variables::SO2,
};
let mut graph = Graph::new();
graph.add_factor(factor);

Implementations§

Source§

impl Graph

Source

pub fn new() -> Self

Examples found in repository?
examples/graph_viz.rs (line 25)
24fn main() {
25    let mut graph = Graph::new();
26    let id = SE2::identity();
27
28    graph.add_factor(fac![PriorResidual::new(id.clone()), X(1)]);
29    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(1), X(2))]);
30    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(2), X(3))]);
31
32    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(1), X(4))]);
33    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(2), X(4))]);
34    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(3), X(5))]);
35
36    rerun_viz(&graph);
37}
More examples
Hide additional examples
examples/readme.rs (line 21)
11fn main() {
12    // Make all the values
13    let mut values = Values::new();
14
15    let x = SO2::from_theta(1.0);
16    let y = SO2::from_theta(2.0);
17    values.insert(X(0), SO2::identity());
18    values.insert(X(1), SO2::identity());
19
20    // Make the factors & insert into graph
21    let mut graph = Graph::new();
22    let res = PriorResidual::new(x.clone());
23    let factor = fac![res, X(0)];
24    graph.add_factor(factor);
25
26    let res = BetweenResidual::new(y.minus(&x));
27    let factor = fac![res, (X(0), X(1)), 0.1 as std, Huber::default()];
28    graph.add_factor(factor);
29
30    // Optimize!
31    let mut opt: GaussNewton = GaussNewton::new_default(graph);
32    let result = opt.optimize(values).unwrap();
33    println!("Results {result:#}");
34}
examples/serde.rs (line 31)
7fn main() {
8    // ------------------------- Serialize values ------------------------- //
9    let x = SO2::from_theta(0.6);
10    let y = SE2::new(1.0, 2.0, 0.3);
11    let mut values = Values::new();
12    values.insert(X(0), x.clone());
13    values.insert(Y(1), y.clone());
14
15    println!("------ Serializing Values ------");
16
17    let serialized = serde_json::to_string_pretty(&values).unwrap();
18    println!("serialized = {serialized}");
19
20    // Convert the JSON string back to a Point.
21    let deserialized: Values = serde_json::from_str(&serialized).unwrap();
22    println!("deserialized = {deserialized:#}");
23
24    // ------------------------- Serialize graph ------------------------- //
25    let prior = PriorResidual::new(x);
26    let bet = BetweenResidual::new(y);
27
28    let prior = fac![prior, X(0), 0.1 as cov, GemanMcClure::default()];
29    let bet = fac![bet, (Y(0), Y(1)), 10.0 as cov];
30
31    let mut graph = Graph::new();
32    graph.add_factor(prior);
33    graph.add_factor(bet);
34
35    println!("\n\n------ Serializing Graph ------");
36
37    let serialized = serde_json::to_string_pretty(&graph).unwrap();
38    println!("serialized = {serialized}");
39
40    let deserialized: Graph = serde_json::from_str(&serialized).unwrap();
41    println!("deserialized = {deserialized:#?}");
42}
examples/gps.rs (line 88)
87fn main() {
88    let mut graph = Graph::new();
89
90    // Add odometry factors
91    let res = BetweenResidual::new(SE2::new(0.0, 2.0, 0.0));
92    let odometry_01 = fac![res.clone(), (X(0), X(1)), (0.1, 0.2) as cov];
93    let odometry_12 = fac![res, (X(1), X(2)), (0.1, 0.2) as cov];
94    graph.add_factor(odometry_01);
95    graph.add_factor(odometry_12);
96
97    // Add gps factors
98    let g0 = fac![GpsResidual::new(0.0, 0.0), X(0), 1.0 as std];
99    let g1 = fac![GpsResidual::new(2.0, 0.0), X(1), 1.0 as std];
100    let g2 = fac![GpsResidual::new(4.0, 0.0), X(2), 1.0 as std];
101    graph.add_factor(g0);
102    graph.add_factor(g1);
103    graph.add_factor(g2);
104
105    // Make values
106    let mut values = Values::new();
107    values.insert(X(0), SE2::new(1.0, 2.0, 3.0));
108    values.insert(X(1), SE2::identity());
109    values.insert(X(2), SE2::identity());
110
111    // // These will all compile-time error
112    // // mismatched symbol-variable types
113    // values.insert(X(5), VectorVar2::identity());
114    // // wrong number of keys
115    // let f = fac![GpsResidual::new(0.0, 0.0), (X(0), X(1))];
116    // // wrong noise-model dimension
117    // let n = factrs::noise::GaussianNoise::<5>::from_scalar_sigma(0.1);
118    // let f = fac![GpsResidual::new(0.0, 0.0), X(0), n];
119    // // mismatched symbol-variable types
120    // assign_symbols!(Y : VectorVar2);
121    // let f = fac![GpsResidual::new(0.0, 0.0), Y(0), 0.1 as std];
122
123    // optimize
124    let mut opt: GaussNewton = GaussNewton::new_default(graph);
125    let result = opt.optimize(values).expect("Optimization failed");
126
127    println!("Final Result: {result:#?}");
128}
Source

pub fn with_capacity(capacity: usize) -> Self

Source

pub fn at(&self, idx: usize) -> &Factor

Source

pub fn add_factor(&mut self, factor: Factor)

Examples found in repository?
examples/graph_viz.rs (line 28)
24fn main() {
25    let mut graph = Graph::new();
26    let id = SE2::identity();
27
28    graph.add_factor(fac![PriorResidual::new(id.clone()), X(1)]);
29    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(1), X(2))]);
30    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(2), X(3))]);
31
32    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(1), X(4))]);
33    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(2), X(4))]);
34    graph.add_factor(fac![BetweenResidual::new(id.clone()), (X(3), X(5))]);
35
36    rerun_viz(&graph);
37}
More examples
Hide additional examples
examples/readme.rs (line 24)
11fn main() {
12    // Make all the values
13    let mut values = Values::new();
14
15    let x = SO2::from_theta(1.0);
16    let y = SO2::from_theta(2.0);
17    values.insert(X(0), SO2::identity());
18    values.insert(X(1), SO2::identity());
19
20    // Make the factors & insert into graph
21    let mut graph = Graph::new();
22    let res = PriorResidual::new(x.clone());
23    let factor = fac![res, X(0)];
24    graph.add_factor(factor);
25
26    let res = BetweenResidual::new(y.minus(&x));
27    let factor = fac![res, (X(0), X(1)), 0.1 as std, Huber::default()];
28    graph.add_factor(factor);
29
30    // Optimize!
31    let mut opt: GaussNewton = GaussNewton::new_default(graph);
32    let result = opt.optimize(values).unwrap();
33    println!("Results {result:#}");
34}
examples/serde.rs (line 32)
7fn main() {
8    // ------------------------- Serialize values ------------------------- //
9    let x = SO2::from_theta(0.6);
10    let y = SE2::new(1.0, 2.0, 0.3);
11    let mut values = Values::new();
12    values.insert(X(0), x.clone());
13    values.insert(Y(1), y.clone());
14
15    println!("------ Serializing Values ------");
16
17    let serialized = serde_json::to_string_pretty(&values).unwrap();
18    println!("serialized = {serialized}");
19
20    // Convert the JSON string back to a Point.
21    let deserialized: Values = serde_json::from_str(&serialized).unwrap();
22    println!("deserialized = {deserialized:#}");
23
24    // ------------------------- Serialize graph ------------------------- //
25    let prior = PriorResidual::new(x);
26    let bet = BetweenResidual::new(y);
27
28    let prior = fac![prior, X(0), 0.1 as cov, GemanMcClure::default()];
29    let bet = fac![bet, (Y(0), Y(1)), 10.0 as cov];
30
31    let mut graph = Graph::new();
32    graph.add_factor(prior);
33    graph.add_factor(bet);
34
35    println!("\n\n------ Serializing Graph ------");
36
37    let serialized = serde_json::to_string_pretty(&graph).unwrap();
38    println!("serialized = {serialized}");
39
40    let deserialized: Graph = serde_json::from_str(&serialized).unwrap();
41    println!("deserialized = {deserialized:#?}");
42}
examples/gps.rs (line 94)
87fn main() {
88    let mut graph = Graph::new();
89
90    // Add odometry factors
91    let res = BetweenResidual::new(SE2::new(0.0, 2.0, 0.0));
92    let odometry_01 = fac![res.clone(), (X(0), X(1)), (0.1, 0.2) as cov];
93    let odometry_12 = fac![res, (X(1), X(2)), (0.1, 0.2) as cov];
94    graph.add_factor(odometry_01);
95    graph.add_factor(odometry_12);
96
97    // Add gps factors
98    let g0 = fac![GpsResidual::new(0.0, 0.0), X(0), 1.0 as std];
99    let g1 = fac![GpsResidual::new(2.0, 0.0), X(1), 1.0 as std];
100    let g2 = fac![GpsResidual::new(4.0, 0.0), X(2), 1.0 as std];
101    graph.add_factor(g0);
102    graph.add_factor(g1);
103    graph.add_factor(g2);
104
105    // Make values
106    let mut values = Values::new();
107    values.insert(X(0), SE2::new(1.0, 2.0, 3.0));
108    values.insert(X(1), SE2::identity());
109    values.insert(X(2), SE2::identity());
110
111    // // These will all compile-time error
112    // // mismatched symbol-variable types
113    // values.insert(X(5), VectorVar2::identity());
114    // // wrong number of keys
115    // let f = fac![GpsResidual::new(0.0, 0.0), (X(0), X(1))];
116    // // wrong noise-model dimension
117    // let n = factrs::noise::GaussianNoise::<5>::from_scalar_sigma(0.1);
118    // let f = fac![GpsResidual::new(0.0, 0.0), X(0), n];
119    // // mismatched symbol-variable types
120    // assign_symbols!(Y : VectorVar2);
121    // let f = fac![GpsResidual::new(0.0, 0.0), Y(0), 0.1 as std];
122
123    // optimize
124    let mut opt: GaussNewton = GaussNewton::new_default(graph);
125    let result = opt.optimize(values).expect("Optimization failed");
126
127    println!("Final Result: {result:#?}");
128}
Source

pub fn len(&self) -> usize

Examples found in repository?
examples/g2o.rs (line 80)
54fn main() -> Result<(), Box<dyn std::error::Error>> {
55    // ---------------------- Parse Arguments & Load data ---------------------- //
56    let mut args: Vec<String> = env::args().collect();
57    match args.len() {
58        2 => {
59            args.push(String::from("gauss"));
60            args.push(String::from("arrows"));
61        }
62        3 => {
63            args.push(String::from("arrows"));
64        }
65        4 => {}
66        _ => {
67            println!(
68                "Usage: {} <g2o file> <optimizer: [gauss|leven|gnc] = gauss> <vis: [points|arrows] = arrows>",
69                args[0]
70            );
71            return Ok(());
72        }
73    }
74
75    pretty_env_logger::init();
76
77    // Load the graph from the g2o file
78    let filename = &args[1];
79    let (graph, init) = load_g20(filename);
80    println!("File loaded, {} factors", graph.len());
81
82    let obj = &args[3];
83    let dim = if init.filter::<SE2>().count() != 0 {
84        "se2"
85    } else if init.filter::<SE3>().count() != 0 {
86        "se3"
87    } else {
88        panic!("Graph doesn't have SE2 or SE3 variables");
89    };
90
91    // Make optimizer
92    let mut optimizer: Box<dyn Optimizer> = match args[2].as_str() {
93        "gauss" => {
94            let params = BaseOptParams {
95                max_iterations: 200,
96                error_tol_relative: 1e-4,
97                ..Default::default()
98            };
99            let mut opt = GaussNewton::new(params, graph);
100            rerun_init(&mut opt, dim, obj);
101            Box::new(opt)
102        }
103        "leven" => {
104            let mut params = LevenParams::default();
105            params.base.max_iterations = 200;
106            params.base.error_tol_relative = 1e-4;
107            params.min_model_fidelity = -1e4;
108            let mut opt = LevenMarquardt::new(params, graph);
109            rerun_init(&mut opt, dim, obj);
110            Box::new(opt)
111        }
112        #[allow(clippy::field_reassign_with_default)]
113        "gnc" => {
114            let mut params: GncParams<LevenMarquardt> = GncParams::default();
115            params.mu_step_size = 1.4;
116            params.base.max_iterations = 200;
117            params.inner.base.max_iterations = 5;
118            params.inner.base.error_tol_absolute = 1e-4;
119            params.inner.base.error_tol_relative = 1e-4;
120            let mut opt: GraduatedNonConvexity<GncGemanMcClure, _> =
121                GraduatedNonConvexity::new(params, graph);
122            rerun_init(&mut opt, dim, obj);
123            Box::new(opt)
124        }
125        _ => {
126            println!("Optimizer not recognized");
127            return Ok(());
128        }
129    };
130
131    // ------------------------- Optimize ------------------------- //
132    let start = Instant::now();
133    let result = optimizer.optimize(init);
134    let duration = start.elapsed();
135
136    match result {
137        Ok(_) => println!("Optimization converged!"),
138        Err(_) => println!("Optimization failed!"),
139    }
140    println!("Optimization took: {duration:?}");
141    Ok(())
142}
Source

pub fn is_empty(&self) -> bool

Source

pub fn error(&self, values: &Values) -> dtype

Source

pub fn linearize(&self, values: &Values) -> LinearGraph

Source

pub fn sparsity_pattern(&self, order: ValuesOrder) -> GraphOrder

Source

pub fn iter(&self) -> Iter<'_, Factor>

Source

pub fn iter_mut(&mut self) -> IterMut<'_, Factor>

Trait Implementations§

Source§

impl Clone for Graph

Source§

fn clone(&self) -> Graph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Graph

Source§

fn default() -> Graph

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Graph

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&Graph> for (GraphNodes, GraphEdges)

Available on crate feature rerun only.
Source§

fn from(graph: &Graph) -> (GraphNodes, GraphEdges)

Converts to this type from the input type.
Source§

impl From<Graph> for (GraphNodes, GraphEdges)

Available on crate feature rerun only.
Source§

fn from(graph: Graph) -> (GraphNodes, GraphEdges)

Converts to this type from the input type.
Source§

impl IntoIterator for Graph

Source§

type Item = Factor

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Factor>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Serialize for Graph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl !RefUnwindSafe for Graph

§

impl !Send for Graph

§

impl !Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl !UnwindSafe for Graph

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,