Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Nonanti/mathcore/llms.txt

Use this file to discover all available pages before exploring further.

MathCore is written as a #![no_std] library at its core — the crate itself carries that attribute in src/lib.rs. The standard library is available as an opt-in std feature (enabled by default), meaning you can drop MathCore into embedded targets, WASM modules, or any environment without an operating system simply by disabling the default feature set.

Cargo.toml Configuration

1
Disable all default features for a pure no_std build
2
[dependencies]
# Disable all default features for no_std
mathcore = { version = "0.3.1", default-features = false }
3
This gives you the alloc-only build: no standard library, no rayon parallelism, no FFT. Core symbolic math is fully available.
4
Selectively re-enable features as needed
5
[dependencies]
# Or enable specific subsets
mathcore = { version = "0.3.1", default-features = false, features = ["std"] }
6
You can mix and match any combination of the available features to match your target’s capabilities.

Feature Breakdown

MathCore’s Cargo.toml defines the following features:
FeatureRequiresWhat it adds
(none)allocCore symbolic math over alloc — parsing, evaluation, calculus, solver, matrix ops
stdstdStandard library; full HashMap, richer error formatting via thiserror/std
parallelstdRayon-based parallel operations (batch evaluation, parallel matrix ops)
fftstdFFT and signal processing via rustfft
fullstdAlias that enables std, parallel, and fft together
The default feature set is ["std", "parallel", "fft"], so a plain mathcore = "0.3.1" entry in Cargo.toml pulls everything in.
Both parallel and fft implicitly require std — they are declared with std as a dependency in the feature graph. You cannot enable either of them without std.

What Is Available in no_std

All of MathCore’s symbolic math capabilities are available in no_std mode, backed by alloc and carefully chosen default-features = false dependencies throughout:
CapabilityAvailable in no_std?
Expression parsing and evaluation
Symbolic differentiation
Symbolic integration
Numerical integration
Equation solving
Complex numbers (num-complex with libm)
Matrix operations (nalgebra with alloc + libm)
Arbitrary precision arithmetic (num-bigint, num-rational)
Parallel operations (rayon)✗ requires std
FFT and signal processing (rustfft)✗ requires std
Full thiserror error formatting✗ requires std
The math-heavy dependencies — nom, num-complex, num-traits, num-bigint, num-rational, and nalgebra — are all configured with default-features = false and use libm for floating-point math where needed, so they work correctly without the standard library.

Setting Up Your no_std Crate

1
Declare no_std and import alloc in your crate root
2
#![no_std]

extern crate alloc;
3
Add the MathCore dependency with default-features = false
4
[dependencies]
mathcore = { version = "0.3.1", default-features = false }
5
Use the prelude to get alloc-compatible types
6
#![no_std]

extern crate alloc;

use mathcore::MathCore;
use mathcore::prelude::*; // re-exports String, Vec, Box, format!, HashMap, etc.

fn compute_distance() -> f64 {
    let math = MathCore::new();
    let mut vars = HashMap::new();
    vars.insert("x".to_string(), 3.0);
    vars.insert("y".to_string(), 4.0);
    math.evaluate_with_vars("sqrt(x^2 + y^2)", &vars).unwrap()
}

HashMap in no_std Mode

In std builds, mathcore::HashMap<K, V> is a type alias for std::collections::HashMap<K, V>. In no_std builds, it becomes alloc::collections::BTreeMap<K, V>:
// src/lib.rs (simplified)
#[cfg(feature = "std")]
pub type HashMap<K, V> = std::collections::HashMap<K, V>;

#[cfg(not(feature = "std"))]
pub type HashMap<K, V> = alloc::collections::BTreeMap<K, V>;
The prelude module re-exports this alias, so your code that imports use mathcore::prelude::* compiles and runs correctly in both environments without any #[cfg] guards on your side.
use mathcore::prelude::*;

// This HashMap is BTreeMap in no_std, std::HashMap in std — same call-site either way
let mut vars = HashMap::new();
vars.insert("theta".to_string(), 1.5707963); // π/2
Because BTreeMap is ordered and requires Ord on keys, HashMap::new() in no_std mode does not take a hasher argument. Do not use HashMap::with_capacity_and_hasher or similar std-only constructors in code that needs to compile for both targets.

The prelude Module

The mathcore::prelude module is designed specifically to smooth over std/no_std differences. It re-exports the types you most commonly need from alloc and core, so you rarely have to write feature-gated imports yourself:
pub mod prelude {
    pub use super::HashMap;
    pub use alloc::{boxed::Box, format, string::String, string::ToString, vec, vec::Vec};
    pub use core::fmt;
    pub use core::str::FromStr;
    pub use num_traits::Float;
}
A single use mathcore::prelude::*; at the top of your file gives you String, Vec, Box, format!, HashMap, FromStr, fmt, and the Float trait — everything you need for typical MathCore usage, in both std and no_std contexts.

Build docs developers (and LLMs) love