update no_std config

This commit is contained in:
Folkert 2022-08-06 19:05:29 +02:00
parent b4eda7c9d9
commit 6394a4e337
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 11 additions and 11 deletions

View file

@ -1,5 +1,5 @@
#![no_std]
#![crate_type = "lib"] #![crate_type = "lib"]
#![cfg_attr(feature = "no_std", no_std)]
use arrayvec::ArrayString; use arrayvec::ArrayString;
use core::cmp::Ordering; use core::cmp::Ordering;
@ -365,7 +365,7 @@ impl RocDec {
} }
fn to_str_helper(self, string: &mut ArrayString<{ Self::MAX_STR_LENGTH }>) -> &str { fn to_str_helper(self, string: &mut ArrayString<{ Self::MAX_STR_LENGTH }>) -> &str {
use std::fmt::Write; use core::fmt::Write;
if self.as_i128() == 0 { if self.as_i128() == 0 {
return "0"; return "0";

View file

@ -7,11 +7,11 @@ use core::{
fmt::Debug, fmt::Debug,
hash::Hash, hash::Hash,
intrinsics::copy_nonoverlapping, intrinsics::copy_nonoverlapping,
iter::FromIterator,
mem::{self, ManuallyDrop}, mem::{self, ManuallyDrop},
ops::Deref, ops::Deref,
ptr::{self, NonNull}, ptr::{self, NonNull},
}; };
use std::iter::FromIterator;
use crate::{roc_alloc, roc_dealloc, roc_realloc, storage::Storage}; use crate::{roc_alloc, roc_dealloc, roc_realloc, storage::Storage};
@ -474,7 +474,7 @@ where
impl<'a, T> IntoIterator for &'a RocList<T> { impl<'a, T> IntoIterator for &'a RocList<T> {
type Item = &'a T; type Item = &'a T;
type IntoIter = std::slice::Iter<'a, T>; type IntoIter = core::slice::Iter<'a, T>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.as_slice().iter() self.as_slice().iter()
@ -529,7 +529,7 @@ impl<T> Drop for IntoIter<T> {
} }
impl<T: Hash> Hash for RocList<T> { impl<T: Hash> Hash for RocList<T> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
// This is the same as Rust's Vec implementation, which // This is the same as Rust's Vec implementation, which
// just delegates to the slice implementation. It's a bit surprising // just delegates to the slice implementation. It's a bit surprising
// that Hash::hash_slice doesn't automatically incorporate the length, // that Hash::hash_slice doesn't automatically incorporate the length,
@ -551,7 +551,7 @@ impl<T: Clone> FromIterator<T> for RocList<T> {
{ {
let iter = into.into_iter(); let iter = into.into_iter();
if std::mem::size_of::<T>() == 0 { if core::mem::size_of::<T>() == 0 {
let count = iter.count(); let count = iter.count();
return Self { return Self {
elements: Some(Self::elems_with_capacity(count)), elements: Some(Self::elems_with_capacity(count)),

View file

@ -10,8 +10,8 @@ use core::{
ptr, ptr,
}; };
#[cfg(not(feature = "no_std"))] #[cfg(feature = "std")]
use std::ffi::{CStr, CString}; use core::ffi::{CStr, CString};
use crate::RocList; use crate::RocList;
@ -527,7 +527,7 @@ impl Deref for RocStr {
} }
/// This can fail because a CStr may contain invalid UTF-8 characters /// This can fail because a CStr may contain invalid UTF-8 characters
#[cfg(not(feature = "no_std"))] #[cfg(feature = "std")]
impl TryFrom<&CStr> for RocStr { impl TryFrom<&CStr> for RocStr {
type Error = core::str::Utf8Error; type Error = core::str::Utf8Error;
@ -537,7 +537,7 @@ impl TryFrom<&CStr> for RocStr {
} }
/// This can fail because a CString may contain invalid UTF-8 characters /// This can fail because a CString may contain invalid UTF-8 characters
#[cfg(not(feature = "no_std"))] #[cfg(feature = "std")]
impl TryFrom<CString> for RocStr { impl TryFrom<CString> for RocStr {
type Error = core::str::Utf8Error; type Error = core::str::Utf8Error;

View file

@ -8,7 +8,7 @@ use core::num::NonZeroIsize;
const REFCOUNT_1: NonZeroIsize = unsafe { NonZeroIsize::new_unchecked(isize::MIN) }; const REFCOUNT_1: NonZeroIsize = unsafe { NonZeroIsize::new_unchecked(isize::MIN) };
const _ASSERT_STORAGE_SIZE: () = const _ASSERT_STORAGE_SIZE: () =
assert!(std::mem::size_of::<isize>() == std::mem::size_of::<Storage>()); assert!(core::mem::size_of::<isize>() == core::mem::size_of::<Storage>());
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub enum Storage { pub enum Storage {