Struct Matcher

Source
pub struct Matcher<Q, C> { /* private fields */ }

Implementations§

Source§

impl<Q: Clone + Debug, C: Clone + Debug> Matcher<Q, C>

Source

pub fn new() -> Self

Examples found in repository?
examples/numeric.rs (line 12)
3fn main() {
4    // Create a numeric similarity metric
5    let numeric_metric = Custom::new(|query: &f64, candidate: &f64| {
6        let diff = (query - candidate).abs();
7        let max_val = query.abs().max(candidate.abs());
8        if max_val == 0.0 { 1.0 } else { 1.0 - (diff / (max_val + 1.0)) }
9    });
10
11    // Create a matcher for f64 numbers
12    let matcher = Matcher::<f64, f64>::new()
13        .add(numeric_metric, 1.0)
14        .threshold(0.8);
15
16    // Define the query and candidate numbers
17    let query = 42.0;
18    let candidates = vec![40.0, 45.0, 100.0];
19
20    // Find all matches
21    println!("Numeric Matching Example");
22    println!("=======================");
23    let matches = matcher.find(&query, &candidates);
24    println!("Matches found: {}", matches.len());
25    for (i, m) in matches.iter().enumerate() {
26        println!(
27            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
28            i + 1, m.score, m.candidate, m.exact
29        );
30    }
31}
More examples
Hide additional examples
examples/multimetric.rs (line 63)
56fn main() {
57    // Create a composite metric with weighted strategy
58    let composite_metric = Composite::<String, String>::new(Strategy::Weighted(vec![0.6, 0.4]))
59        .add(LevenshteinMetric)
60        .add(JaccardMetric);
61
62    // Create a matcher with the composite metric
63    let matcher = Matcher::<String, String>::new()
64        .add(composite_metric, 1.0)
65        .threshold(0.5);
66
67    // Define the query and candidate strings
68    let query = String::from("hello world");
69    let candidates = vec![
70        String::from("hello"),
71        String::from("hello there"),
72        String::from("world"),
73    ];
74
75    // Find matches with a limit of 2
76    println!("Multiple Metrics Example");
77    println!("=======================");
78    let matches = matcher.find_limit(&query, &candidates, 2);
79    println!("Matches found: {}", matches.len());
80    for (i, m) in matches.iter().enumerate() {
81        println!(
82            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
83            i + 1, m.score, m.candidate, m.exact
84        );
85    }
86}
examples/analysis.rs (line 59)
57fn main() {
58    // Create a matcher with two metrics
59    let matcher = Matcher::<String, String>::new()
60        .add(LevenshteinMetric, 0.7) // 70% weight
61        .add(JaccardMetric, 0.3)     // 30% weight
62        .threshold(0.5);
63
64    // Define the query and candidate
65    let query = String::from("test");
66    let candidate = String::from("tent");
67
68    // Perform detailed analysis
69    println!("Detailed Analysis Example");
70    println!("========================");
71    let analysis = matcher.analyze(&query, &candidate);
72    println!("Query: {}", analysis.query);
73    println!("Candidate: {}", analysis.candidate);
74    println!("Overall score: {:.2}", analysis.score);
75    println!("Exact match: {}", analysis.exact);
76    println!("Is match: {}", matcher.matches(&query, &candidate));
77    println!("Individual metric scores:");
78    for (i, score) in analysis.scores.iter().enumerate() {
79        println!(
80            "  Metric {}:\n    Raw score: {:.2}\n    Weight: {:.2}\n    Weighted score: {:.2}",
81            i + 1, score.value, score.weight, score.weighted()
82        );
83    }
84}
examples/multimatcher.rs (line 58)
56fn main() {
57    // Create two matchers with different metrics and thresholds
58    let matcher1 = Matcher::<String, String>::new()
59        .add(LevenshteinMetric, 1.0)
60        .threshold(0.6);
61
62    let matcher2 = Matcher::<String, String>::new()
63        .add(JaccardMetric, 1.0)
64        .threshold(0.4);
65
66    // Combine them into a MultiMatcher
67    let multi_matcher = MultiMatcher::<String, String>::new()
68        .add(matcher1)
69        .add(matcher2)
70        .threshold(0.5);
71
72    // Define the query and candidate strings
73    let query = String::from("example");
74    let candidates = vec![
75        String::from("example"),
76        String::from("examp"),
77        String::from("test"),
78    ];
79
80    // Find matches with a limit of 2
81    println!("MultiMatcher Example");
82    println!("===================");
83    let matches = multi_matcher.find_limit(&query, &candidates, 2);
84    println!("Matches found: {}", matches.len());
85    for (i, m) in matches.iter().enumerate() {
86        println!(
87            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
88            i + 1, m.score, m.candidate, m.exact
89        );
90    }
91}
examples/string.rs (line 41)
32fn main() {
33    // Create a custom similarity metric for strings
34    let levenshtein_metric = Custom::new(|query: &String, candidate: &String| {
35        let distance = SimpleLevenshteinMetric::levenshtein_distance(query, candidate);
36        let max_len = query.len().max(candidate.len());
37        if max_len == 0 { 1.0 } else { 1.0 - (distance as f64 / max_len as f64) }
38    });
39
40    // Create a matcher with the custom metric
41    let matcher = Matcher::<String, String>::new()
42        .add(levenshtein_metric, 1.0)
43        .threshold(0.6);
44
45    // Define the query and candidate strings
46    let query = String::from("hello");
47    let candidates = vec![
48        String::from("hello"),
49        String::from("helo"),
50        String::from("world"),
51    ];
52
53    // Find the best match
54    println!("Basic String Matching Example");
55    println!("============================");
56    if let Some(result) = matcher.best(&query, &candidates) {
57        println!(
58            "Best match found:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
59            result.score, result.candidate, result.exact
60        );
61    } else {
62        println!("No match found above threshold");
63    }
64}
Source

