pub struct UsageExample {
pub title: String,
pub description: String,
pub code: String,
pub category: ExampleCategory,
pub difficulty: ExampleDifficulty,
pub runnable: bool,
}Expand description
Usage example for a trait.
Provides practical examples of how to use a trait, including code samples and explanations.
§Fields
title- Brief title for the exampledescription- Detailed description of what the example demonstratescode- Actual code contentcategory- Category of the example (Implementation, Usage, etc.)difficulty- Difficulty level (Beginner, Intermediate, Advanced)runnable- Whether the example can be executed
§Examples
ⓘ
use sklears_core::trait_explorer::trait_registry::*;
let example = UsageExample {
title: "Basic Estimator Implementation".to_string(),
description: "Shows how to implement the Estimator trait".to_string(),
code: r#"
impl Estimator for MyEstimator {
type Config = MyConfig;
fn name(&self) -> &'static str {
"MyEstimator"
}
}
"#.to_string(),
category: ExampleCategory::Implementation,
difficulty: ExampleDifficulty::Beginner,
runnable: true,
};
assert_eq!(example.difficulty, ExampleDifficulty::Beginner);
assert!(example.runnable);Fields§
§title: StringTitle of the example
description: StringDescription of what the example shows
code: StringCode content
category: ExampleCategoryCategory of example
difficulty: ExampleDifficultyDifficulty level
runnable: boolWhether the example can be run
Trait Implementations§
Source§impl Clone for UsageExample
impl Clone for UsageExample
Source§fn clone(&self) -> UsageExample
fn clone(&self) -> UsageExample
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UsageExample
impl Debug for UsageExample
Source§impl<'de> Deserialize<'de> for UsageExample
impl<'de> Deserialize<'de> for UsageExample
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for UsageExample
impl RefUnwindSafe for UsageExample
impl Send for UsageExample
impl Sync for UsageExample
impl Unpin for UsageExample
impl UnwindSafe for UsageExample
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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