Skip to content

Commit 0b1aa69

Browse files
committed
Switch the Into impls over to From.
1 parent ec4d0da commit 0b1aa69

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/boxed.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ impl From<String> for BoxedString {
163163
}
164164
}
165165

166-
impl Into<String> for BoxedString {
167-
fn into(self) -> String {
166+
impl From<BoxedString> for String {
167+
fn from(s: BoxedString) -> Self {
168168
#[allow(unsafe_code)]
169-
let s = unsafe { String::from_raw_parts(self.ptr.as_ptr(), self.len(), self.capacity()) };
170-
forget(self);
171-
s
169+
let out = unsafe { String::from_raw_parts(s.ptr.as_ptr(), s.len(), s.capacity()) };
170+
forget(s);
171+
out
172172
}
173173
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,12 +865,12 @@ impl<Mode: SmartStringMode> FromStr for SmartString<Mode> {
865865
}
866866
}
867867

868-
impl<Mode: SmartStringMode> Into<String> for SmartString<Mode> {
868+
impl<Mode: SmartStringMode> From<SmartString<Mode>> for String {
869869
/// Unwrap a boxed [`String`][String], or copy an inline string into a new [`String`][String].
870870
///
871871
/// [String]: https://doc.rust-lang.org/std/string/struct.String.html
872-
fn into(self) -> String {
873-
match self.cast_into() {
872+
fn from(s: SmartString<Mode>) -> Self {
873+
match s.cast_into() {
874874
StringCastInto::Boxed(string) => string.into(),
875875
StringCastInto::Inline(string) => string.to_string(),
876876
}

0 commit comments

Comments
 (0)