Crates.io | fibext |
lib.rs | fibext |
version | 0.2.1 |
source | src |
created_at | 2023-05-11 00:08:40.775327 |
updated_at | 2023-05-14 03:28:28.615719 |
description | A versatile Fibonacci sequence generator for Rust, with support for large numbers and optional iterator interface. |
homepage | |
repository | https://github.com/cainthebest/fibext |
max_upload_size | |
id | 861705 |
size | 62,328 |
fibext
is a versatile Fibonacci sequence generator for Rust, offering support for various features and customization options.
num_bigint
crate (enabled through the large-numbers
feature).iterator
feature).Add fibext
as a dependency in your Cargo.toml
file:
[dependencies]
fibext = "0.2.0"
Import the fibext
crate into your Rust code:
use fibext::*;
Create a new Fibonacci sequence:
let fib: Fibonacci<u32> = Fibonacci::new();
Iterate over the Fibonacci sequence:
for number in fib.take(10) {
println!("{}", number);
}
This will print the first 10 Fibonacci numbers.
The fibext
library supports the following types of unsigned integers:
u8
u16
u32
u64
u128
When the large-numbers
feature is enabled, the library also supports BigUint
from the num_bigint
crate.
The fibext
library provides several optional features that can be enabled or disabled based on your needs. These features are controlled through the features
section in your Cargo.toml
file.
std
(enabled by default): Enables the use of std
types and features. When disabled, the library uses the core version of Wrapping
and does not rely on std
.checked-overflow
(enabled by default): Enables checked overflow for arithmetic operations. When enabled, the library returns an ArithmeticError
if an overflow occurs.iterator
(enabled by default): Enables the iterator implementation for generating Fibonacci sequences.large-numbers
(optional): Enables support for large numbers using the num_bigint
crate. To enable this feature, add the large-numbers
feature under the features
section in your Cargo.toml
file.[dependencies]
fibext = { version = "0.2.0", features = ["large-numbers"] }
The fibext
library includes a benchmark for Fibonacci sequence generation. To run the benchmark, use the following command:
cargo bench --bench fibonacci
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.