pub fn add<M: Similarity<Q, C> + 'static>(self, metric: M, weight: f64) -> Self

Examples found in repository?
examples/numeric.rs (line 13)
3fn main() {
4    // Create a numeric similarity metric
5    let numeric_metric = Custom::new(|query: &f64, candidate: &f64| {
6        let diff = (query - candidate).abs();
7        let max_val = query.abs().max(candidate.abs());
8        if max_val == 0.0 { 1.0 } else { 1.0 - (diff / (max_val + 1.0)) }
9    });
10
11    // Create a matcher for f64 numbers
12    let matcher = Matcher::<f64, f64>::new()
13        .add(numeric_metric, 1.0)
14        .threshold(0.8);
15
16    // Define the query and candidate numbers
17    let query = 42.0;
18    let candidates = vec![40.0, 45.0, 100.0];
19
20    // Find all matches
21    println!("Numeric Matching Example");
22    println!("=======================");
23    let matches = matcher.find(&query, &candidates);
24    println!("Matches found: {}", matches.len());
25    for (i, m) in matches.iter().enumerate() {
26        println!(
27            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
28            i + 1, m.score, m.candidate, m.exact
29        );
30    }
31}
More examples
Hide additional examples
examples/multimetric.rs (line 64)
56fn main() {
57    // Create a composite metric with weighted strategy
58    let composite_metric = Composite::<String, String>::new(Strategy::Weighted(vec![0.6, 0.4]))
59        .add(LevenshteinMetric)
60        .add(JaccardMetric);
61
62    // Create a matcher with the composite metric
63    let matcher = Matcher::<String, String>::new()
64        .add(composite_metric, 1.0)
65        .threshold(0.5);
66
67    // Define the query and candidate strings
68    let query = String::from("hello world");
69    let candidates = vec![
70        String::from("hello"),
71        String::from("hello there"),
72        String::from("world"),
73    ];
74
75    // Find matches with a limit of 2
76    println!("Multiple Metrics Example");
77    println!("=======================");
78    let matches = matcher.find_limit(&query, &candidates, 2);
79    println!("Matches found: {}", matches.len());
80    for (i, m) in matches.iter().enumerate() {
81        println!(
82            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
83            i + 1, m.score, m.candidate, m.exact
84        );
85    }
86}
examples/analysis.rs (line 60)
57fn main() {
58    // Create a matcher with two metrics
59    let matcher = Matcher::<String, String>::new()
60        .add(LevenshteinMetric, 0.7) // 70% weight
61        .add(JaccardMetric, 0.3)     // 30% weight
62        .threshold(0.5);
63
64    // Define the query and candidate
65    let query = String::from("test");
66    let candidate = String::from("tent");
67
68    // Perform detailed analysis
69    println!("Detailed Analysis Example");
70    println!("========================");
71    let analysis = matcher.analyze(&query, &candidate);
72    println!("Query: {}", analysis.query);
73    println!("Candidate: {}", analysis.candidate);
74    println!("Overall score: {:.2}", analysis.score);
75    println!("Exact match: {}", analysis.exact);
76    println!("Is match: {}", matcher.matches(&query, &candidate));
77    println!("Individual metric scores:");
78    for (i, score) in analysis.scores.iter().enumerate() {
79        println!(
80            "  Metric {}:\n    Raw score: {:.2}\n    Weight: {:.2}\n    Weighted score: {:.2}",
81            i + 1, score.value, score.weight, score.weighted()
82        );
83    }
84}
examples/multimatcher.rs (line 59)
56fn main() {
57    // Create two matchers with different metrics and thresholds
58    let matcher1 = Matcher::<String, String>::new()
59        .add(LevenshteinMetric, 1.0)
60        .threshold(0.6);
61
62    let matcher2 = Matcher::<String, String>::new()
63        .add(JaccardMetric, 1.0)
64        .threshold(0.4);
65
66    // Combine them into a MultiMatcher
67    let multi_matcher = MultiMatcher::<String, String>::new()
68        .add(matcher1)
69        .add(matcher2)
70        .threshold(0.5);
71
72    // Define the query and candidate strings
73    let query = String::from("example");
74    let candidates = vec![
75        String::from("example"),
76        String::from("examp"),
77        String::from("test"),
78    ];
79
80    // Find matches with a limit of 2
81    println!("MultiMatcher Example");
82    println!("===================");
83    let matches = multi_matcher.find_limit(&query, &candidates, 2);
84    println!("Matches found: {}", matches.len());
85    for (i, m) in matches.iter().enumerate() {
86        println!(
87            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
88            i + 1, m.score, m.candidate, m.exact
89        );
90    }
91}
examples/string.rs (line 42)
32fn main() {
33    // Create a custom similarity metric for strings
34    let levenshtein_metric = Custom::new(|query: &String, candidate: &String| {
35        let distance = SimpleLevenshteinMetric::levenshtein_distance(query, candidate);
36        let max_len = query.len().max(candidate.len());
37        if max_len == 0 { 1.0 } else { 1.0 - (distance as f64 / max_len as f64) }
38    });
39
40    // Create a matcher with the custom metric
41    let matcher = Matcher::<String, String>::new()
42        .add(levenshtein_metric, 1.0)
43        .threshold(0.6);
44
45    // Define the query and candidate strings
46    let query = String::from("hello");
47    let candidates = vec![
48        String::from("hello"),
49        String::from("helo"),
50        String::from("world"),
51    ];
52
53    // Find the best match
54    println!("Basic String Matching Example");
55    println!("============================");
56    if let Some(result) = matcher.best(&query, &candidates) {
57        println!(
58            "Best match found:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
59            result.score, result.candidate, result.exact
60        );
61    } else {
62        println!("No match found above threshold");
63    }
64}
Source

