mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
add tests and expose types
This commit is contained in:
parent
58f4afd9f0
commit
24cd78fe7e
4 changed files with 98 additions and 5 deletions
|
@ -19,9 +19,9 @@ mod storage;
|
|||
|
||||
pub use roc_box::RocBox;
|
||||
pub use roc_dict::RocDict;
|
||||
pub use roc_list::RocList;
|
||||
pub use roc_list::{RocList, SendSafeRocList};
|
||||
pub use roc_set::RocSet;
|
||||
pub use roc_str::{InteriorNulError, RocStr};
|
||||
pub use roc_str::{InteriorNulError, RocStr, SendSafeRocStr};
|
||||
pub use storage::Storage;
|
||||
|
||||
// A list of C functions that are being imported
|
||||
|
|
|
@ -121,6 +121,15 @@ impl<T> RocList<T> {
|
|||
}
|
||||
}
|
||||
|
||||
// Marks a list as readonly. This means that it will be leaked.
|
||||
// For constants passed in from platform to application, this may be reasonable.
|
||||
// Marked unsafe because it should not be used lightly.
|
||||
pub unsafe fn set_readonly(&self) {
|
||||
if let Some((_, storage)) = self.elements_and_storage() {
|
||||
storage.set(Storage::Readonly);
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that there is no way to convert directly to a Vec.
|
||||
///
|
||||
/// This is because RocList values are not allocated using the system allocator, so
|
||||
|
|
|
@ -123,6 +123,16 @@ impl RocStr {
|
|||
}
|
||||
}
|
||||
|
||||
// Marks a str as readonly. This means that it will be leaked.
|
||||
// For constants passed in from platform to application, this may be reasonable.
|
||||
// Marked unsafe because it should not be used lightly.
|
||||
pub unsafe fn set_readonly(&self) {
|
||||
match self.as_enum_ref() {
|
||||
RocStrInnerRef::HeapAllocated(roc_list) => unsafe { roc_list.set_readonly() },
|
||||
RocStrInnerRef::SmallString(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Note that there is no way to convert directly to a String.
|
||||
///
|
||||
/// This is because RocStr values are not allocated using the system allocator, so
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue