Skip to content

Rust trait for generic functions that need either a compile-time array or a dynamic vector

License

Notifications You must be signed in to change notification settings

m13253/array-or-vec-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

array-or-vec-rs

Rust trait for generic functions that need either a compile-time array or a dynamic vector

Usage

Put this to your Cargo.toml:

[dependencies]
array-or-vec = { "git" = "https://github.com/m13253/array-or-vec-rs" }

Write your code that uses the trait:

use array_or_vec::ArrayOrVec;
use num_traits::NumRef;  // From crate "num_traits"

fn sum<T, A>(a: &A) -> T
where
    T: NumRef,
    A: ArrayOrVec<T>,
{
    a.iter().fold(T::zero(), |acc, x| acc + x)
}

FAQ

  1. Why don't you publish this package to crates.io?

    Because I can't find a good name for this package. Crates.io doesn't allow me to change the name after publishing.

About

Rust trait for generic functions that need either a compile-time array or a dynamic vector

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages