harbor run -t openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-2479harbor download openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-2479Task Description: Implement the Rng Trait for Random Value Generation
Functionality to Implement:
You need to implement the Rng trait that allows for various methods of generating random values within the Rust programming language. This trait primarily provides high-level generic methods for sampling values and other convenience functions related to random number generation.
Specific Requirements:
Implement the gen Method:
gen method which generates a random value according to the Standard distribution.Implement the gen_range Method:
gen_range method which generates a random value within a specified range (both exclusive and inclusive ranges are supported).Implement the sample Method:
sample method which samples a value from a given distribution.Implement the sample_iter Method:
sample_iter method to create an iterator that yields values based on a specified distribution.Implement the fill and try_fill Methods:
fill method, which fills a provided type implementing the Fill trait with random data, panicking on error.try_fill method, which fills a provided type implementing the Fill trait with random data and forwards any errors.Implement Probability Generation Methods:
gen_bool method, which returns a boolean based on a given probability.gen_ratio method, which returns a boolean based on a specified ratio of true outcomes.Fill Trait Requirements:
Fill trait that includes a method for filling types with random data.Testing:
#[cfg(test)] module. Focus particularly on the test_fill, test_gen_range_int, and test_gen_bool functions to verify correctness.Solution Placement:
Place your complete implementation in the /app/ directory, ensuring the code is structured properly to conform to Rust's module system. Your implementation should seamlessly integrate with the existing test suite.