This commit is contained in:
Brendan Hansknecht 2023-03-06 21:02:47 -08:00
parent 75e996c445
commit 11cccde050
No known key found for this signature in database
GPG Key ID: 0EA784685083E75B
6 changed files with 22 additions and 22 deletions

View File

@ -387,7 +387,7 @@ pub fn cli_testing_dir(dir_name: &str) -> PathBuf {
// Descend into examples/{dir_name}
path.push("crates");
path.push("cli_testing_examples");
path.extend(dir_name.split("/")); // Make slashes cross-target
path.extend(dir_name.split('/')); // Make slashes cross-target
path
}
@ -396,7 +396,7 @@ pub fn cli_testing_dir(dir_name: &str) -> PathBuf {
pub fn dir_path_from_root(dir_name: &str) -> PathBuf {
let mut path = root_dir();
path.extend(dir_name.split("/")); // Make slashes cross-target
path.extend(dir_name.split('/')); // Make slashes cross-target
path
}
@ -419,7 +419,7 @@ pub fn fixtures_dir(dir_name: &str) -> PathBuf {
path.push("cli");
path.push("tests");
path.push("fixtures");
path.extend(dir_name.split("/")); // Make slashes cross-target
path.extend(dir_name.split('/')); // Make slashes cross-target
path
}

View File

@ -46,7 +46,14 @@ impl<K, V> RocDict<K, V> {
}
impl<K: Hash, V> RocDict<K, V> {
pub fn from_iter<I: Iterator<Item = (K, V)>>(src: I) -> Self {
unsafe fn insert_unchecked(&mut self, _key: K, _val: V) {
todo!();
}
}
impl<K: Hash, V> FromIterator<(K, V)> for RocDict<K, V> {
fn from_iter<T: IntoIterator<Item = (K, V)>>(into_iter: T) -> Self {
let src = into_iter.into_iter();
let mut ret = Self::with_capacity(src.size_hint().0);
for (key, val) in src {
@ -57,16 +64,6 @@ impl<K: Hash, V> RocDict<K, V> {
ret
}
unsafe fn insert_unchecked(&mut self, _key: K, _val: V) {
todo!();
}
}
impl<'a, K: Hash, V> FromIterator<(K, V)> for RocDict<K, V> {
fn from_iter<T: IntoIterator<Item = (K, V)>>(into_iter: T) -> Self {
RocDict::from_iter(into_iter.into_iter())
}
}
impl<'a, K, V> IntoIterator for &'a RocDict<K, V> {

View File

@ -151,7 +151,7 @@ impl<T> RocList<T> {
/// bytes over - in other words, calling this `as_slice` method and then calling `to_vec`
/// on that.
pub fn as_slice(&self) -> &[T] {
&*self
self
}
#[inline(always)]

View File

@ -27,10 +27,11 @@ impl<T> RocSet<T> {
}
}
impl<T: Hash> RocSet<T> {
#[allow(unused)]
pub fn from_iter<I: Iterator<Item = T>>(src: I) -> Self {
Self(RocDict::from_iter(src.map(|elem| (elem, ()))))
impl<T: Hash> FromIterator<T> for RocSet<T> {
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Self {
Self(RocDict::from_iter(
into_iter.into_iter().map(|elem| (elem, ())),
))
}
}

View File

@ -154,7 +154,7 @@ impl RocStr {
/// bytes over - in other words, calling this `as_str` method and then calling `to_string`
/// on that.
pub fn as_str(&self) -> &str {
&*self
self
}
/// Create an empty RocStr with enough space preallocated to store
@ -562,8 +562,8 @@ impl Deref for RocStr {
fn deref(&self) -> &Self::Target {
match self.as_enum_ref() {
RocStrInnerRef::HeapAllocated(h) => unsafe { core::str::from_utf8_unchecked(&*h) },
RocStrInnerRef::SmallString(s) => &*s,
RocStrInnerRef::HeapAllocated(h) => unsafe { core::str::from_utf8_unchecked(h) },
RocStrInnerRef::SmallString(s) => s,
}
}
}

View File

@ -1,3 +1,5 @@
#![allow(clippy::missing_safety_doc)]
#[macro_use]
extern crate pretty_assertions;
extern crate quickcheck;