pub fn validate(&self, max_value: u64) -> Result<(), Error> {
        if !is_continuous(&self.payout_function_pieces) {
            return Err(Error::InvalidParameters(
                "Payout function is not continuous.".to_string(),
            ));
        }

        let covers = {
            let first = self
                .payout_function_pieces
                .first()
                .expect("to have at least one piece");
            let starts_at_zero = match first {
                PayoutFunctionPiece::PolynomialPayoutCurvePiece(p) => {
                    p.payout_points
                        .first()
                        .expect("to have at least a point")
                        .event_outcome
                        == 0
                }
                PayoutFunctionPiece::HyperbolaPayoutCurvePiece(h) => {
                    h.left_end_point.event_outcome == 0
                }
            };

            let last = self
                .payout_function_pieces
                .last()
                .expect("to have at least one piece");
            let finishes_at_max = match last {
                PayoutFunctionPiece::PolynomialPayoutCurvePiece(p) => {
                    p.payout_points
                        .last()
                        .expect("to have at least a point")
                        .event_outcome
                        == max_value
                }
                PayoutFunctionPiece::HyperbolaPayoutCurvePiece(h) => {
                    h.right_end_point.event_outcome == max_value
                }
            };

            starts_at_zero && finishes_at_max
        };

        if covers {
            Ok(())
        } else {
            Err(Error::InvalidParameters(
                "Payout function doesn't cover all the possible outcomes.".to_string(),
            ))
        }
    }
/// Validate that the payout function is continuous and covers the interval [0, max_value]
Validate that the payout function is continuous and covers the interval [0, max_value]
Validate that the payout function is continuous and covers the interval [ 0 max_value ]
pub fn validate(&self, max_value: u64) -> Result<(), Error> {
        if !is_continuous(&self.payout_function_pieces) {
            return Err(Error::InvalidParameters(
                "Payout function is not continuous.".to_string(),
            ));
        }
        let covers = {
            let first = self
                .payout_function_pieces
                .first()
                .expect("to have at least one piece");
            let starts_at_zero = match first {
                PayoutFunctionPiece::PolynomialPayoutCurvePiece(p) => {
                    p.payout_points
                        .first()
                        .expect("to have at least a point")
                        .event_outcome
                        == 0
                }
                PayoutFunctionPiece::HyperbolaPayoutCurvePiece(h) => {
                    h.left_end_point.event_outcome == 0
                }
            };
            let last = self
                .payout_function_pieces
                .last()
                .expect("to have at least one piece");
            let finishes_at_max = match last {
                PayoutFunctionPiece::PolynomialPayoutCurvePiece(p) => {
                    p.payout_points
                        .last()
                        .expect("to have at least a point")
                        .event_outcome
                        == max_value
                }
                PayoutFunctionPiece::HyperbolaPayoutCurvePiece(h) => {
                    h.right_end_point.event_outcome == max_value
                }
            };
            starts_at_zero && finishes_at_max
        };
        if covers {
            Ok(())
        } else {
            Err(Error::InvalidParameters(
                "Payout function doesn't cover all the possible outcomes.".to_string(),
            ))
        }
    }
pub fn validate ( & self , max_value : u64 ) -> Result < ( ) , Error > { if ! is_continuous ( & self . payout_function_pieces ) { return Err ( Error :: InvalidParameters ( " " . to_string ( ) , ) ) ; } let covers = { let first = self . payout_function_pieces . first ( ) . expect ( " " ) ; let starts_at_zero = match first { PayoutFunctionPiece :: PolynomialPayoutCurvePiece ( p ) => { p . payout_points . first ( ) . expect ( " " ) . event_outcome == 0 } PayoutFunctionPiece :: HyperbolaPayoutCurvePiece ( h ) => { h . left_end_point . event_outcome == 0 } } ; let last = self . payout_function_pieces . last ( ) . expect ( " " ) ; let finishes_at_max = match last { PayoutFunctionPiece :: PolynomialPayoutCurvePiece ( p ) => { p . payout_points . last ( ) . expect ( " " ) . event_outcome == max_value } PayoutFunctionPiece :: HyperbolaPayoutCurvePiece ( h ) => { h . right_end_point . event_outcome == max_value } } ; starts_at_zero && finishes_at_max } ; if covers { Ok ( ( ) ) } else { Err ( Error :: InvalidParameters ( " " . to_string ( ) , ) ) } }
Validate that the payout function is continuous and covers the interval [0, max_value]
Validate that the payout function is continuous and covers the interval [ 0 max_value ]
&self
max_value
u64