diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 49f82a1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: rust -cache: cargo -rust: - - 1.41.1 - - stable - - beta - - nightly - -jobs: - include: - - rust: nightly - name: "Test minimal dependency versions with Rust nightly" - script: cargo test -Zminimal-versions --verbose --all-features - - rust: stable - name: "Lint with Clippy" - install: rustup component add clippy - script: - - cargo clippy --verbose --all-targets --no-default-features - - cargo clippy --verbose --all-targets --all-features - -install: skip -script: - - cargo test --verbose --all-features - - cargo test --verbose --no-default-features diff --git a/Cargo.toml b/Cargo.toml index 0956bb5..c09e985 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Thomas Bahn ", "Torbjørn Birch Moltu ", "Simon Sapin "] description = "ASCII-only equivalents to `char`, `str` and `String`." documentation = "https://docs.rs/ascii" -license = "Apache-2.0 / MIT" +license = "Apache-2.0 OR MIT" name = "ascii" readme = "README.md" repository = "https://github.com/tomprogrammer/rust-ascii" diff --git a/src/ascii_str.rs b/src/ascii_str.rs index 3c4dbf2..e8a6e12 100644 --- a/src/ascii_str.rs +++ b/src/ascii_str.rs @@ -139,7 +139,7 @@ impl AsciiStr { /// ``` #[inline] #[must_use] - pub fn len(&self) -> usize { + pub const fn len(&self) -> usize { self.slice.len() } @@ -155,7 +155,7 @@ impl AsciiStr { /// ``` #[inline] #[must_use] - pub fn is_empty(&self) -> bool { + pub const fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/src/ascii_string.rs b/src/ascii_string.rs index e85a512..10a88dc 100644 --- a/src/ascii_string.rs +++ b/src/ascii_string.rs @@ -497,16 +497,14 @@ impl From for AsciiString { } } -// FIXME? Turn this into a `From` impl -#[allow(clippy::from_over_into)] -impl Into> for AsciiString { - fn into(mut self) -> Vec { +impl From for Vec { + fn from(mut s: AsciiString) -> Vec { // SAFETY: All ascii bytes are valid `u8`, as we are `repr(u8)`. // Note: We forget `self` to avoid `self.vec` from being deallocated. - let ptr = self.vec.as_mut_ptr().cast::(); - let length = self.vec.len(); - let capacity = self.vec.capacity(); - mem::forget(self); + let ptr = s.vec.as_mut_ptr().cast::(); + let length = s.vec.len(); + let capacity = s.vec.capacity(); + mem::forget(s); // SAFETY: We guarantee all invariants due to getting `ptr`, `length` // and `capacity` from a `Vec`. We also guarantee `ptr` is valid @@ -515,10 +513,9 @@ impl Into> for AsciiString { } } -#[allow(clippy::from_over_into)] -impl Into> for AsciiString { - fn into(self) -> Vec { - self.vec +impl From for Vec { + fn from(s: AsciiString) -> Vec { + s.vec } } @@ -536,13 +533,11 @@ impl<'a> From<&'a [AsciiChar]> for AsciiString { } } -// FIXME? Turn this into a `From` impl -#[allow(clippy::from_over_into)] -impl Into for AsciiString { +impl From for String { #[inline] - fn into(self) -> String { + fn from(s: AsciiString) -> String { // SAFETY: All ascii bytes are `utf8`. - unsafe { String::from_utf8_unchecked(self.into()) } + unsafe { String::from_utf8_unchecked(s.into()) } } } @@ -560,19 +555,17 @@ impl From for Box { } } -#[allow(clippy::from_over_into)] -impl Into> for AsciiString { - fn into(self) -> Rc { - let var: Rc<[AsciiChar]> = self.vec.into(); +impl From for Rc { + fn from(s: AsciiString) -> Rc { + let var: Rc<[AsciiChar]> = s.vec.into(); // SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar] unsafe { Rc::from_raw(Rc::into_raw(var) as *const AsciiStr) } } } -#[allow(clippy::from_over_into)] -impl Into> for AsciiString { - fn into(self) -> Arc { - let var: Arc<[AsciiChar]> = self.vec.into(); +impl From for Arc { + fn from(s: AsciiString) -> Arc { + let var: Arc<[AsciiChar]> = s.vec.into(); // SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar] unsafe { Arc::from_raw(Arc::into_raw(var) as *const AsciiStr) } }