-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Description
Not a huge deal but making it apparent for anyone else who get this issue.
Path: bootcamp/1. Beginner/4. How To Structure Your Rust Projects/auth_service/
Issue:
# Cargol.toml
rand = "0.8.4" # newest version is now 0.9.2 so use rand::prelude::* is deprecated.
# lib.rs
#![allow(dead_code, unused_variables)]
use rand::prelude::*;
pub mod database;
mod auth_utils;
pub use auth_utils::models::Credentials;
use database::Status;
pub fn authenticate(creds: Credentials) {
let timeout =
thread_rng().gen_range(100..500);
println!("The timeout is {timeout}");
if let Status::Connected = database::connect_to_database() {
auth_utils::login(creds);
}
}
Solution:
# Cargo.toml
rand = "0.9.2"
# lib.rs
#![allow(dead_code, unused_variables)]
use rand::Rng;
pub mod database;
mod auth_utils;
pub use auth_utils::models::Credentials;
use database::Status;
pub fn authenticate(creds: Credentials) {
let timeout = rand::rng().random_range(100..=500);
println!("The timeout is {timeout}");
if let Status::Connected = database::connect_to_database() {
auth_utils::login(creds);
}
}
Metadata
Metadata
Assignees
Labels
No labels