pub fn threshold(self, threshold: f64) -> Self

Examples found in repository?
examples/numeric.rs (line 14)
3fn main() {
4    // Create a numeric similarity metric
5    let numeric_metric = Custom::new(|query: &f64, candidate: &f64| {
6        let diff = (query - candidate).abs();
7        let max_val = query.abs().max(candidate.abs());
8        if max_val == 0.0 { 1.0 } else { 1.0 - (diff / (max_val + 1.0)) }
9    });
10
11    // Create a matcher for f64 numbers
12    let matcher = Matcher::<f64, f64>::new()
13        .add(numeric_metric, 1.0)
14        .threshold(0.8);
15
16    // Define the query and candidate numbers
17    let query = 42.0;
18    let candidates = vec![40.0, 45.0, 100.0];
19
20    // Find all matches
21    println!("Numeric Matching Example");
22    println!("=======================");
23    let matches = matcher.find(&query, &candidates);
24    println!("Matches found: {}", matches.len());
25    for (i, m) in matches.iter().enumerate() {
26        println!(
27            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
28            i + 1, m.score, m.candidate, m.exact
29        );
30    }
31}
More examples
Hide additional examples
examples/multimetric.rs (line 65)
56fn main() {
57    // Create a composite metric with weighted strategy
58    let composite_metric = Composite::<String, String>::new(Strategy::Weighted(vec![0.6, 0.4]))
59        .add(LevenshteinMetric)
60        .add(JaccardMetric);
61
62    // Create a matcher with the composite metric
63    let matcher = Matcher::<String, String>::new()
64        .add(composite_metric, 1.0)
65        .threshold(0.5);
66
67    // Define the query and candidate strings
68    let query = String::from("hello world");
69    let candidates = vec![
70        String::from("hello"),
71        String::from("hello there"),
72        String::from("world"),
73    ];
74
75    // Find matches with a limit of 2
76    println!("Multiple Metrics Example");
77    println!("=======================");
78    let matches = matcher.find_limit(&query, &candidates, 2);
79    println!("Matches found: {}", matches.len());
80    for (i, m) in matches.iter().enumerate() {
81        println!(
82            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
83            i + 1, m.score, m.candidate, m.exact
84        );
85    }
86}
examples/analysis.rs (line 62)
57fn main() {
58    // Create a matcher with two metrics
59    let matcher = Matcher::<String, String>::new()
60        .add(LevenshteinMetric, 0.7) // 70% weight
61        .add(JaccardMetric, 0.3)     // 30% weight
62        .threshold(0.5);
63
64    // Define the query and candidate
65    let query = String::from("test");
66    let candidate = String::from("tent");
67
68    // Perform detailed analysis
69    println!("Detailed Analysis Example");
70    println!("========================");
71    let analysis = matcher.analyze(&query, &candidate);
72    println!("Query: {}", analysis.query);
73    println!("Candidate: {}", analysis.candidate);
74    println!("Overall score: {:.2}", analysis.score);
75    println!("Exact match: {}", analysis.exact);
76    println!("Is match: {}", matcher.matches(&query, &candidate));
77    println!("Individual metric scores:");
78    for (i, score) in analysis.scores.iter().enumerate() {
79        println!(
80            "  Metric {}:\n    Raw score: {:.2}\n    Weight: {:.2}\n    Weighted score: {:.2}",
81            i + 1, score.value, score.weight, score.weighted()
82        );
83    }
84}
examples/multimatcher.rs (line 60)
56fn main() {
57    // Create two matchers with different metrics and thresholds
58    let matcher1 = Matcher::<String, String>::new()
59        .add(LevenshteinMetric, 1.0)
60        .threshold(0.6);
61
62    let matcher2 = Matcher::<String, String>::new()
63        .add(JaccardMetric, 1.0)
64        .threshold(0.4);
65
66    // Combine them into a MultiMatcher
67    let multi_matcher = MultiMatcher::<String, String>::new()
68        .add(matcher1)
69        .add(matcher2)
70        .threshold(0.5);
71
72    // Define the query and candidate strings
73    let query = String::from("example");
74    let candidates = vec![
75        String::from("example"),
76        String::from("examp"),
77        String::from("test"),
78    ];
79
80    // Find matches with a limit of 2
81    println!("MultiMatcher Example");
82    println!("===================");
83    let matches = multi_matcher.find_limit(&query, &candidates, 2);
84    println!("Matches found: {}", matches.len());
85    for (i, m) in matches.iter().enumerate() {
86        println!(
87            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
88            i + 1, m.score, m.candidate, m.exact
89        );
90    }
91}
examples/string.rs (line 43)
32fn main() {
33    // Create a custom similarity metric for strings
34    let levenshtein_metric = Custom::new(|query: &String, candidate: &String| {
35        let distance = SimpleLevenshteinMetric::levenshtein_distance(query, candidate);
36        let max_len = query.len().max(candidate.len());
37        if max_len == 0 { 1.0 } else { 1.0 - (distance as f64 / max_len as f64) }
38    });
39
40    // Create a matcher with the custom metric
41    let matcher = Matcher::<String, String>::new()
42        .add(levenshtein_metric, 1.0)
43        .threshold(0.6);
44
45    // Define the query and candidate strings
46    let query = String::from("hello");
47    let candidates = vec![
48        String::from("hello"),
49        String::from("helo"),
50        String::from("world"),
51    ];
52
53    // Find the best match
54    println!("Basic String Matching Example");
55    println!("============================");
56    if let Some(result) = matcher.best(&query, &candidates) {
57        println!(
58            "Best match found:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
59            result.score, result.candidate, result.exact
60        );
61    } else {
62        println!("No match found above threshold");
63    }
64}
Source

