mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
update no_std config
This commit is contained in:
parent
b4eda7c9d9
commit
6394a4e337
4 changed files with 11 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
#![no_std]
|
||||
#![crate_type = "lib"]
|
||||
#![cfg_attr(feature = "no_std", no_std)]
|
||||
|
||||
use arrayvec::ArrayString;
|
||||
use core::cmp::Ordering;
|
||||
|
@ -365,7 +365,7 @@ impl RocDec {
|
|||
}
|
||||
|
||||
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 {
|
||||
return "0";
|
||||
|
|
|
@ -7,11 +7,11 @@ use core::{
|
|||
fmt::Debug,
|
||||
hash::Hash,
|
||||
intrinsics::copy_nonoverlapping,
|
||||
iter::FromIterator,
|
||||
mem::{self, ManuallyDrop},
|
||||
ops::Deref,
|
||||
ptr::{self, NonNull},
|
||||
};
|
||||
use std::iter::FromIterator;
|
||||
|
||||
use crate::{roc_alloc, roc_dealloc, roc_realloc, storage::Storage};
|
||||
|
||||
|
@ -474,7 +474,7 @@ where
|
|||
|
||||
impl<'a, T> IntoIterator for &'a RocList<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 {
|
||||
self.as_slice().iter()
|
||||
|
@ -529,7 +529,7 @@ impl<T> Drop for IntoIter<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
|
||||
// just delegates to the slice implementation. It's a bit surprising
|
||||
// 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();
|
||||
|
||||
if std::mem::size_of::<T>() == 0 {
|
||||
if core::mem::size_of::<T>() == 0 {
|
||||
let count = iter.count();
|
||||
return Self {
|
||||
elements: Some(Self::elems_with_capacity(count)),
|
||||
|
|
|
@ -10,8 +10,8 @@ use core::{
|
|||
ptr,
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
use std::ffi::{CStr, CString};
|
||||
#[cfg(feature = "std")]
|
||||
use core::ffi::{CStr, CString};
|
||||
|
||||
use crate::RocList;
|
||||
|
||||
|
@ -527,7 +527,7 @@ impl Deref for RocStr {
|
|||
}
|
||||
|
||||
/// 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 {
|
||||
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
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
#[cfg(feature = "std")]
|
||||
impl TryFrom<CString> for RocStr {
|
||||
type Error = core::str::Utf8Error;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use core::num::NonZeroIsize;
|
|||
const REFCOUNT_1: NonZeroIsize = unsafe { NonZeroIsize::new_unchecked(isize::MIN) };
|
||||
|
||||
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)]
|
||||
pub enum Storage {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue