Skip to content

Commit 2f41f4a

Browse files
committed
Make crate no_std
1 parent 607edb8 commit 2f41f4a

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/gallop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
mod tests;
55

66
use crate::Comparator;
7-
use std::cmp::Ordering;
7+
use core::cmp::Ordering;
88

99
#[derive(Copy, Clone)]
1010
pub(crate) enum Mode {

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
//! on an already-sorted list, smoothly becoming O(n log n) as the sorted
44
//! sections (runs) get smaller and smaller.
55
6+
#![cfg_attr(not(test), no_std)]
7+
8+
extern crate alloc;
9+
610
mod find_run;
711
mod gallop;
812
mod insort;
913
mod merge;
1014
mod sort;
1115

16+
use core::cmp::Ordering;
17+
use core::convert::Infallible;
1218
use sort::try_sort_by as try_sort_by_cmp;
13-
use std::cmp::Ordering;
14-
use std::convert::Infallible;
1519

1620
type NeverResult<T> = Result<T, Infallible>;
1721
#[inline(always)]

src/merge.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ mod tests;
77

88
use crate::gallop::{self, gallop_left, gallop_right};
99
use crate::Comparator;
10-
use std::mem::ManuallyDrop;
11-
use std::ptr;
10+
use alloc::vec::Vec;
11+
use core::mem::ManuallyDrop;
12+
use core::ptr;
1213

1314
/// Merge implementation switch.
1415
pub(crate) fn merge<T, C: Comparator<T>>(

src/sort.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use crate::find_run::get_run;
88
use crate::insort;
99
use crate::merge::merge;
1010
use crate::Comparator;
11-
use std::cmp::min;
11+
use alloc::vec::Vec;
12+
use core::cmp::min;
1213

1314
/// Minimum run length to merge; anything shorter will be lengthend and
1415
/// sorted using `insort::sort`.

0 commit comments

Comments
 (0)