Send, Sync, Borrow, AsRef, remove Cargo.lock
This commit is contained in:
parent
eb64585d3c
commit
23f0c5ddd8
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
/target
|
/target
|
||||||
|
Cargo.lock
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -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"
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "stringish"
|
name = "stringish"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "A smaller and easier copy-on-write string"
|
description = "A smaller and easier copy-on-write string"
|
||||||
repository = "https://git.karx.xyz/missing/stringish"
|
repository = "https://git.karx.xyz/missing/stringish"
|
||||||
|
|
14
src/impls.rs
14
src/impls.rs
|
@ -1,5 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::{Borrow, Cow},
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
};
|
};
|
||||||
|
@ -101,3 +101,15 @@ macro_rules! impl_eq_ord {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_eq_ord!(str, &'a str, String, Cow<'a, str>);
|
impl_eq_ord!(str, &'a str, String, Cow<'a, str>);
|
||||||
|
|
||||||
|
impl AsRef<str> for Stringish {
|
||||||
|
fn as_ref(&self) -> &str {
|
||||||
|
&self[..]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Borrow<str> for Stringish {
|
||||||
|
fn borrow(&self) -> &str {
|
||||||
|
&self[..]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@ pub struct Stringish {
|
||||||
cap: usize,
|
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 {
|
impl Drop for Stringish {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if let Some(true) = self.is_owned() {
|
if let Some(true) = self.is_owned() {
|
||||||
|
|
Loading…
Reference in a new issue