diff --git a/.gitignore b/.gitignore index ea8c4bf..869df07 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +Cargo.lock \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 9a30d08..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "stringish" -version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index f26c58a..1800df9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stringish" -version = "0.1.0" +version = "0.1.1" edition = "2021" description = "A smaller and easier copy-on-write string" repository = "https://git.karx.xyz/missing/stringish" diff --git a/src/impls.rs b/src/impls.rs index 4b04d94..a76c787 100644 --- a/src/impls.rs +++ b/src/impls.rs @@ -1,5 +1,5 @@ use std::{ - borrow::Cow, + borrow::{Borrow, Cow}, fmt::{Debug, Display}, hash::Hash, }; @@ -101,3 +101,15 @@ macro_rules! impl_eq_ord { } impl_eq_ord!(str, &'a str, String, Cow<'a, str>); + +impl AsRef for Stringish { + fn as_ref(&self) -> &str { + &self[..] + } +} + +impl Borrow for Stringish { + fn borrow(&self) -> &str { + &self[..] + } +} diff --git a/src/lib.rs b/src/lib.rs index 7761f6a..57cad9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,6 +47,10 @@ pub struct Stringish { cap: usize, } +// SAFETY: this can be `Send + Sync` for the same reasons `String` can be +unsafe impl Send for Stringish {} +unsafe impl Sync for Stringish {} + impl Drop for Stringish { fn drop(&mut self) { if let Some(true) = self.is_owned() {