Coder Social home page Coder Social logo

cainthebest / fibext Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 66 KB

A versatile Fibonacci sequence generator for Rust, with support for large numbers and optional iterator interface.

Home Page: https://docs.rs/fibext

License: GNU General Public License v3.0

Rust 100.00%

fibext's Introduction

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_bigint crate (enabled through the large-numbers feature).
  • Iterator implementation for generating Fibonacci sequences (enabled through the iterator feature).

Usage

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.

Supported Types

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.

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 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"] }

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.