pub fn analyze(&self, query: &Q, candidate: &C) -> Analysis<Q, C>

Examples found in repository?
examples/analysis.rs (line 71)
57fn main() {
58    // Create a matcher with two metrics
59    let matcher = Matcher::<String, String>::new()
60        .add(LevenshteinMetric, 0.7) // 70% weight
61        .add(JaccardMetric, 0.3)     // 30% weight
62        .threshold(0.5);
63
64    // Define the query and candidate
65    let query = String::from("test");
66    let candidate = String::from("tent");
67
68    // Perform detailed analysis
69    println!("Detailed Analysis Example");
70    println!("========================");
71    let analysis = matcher.analyze(&query, &candidate);
72    println!("Query: {}", analysis.query);
73    println!("Candidate: {}", analysis.candidate);
74    println!("Overall score: {:.2}", analysis.score);
75    println!("Exact match: {}", analysis.exact);
76    println!("Is match: {}", matcher.matches(&query, &candidate));
77    println!("Individual metric scores:");
78    for (i, score) in analysis.scores.iter().enumerate() {
79        println!(
80            "  Metric {}:\n    Raw score: {:.2}\n    Weight: {:.2}\n    Weighted score: {:.2}",
81            i + 1, score.value, score.weight, score.weighted()
82        );
83    }
84}
Source

