Skip to content

no-std Step 5: mechanical use std::use core::/use alloc:: sweep across src/ #418

Description

@Mec-iS

Sub-task of #413.

What

Replace all use std:: imports in production code (non-test) with their core:: or alloc:: equivalents across the full src/ tree.

Mechanical core:: swaps (pure re-exports, no logic change)

std::fmt         → core::fmt
std::fmt::*      → core::fmt::*
std::ops::*      → core::ops::*
std::cmp::*      → core::cmp::*
std::iter::*     → core::iter::*
std::slice::*    → core::slice::*
std::marker::*   → core::marker::*
std::mem::*      → core::mem::*
std::cell::*     → core::cell::*
std::hash::*     → core::hash::*

alloc:: swaps (heap types, available under no_std + alloc)

std::vec::Vec    → alloc::vec::Vec  (or just Vec via alloc prelude)
std::string::String → alloc::string::String
std::boxed::Box  → alloc::boxed::Box
std::collections::BTreeMap/BTreeSet → alloc::collections::*

Still needs #[cfg(feature = "std")]

Scope

All directories under src/: algorithm/, cluster/, decomposition/, ensemble/, linalg/, linear/, metrics/, model_selection/, naive_bayes/, neighbors/, numbers/, optimization/, preprocessing/, svm/, tree/, xgboost/, readers/, dataset/, error/, rand_custom.rs.

Approximately 115 mechanical import lines across ~20+ files (per baseline audit in #413). A lint-assisted pass with sed for the mechanical cases, then manual review for the alloc:: cases.

Acceptance

  • No use std:: in production code outside of #[cfg(feature = "std")]-gated blocks
  • cargo clippy --all-features -- -Drust-2018-idioms -Drust-2024-compatibility -Dwarnings exits 0
  • cargo test --all-features passes (474+ unit + 68+3 doctests)

Estimated effort: ~3.5 hrs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions