Skip to content

Commit

Permalink
Make crate no_std
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed May 5, 2022
1 parent 607edb8 commit 2f41f4a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/gallop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mod tests;

use crate::Comparator;
use std::cmp::Ordering;
use core::cmp::Ordering;

#[derive(Copy, Clone)]
pub(crate) enum Mode {
Expand Down
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
//! on an already-sorted list, smoothly becoming O(n log n) as the sorted
//! sections (runs) get smaller and smaller.
#![cfg_attr(not(test), no_std)]

extern crate alloc;

mod find_run;
mod gallop;
mod insort;
mod merge;
mod sort;

use core::cmp::Ordering;
use core::convert::Infallible;
use sort::try_sort_by as try_sort_by_cmp;
use std::cmp::Ordering;
use std::convert::Infallible;

type NeverResult<T> = Result<T, Infallible>;
#[inline(always)]
Expand Down
5 changes: 3 additions & 2 deletions src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ mod tests;

use crate::gallop::{self, gallop_left, gallop_right};
use crate::Comparator;
use std::mem::ManuallyDrop;
use std::ptr;
use alloc::vec::Vec;
use core::mem::ManuallyDrop;
use core::ptr;

/// Merge implementation switch.
pub(crate) fn merge<T, C: Comparator<T>>(
Expand Down
3 changes: 2 additions & 1 deletion src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use crate::find_run::get_run;
use crate::insort;
use crate::merge::merge;
use crate::Comparator;
use std::cmp::min;
use alloc::vec::Vec;
use core::cmp::min;

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

0 comments on commit 2f41f4a

Please sign in to comment.