MCPcopy Create free account
hub / github.com/actix/examples / sample

Method sample

basics/error-handling/src/main.rs:44–51  ·  view source on GitHub ↗
(&self, rng: &mut R)

Source from the content-addressed store, hash-verified

42
43impl Distribution<CustomError> for StandardUniform {
44 fn sample<R: rand::RngExt + ?Sized>(&self, rng: &mut R) -> CustomError {
45 match rng.random_range(0..4) {
46 0 => CustomError::CustomOne,
47 1 => CustomError::CustomTwo,
48 2 => CustomError::CustomThree,
49 _ => CustomError::CustomFour,
50 }
51 }
52}
53
54/// Actix Web uses `ResponseError` for conversion of errors to a response

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected