Skip to content

Commit

Permalink
Replace the replaceable "std" with "core"
Browse files Browse the repository at this point in the history
  • Loading branch information
SparrowLii committed Dec 11, 2020
1 parent e808e2b commit 84767e2
Show file tree
Hide file tree
Showing 36 changed files with 80 additions and 80 deletions.
4 changes: 2 additions & 2 deletions src/argument_traits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::cell::Cell;
use std::mem::MaybeUninit;
use core::cell::Cell;
use core::mem::MaybeUninit;


/// A producer element that can be assigned to once
Expand Down
4 changes: 2 additions & 2 deletions src/array_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use serde::de::{self, MapAccess, SeqAccess, Visitor};
use serde::ser::{SerializeSeq, SerializeStruct};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use std::fmt;
use std::marker::PhantomData;
use core::fmt;
use core::marker::PhantomData;

use crate::imp_prelude::*;

Expand Down
10 changes: 5 additions & 5 deletions src/arrayformat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// except according to those terms.
use super::{ArrayBase, ArrayView, Axis, Data, Dimension, NdProducer};
use crate::aliases::{Ix1, IxDyn};
use std::fmt;
use core::fmt;

/// Default threshold, below this element count, we don't ellipsize
const ARRAY_MANY_ELEMENT_LIMIT: usize = 500;
Expand Down Expand Up @@ -46,9 +46,9 @@ impl FormatOptions {

fn set_no_limit(mut self, no_limit: bool) -> Self {
if no_limit {
self.axis_collapse_limit = std::usize::MAX;
self.axis_collapse_limit_next_last = std::usize::MAX;
self.axis_collapse_limit_last = std::usize::MAX;
self.axis_collapse_limit = core::usize::MAX;
self.axis_collapse_limit_next_last = core::usize::MAX;
self.axis_collapse_limit_last = core::usize::MAX;
self
} else {
self
Expand Down Expand Up @@ -286,7 +286,7 @@ where
#[cfg(test)]
mod formatting_with_omit {
use itertools::Itertools;
use std::fmt;
use core::fmt;

use super::*;
use crate::prelude::*;
Expand Down
18 changes: 9 additions & 9 deletions src/arraytraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::hash;
use std::isize;
use std::iter::FromIterator;
use std::iter::IntoIterator;
use std::mem;
use std::ops::{Index, IndexMut};
use core::hash;
use core::isize;
use core::iter::FromIterator;
use core::iter::IntoIterator;
use core::mem;
use core::ops::{Index, IndexMut};

use crate::imp_prelude::*;
use crate::iter::{Iter, IterMut};
Expand Down Expand Up @@ -154,7 +154,7 @@ where
///
/// ```rust
/// use ndarray::{Array, arr1};
/// use std::iter::FromIterator;
/// use core::iter::FromIterator;
///
/// // Either use `from_iter` directly or use `Iterator::collect`.
/// let array = Array::from_iter((0..5).map(|x| x * x));
Expand Down Expand Up @@ -281,7 +281,7 @@ where
let xs = slice.as_ref();
if mem::size_of::<A>() == 0 {
assert!(
xs.len() <= ::std::isize::MAX as usize,
xs.len() <= ::core::isize::MAX as usize,
"Slice length must fit in `isize`.",
);
}
Expand Down Expand Up @@ -313,7 +313,7 @@ where
let xs = slice.as_mut();
if mem::size_of::<A>() == 0 {
assert!(
xs.len() <= ::std::isize::MAX as usize,
xs.len() <= ::core::isize::MAX as usize,
"Slice length must fit in `isize`.",
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/data_repr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

use std::mem;
use std::mem::ManuallyDrop;
use std::ptr::NonNull;
use core::mem;
use core::mem::ManuallyDrop;
use core::ptr::NonNull;
use std::slice;
use crate::extension::nonnull;

Expand Down
4 changes: 2 additions & 2 deletions src/data_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
//! The data (inner representation) traits for ndarray
use rawpointer::PointerExt;
use std::mem::{self, size_of};
use std::ptr::NonNull;
use core::mem::{self, size_of};
use core::ptr::NonNull;
use std::sync::Arc;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion src/dimension/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! Tuple to array conversion, IntoDimension, and related things
use num_traits::Zero;
use std::ops::{Index, IndexMut};
use core::ops::{Index, IndexMut};

use crate::{Dim, Dimension, Ix, Ix1, IxDyn, IxDynImpl};

Expand Down
4 changes: 2 additions & 2 deletions src/dimension/dim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::fmt;

use core::fmt;
use super::Dimension;
use super::IntoDimension;
use crate::itertools::zip;
Expand Down Expand Up @@ -82,7 +82,7 @@ where
}
}

use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
use core::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};

macro_rules! impl_op {
($op:ident, $op_m:ident, $opassign:ident, $opassign_m:ident, $expr:ident) => {
Expand Down
6 changes: 3 additions & 3 deletions src/dimension/dimension_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::fmt::Debug;
use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
use std::ops::{Index, IndexMut};
use core::fmt::Debug;
use core::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
use core::ops::{Index, IndexMut};

use super::axes_of;
use super::conversion::Convert;
Expand Down
4 changes: 2 additions & 2 deletions src/dimension/dynindeximpl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::imp_prelude::*;
use std::hash::{Hash, Hasher};
use std::ops::{Deref, DerefMut, Index, IndexMut};
use core::hash::{Hash, Hasher};
use core::ops::{Deref, DerefMut, Index, IndexMut};

const CAP: usize = 4;

Expand Down
4 changes: 2 additions & 2 deletions src/dimension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub use self::dynindeximpl::IxDynImpl;
pub use self::ndindex::NdIndex;
pub use self::remove_axis::RemoveAxis;

use std::isize;
use std::mem;
use core::isize;
use core::mem;

#[macro_use]
mod macros;
Expand Down
2 changes: 1 addition & 1 deletion src/dimension/ndindex.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Debug;
use core::fmt::Debug;

use super::{stride_offset, stride_offset_checked};
use crate::itertools::zip;
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// except according to those terms.
use super::Dimension;
use std::error::Error;
use std::fmt;
use core::fmt;

/// An error related to array shape or layout.
#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/extension/nonnull.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ptr::NonNull;
use core::ptr::NonNull;

/// Return a NonNull<T> pointer to the vector's data
pub(crate) fn nonnull_from_vec_data<T>(v: &mut Vec<T>) -> NonNull<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/free_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::mem::{forget, size_of};
use core::mem::{forget, size_of};
use std::slice;

use crate::imp_prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/impl_constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![allow(clippy::match_wild_err_arm)]

use num_traits::{Float, One, Zero};
use std::mem::MaybeUninit;
use core::mem::MaybeUninit;

use crate::dimension;
use crate::error::{self, ShapeError};
Expand Down
4 changes: 2 additions & 2 deletions src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::ptr as std_ptr;
use core::ptr as std_ptr;
use std::slice;

use rawpointer::PointerExt;
Expand Down Expand Up @@ -1067,7 +1067,7 @@ where
/// ```
/// use ndarray::Array;
/// use ndarray::{arr3, Axis};
/// use std::iter::FromIterator;
/// use core::iter::FromIterator;
///
/// let a = Array::from_iter(0..28).into_shape((2, 7, 2)).unwrap();
/// let mut iter = a.axis_chunks_iter(Axis(1), 2);
Expand Down
4 changes: 2 additions & 2 deletions src/impl_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ mod arithmetic_ops {
use crate::imp_prelude::*;

use num_complex::Complex;
use std::ops::*;
use core::ops::*;

impl_binary_op!(Add, +, add, +=, "addition");
impl_binary_op!(Sub, -, sub, -=, "subtraction");
Expand Down Expand Up @@ -357,7 +357,7 @@ mod assign_ops {

macro_rules! impl_assign_op {
($trt:ident, $method:ident, $doc:expr) => {
use std::ops::$trt;
use core::ops::$trt;

#[doc=$doc]
/// If their shapes disagree, `rhs` is broadcast to the shape of `self`.
Expand Down
2 changes: 1 addition & 1 deletion src/impl_owned_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<A> Array<A, Ix0> {
/// assert_eq!(scalar, Foo);
/// ```
pub fn into_scalar(self) -> A {
let size = ::std::mem::size_of::<A>();
let size = ::core::mem::size_of::<A>();
if size == 0 {
// Any index in the `Vec` is fine since all elements are identical.
self.data.into_vec().remove(0)
Expand Down
4 changes: 2 additions & 2 deletions src/impl_raw_views.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::mem;
use std::ptr::NonNull;
use core::mem;
use core::ptr::NonNull;

use crate::dimension::{self, stride_offset};
use crate::extension::nonnull::nonnull_debug_checked_from_ptr;
Expand Down
6 changes: 3 additions & 3 deletions src/impl_special_element_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::mem::size_of;
use std::mem::ManuallyDrop;
use std::mem::MaybeUninit;
use core::mem::size_of;
use core::mem::ManuallyDrop;
use core::mem::MaybeUninit;

use crate::imp_prelude::*;
use crate::RawDataSubst;
Expand Down
2 changes: 1 addition & 1 deletion src/impl_views/constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::ptr::NonNull;
use core::ptr::NonNull;

use crate::dimension;
use crate::error::ShapeError;
Expand Down
2 changes: 1 addition & 1 deletion src/iterators/lanes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::marker::PhantomData;
use core::marker::PhantomData;

use super::LanesIter;
use super::LanesIterMut;
Expand Down
6 changes: 3 additions & 3 deletions src/iterators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub mod iter;
mod lanes;
mod windows;

use std::iter::FromIterator;
use std::marker::PhantomData;
use std::ptr;
use core::iter::FromIterator;
use core::marker::PhantomData;
use core::ptr;

use crate::Ix1;

Expand Down
2 changes: 1 addition & 1 deletion src/itertools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

//! A few iterator-related utilities and tools
use std::iter;
use core::iter;

/// Iterate `iterable` with a running index.
///
Expand Down
2 changes: 1 addition & 1 deletion src/layout/layoutfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::Layout;

const LAYOUT_NAMES: &[&str] = &["C", "F", "c", "f"];

use std::fmt;
use core::fmt;

impl fmt::Debug for Layout {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extern crate cblas_sys;
#[cfg(feature = "docs")]
pub mod doc;

use std::marker::PhantomData;
use core::marker::PhantomData;
use std::sync::Arc;

pub use crate::dimension::dim::*;
Expand Down Expand Up @@ -1232,7 +1232,7 @@ where
data: S,
/// A non-null pointer into the buffer held by `data`; may point anywhere
/// in its range. If `S: Data`, this pointer must be aligned.
ptr: std::ptr::NonNull<S::Elem>,
ptr: core::ptr::NonNull<S::Elem>,
/// The lengths of the axes.
dim: D,
/// The element count stride per axis. To be parsed as `isize`.
Expand Down Expand Up @@ -1628,5 +1628,5 @@ pub struct StrideShape<D> {

/// Returns `true` if the pointer is aligned.
pub(crate) fn is_aligned<T>(ptr: *const T) -> bool {
(ptr as usize) % ::std::mem::align_of::<T>() == 0
(ptr as usize) % ::core::mem::align_of::<T>() == 0
}
10 changes: 5 additions & 5 deletions src/linalg/impl_linalg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use crate::numeric_util;

use crate::{LinalgScalar, Zip};

use std::any::TypeId;
use core::any::TypeId;

#[cfg(feature = "blas")]
use std::cmp;
use core::cmp;
#[cfg(feature = "blas")]
use std::mem::swap;
use core::mem::swap;
#[cfg(feature = "blas")]
use std::os::raw::c_int;

Expand Down Expand Up @@ -285,7 +285,7 @@ where
#[inline(never)]
fn dot_shape_error(m: usize, k: usize, k2: usize, n: usize) -> ! {
match m.checked_mul(n) {
Some(len) if len <= ::std::isize::MAX as usize => {}
Some(len) if len <= ::core::isize::MAX as usize => {}
_ => panic!("ndarray: shape {} × {} overflows isize", m, n),
}
panic!(
Expand Down Expand Up @@ -677,7 +677,7 @@ fn same_type<A: 'static, B: 'static>() -> bool {
// **Panics** if `A` and `B` are not the same type
fn cast_as<A: 'static + Copy, B: 'static + Copy>(a: &A) -> B {
assert!(same_type::<A, B>());
unsafe { ::std::ptr::read(a as *const _ as *const B) }
unsafe { ::core::ptr::read(a as *const _ as *const B) }
}

#[cfg(feature = "blas")]
Expand Down
Loading

0 comments on commit 84767e2

Please sign in to comment.