fibext
fibext is a versatile Fibonacci sequence generator for Rust, offering support for various features and customization options.
Features
- Support for different types of unsigned integers.
- Option to enable checked overflow for arithmetic operations.
- Support for large numbers using the
num_bigintcrate (enabled through thelarge-numbersfeature). - Iterator implementation for generating Fibonacci sequences (enabled through the
iteratorfeature).
Usage
Add fibext as a dependency in your Cargo.toml file:
[]
= "0.2.0"
Import the fibext crate into your Rust code:
use *;
Create a new Fibonacci sequence:
let fib: = new;
Iterate over the Fibonacci sequence:
for number in fib.take
This will print the first 10 Fibonacci numbers.
Supported Types
The fibext library supports the following types of unsigned integers:
u8u16u32u64u128
When the large-numbers feature is enabled, the library also supports BigUint from the num_bigint crate.
Optional Features
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 ofstdtypes and features. When disabled, the library uses the core version ofWrappingand does not rely onstd.checked-overflow(enabled by default): Enables checked overflow for arithmetic operations. When enabled, the library returns anArithmeticErrorif an overflow occurs.iterator(enabled by default): Enables the iterator implementation for generating Fibonacci sequences.large-numbers(optional): Enables support for large numbers using thenum_bigintcrate. To enable this feature, add thelarge-numbersfeature under thefeaturessection in yourCargo.tomlfile.
[]
= { = "0.2.0", = ["large-numbers"] }
Benchmarks
The fibext library includes a benchmark for Fibonacci sequence generation. To run the benchmark, use the following command:
cargo bench --bench fibonacci
License
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.