Files
ere/tests/pico/compile/basic/lib/src/lib.rs
Kevaundray Wedderburn 0dacaa9ebe add basic pico test
2025-05-13 23:44:40 +01:00

28 lines
691 B
Rust

use serde::{Deserialize, Serialize};
use std::fs;
#[derive(Serialize, Deserialize)]
pub struct FibonacciData {
pub a: u32,
pub b: u32,
pub n: u32,
}
/// Computes the Fibonacci sequence starting from `a` and `b` up to the `n`-th iteration.
/// Returns the last two values in the sequence: (a, b).
pub fn fibonacci(mut a: u32, mut b: u32, n: u32) -> (u32, u32) {
for _ in 0..n {
let next = a.wrapping_add(b);
a = b;
b = next;
}
(a, b)
}
/// Loads an ELF file from the specified path.
pub fn load_elf(path: &str) -> Vec<u8> {
fs::read(path).unwrap_or_else(|err| {
panic!("Failed to load ELF file from {}: {}", path, err);
})
}