cashmere

cashmere

parse string to i64

Preface

how to parse a string to i64 in Rust.

Example

let amount_cents = db_data
    .booking_service
    .get_user_booking(user.id.expect("User ID is none"))
    .await
    .map_err(|_| return ErrorUnauthorized("Missing hoster_id"))?
    .price
    .parse::<i64>()
    .map_err(|e| return ErrorInternalServerError(e.into()))?;

References