bixverse-rs 0.3.5

A Rust library with various utilities for computational biology and single cell.
Documentation
//! All type of utility modules with shared code that does not fit fully into
//! other modules. Has assertion macros, structures designed for the heap,
//! traits and their implementations, R <> Rust interface functions and more.

pub mod heap_structures;
pub mod macros;
pub mod matrix_utils;
pub mod r_rust_interface;
pub mod simd;
pub mod traits;
pub mod vec_utils;

use faer::Par;
use rustc_hash::{FxBuildHasher, FxHashSet};

///////////////////
// General utils //
///////////////////

/// String slice to FxHashSet
///
/// ### Params
///
/// * `x` - The string slice.
///
/// ### Returns
///
/// A HashSet with borrowed String values
pub fn string_vec_to_set(x: &[String]) -> FxHashSet<&String> {
    let mut set = FxHashSet::with_capacity_and_hasher(x.len(), FxBuildHasher);
    for s in x {
        set.insert(s);
    }
    set
}

/// Returns the faer parallelism enum (all available cores via Rayon).
#[inline]
pub fn faer_parallelism() -> Par {
    Par::Rayon(std::thread::available_parallelism().unwrap())
}