Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/ex01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,34 @@ pub const LAMPORTS_PER_SOL: u64 = 1_000_000_000;
///
/// `sol_to_lamports(2)` should return `2_000_000_000`.
pub fn sol_to_lamports(sol: u64) -> u64 {
todo!()
let lamports = sol * LAMPORTS_PER_SOL;
lamports
}

/// Convert lamports into whole SOL, dropping any remainder.
///
/// `lamports_to_sol(2_500_000_000)` should return `2`.
pub fn lamports_to_sol(lamports: u64) -> u64 {
todo!()
lamports / LAMPORTS_PER_SOL
}

/// Add a bonus to a balance and return the new balance.
pub fn apply_bonus(balance: u64, bonus: u64) -> u64 {
todo!()
let new_balance = balance + bonus;
new_balance
}

/// Double a value.
///
/// Use shadowing in your implementation: declare a new `value` instead of
/// mutating the parameter.
pub fn double(value: u64) -> u64 {
todo!()
let value = value * 2;
value
}

/// Return `true` when the balance is zero.
pub fn is_empty(balance: u64) -> bool {
todo!()
let is_empty = balance == 0;
is_empty
}