pub fn score(&self, query: &Q, candidate: &C) -> f64

Source

pub fn matches(&self, query: &Q, candidate: &C) -> bool

Examples found in repository?
examples/analysis.rs (line 76)
57fn main() {
58    // Create a matcher with two metrics
59    let matcher = Matcher::<String, String>::new()
60        .add(LevenshteinMetric, 0.7) // 70% weight
61        .add(JaccardMetric, 0.3)     // 30% weight
62        .threshold(0.5);
63
64    // Define the query and candidate
65    let query = String::from("test");
66    let candidate = String::from("tent");
67
68    // Perform detailed analysis
69    println!("Detailed Analysis Example");
70    println!("========================");
71    let analysis = matcher.analyze(&query, &candidate);
72    println!("Query: {}", analysis.query);
73    println!("Candidate: {}", analysis.candidate);
74    println!("Overall score: {:.2}", analysis.score);
75    println!("Exact match: {}", analysis.exact);
76    println!("Is match: {}", matcher.matches(&query, &candidate));
77    println!("Individual metric scores:");
78    for (i, score) in analysis.scores.iter().enumerate() {
79        println!(
80            "  Metric {}:\n    Raw score: {:.2}\n    Weight: {:.2}\n    Weighted score: {:.2}",
81            i + 1, score.value, score.weight, score.weighted()
82        );
83    }
84}
Source

pub fn best(&self, query: &Q, candidates: &[C]) -> Option<Match<Q, C>>

Examples found in repository?
examples/string.rs (line 56)
32fn main() {
33    // Create a custom similarity metric for strings
34    let levenshtein_metric = Custom::new(|query: &String, candidate: &String| {
35        let distance = SimpleLevenshteinMetric::levenshtein_distance(query, candidate);
36        let max_len = query.len().max(candidate.len());
37        if max_len == 0 { 1.0 } else { 1.0 - (distance as f64 / max_len as f64) }
38    });
39
40    // Create a matcher with the custom metric
41    let matcher = Matcher::<String, String>::new()
42        .add(levenshtein_metric, 1.0)
43        .threshold(0.6);
44
45    // Define the query and candidate strings
46    let query = String::from("hello");
47    let candidates = vec![
48        String::from("hello"),
49        String::from("helo"),
50        String::from("world"),
51    ];
52
53    // Find the best match
54    println!("Basic String Matching Example");
55    println!("============================");
56    if let Some(result) = matcher.best(&query, &candidates) {
57        println!(
58            "Best match found:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
59            result.score, result.candidate, result.exact
60        );
61    } else {
62        println!("No match found above threshold");
63    }
64}
Source

pub fn find(&self, query: &Q, candidates: &[C]) -> Vec<Match<Q, C>>

Examples found in repository?
examples/numeric.rs (line 23)
3fn main() {
4    // Create a numeric similarity metric
5    let numeric_metric = Custom::new(|query: &f64, candidate: &f64| {
6        let diff = (query - candidate).abs();
7        let max_val = query.abs().max(candidate.abs());
8        if max_val == 0.0 { 1.0 } else { 1.0 - (diff / (max_val + 1.0)) }
9    });
10
11    // Create a matcher for f64 numbers
12    let matcher = Matcher::<f64, f64>::new()
13        .add(numeric_metric, 1.0)
14        .threshold(0.8);
15
16    // Define the query and candidate numbers
17    let query = 42.0;
18    let candidates = vec![40.0, 45.0, 100.0];
19
20    // Find all matches
21    println!("Numeric Matching Example");
22    println!("=======================");
23    let matches = matcher.find(&query, &candidates);
24    println!("Matches found: {}", matches.len());
25    for (i, m) in matches.iter().enumerate() {
26        println!(
27            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
28            i + 1, m.score, m.candidate, m.exact
29        );
30    }
31}
Source

pub fn find_limit( &self, query: &Q, candidates: &[C], limit: usize, ) -> Vec<Match<Q, C>>

Examples found in repository?
examples/multimetric.rs (line 78)
56fn main() {
57    // Create a composite metric with weighted strategy
58    let composite_metric = Composite::<String, String>::new(Strategy::Weighted(vec![0.6, 0.4]))
59        .add(LevenshteinMetric)
60        .add(JaccardMetric);
61
62    // Create a matcher with the composite metric
63    let matcher = Matcher::<String, String>::new()
64        .add(composite_metric, 1.0)
65        .threshold(0.5);
66
67    // Define the query and candidate strings
68    let query = String::from("hello world");
69    let candidates = vec![
70        String::from("hello"),
71        String::from("hello there"),
72        String::from("world"),
73    ];
74
75    // Find matches with a limit of 2
76    println!("Multiple Metrics Example");
77    println!("=======================");
78    let matches = matcher.find_limit(&query, &candidates, 2);
79    println!("Matches found: {}", matches.len());
80    for (i, m) in matches.iter().enumerate() {
81        println!(
82            "Match {}:\n  Score: {:.2}\n  Candidate: {}\n  Exact: {}",
83            i + 1, m.score, m.candidate, m.exact
84        );
85    }
86}

Trait Implementations§

Source§

impl<Q, C> Default for Matcher<Q, C>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<Q, C> Freeze for Matcher<Q, C>

§

impl<Q, C> !RefUnwindSafe for Matcher<Q, C>

§

impl<Q, C> !Send for Matcher<Q, C>

§

impl<Q, C> !Sync for Matcher<Q, C>

§

impl<Q, C> Unpin for Matcher<Q, C>

§

impl<Q, C> !UnwindSafe for Matcher<Q, C>

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.