From 49fbaecbdc8531aed73579971fdcebf6183e9057 Mon Sep 17 00:00:00 2001 From: Vivian Hellyer Date: Fri, 16 Apr 2021 20:24:57 -0400 Subject: [PATCH] chore!(command-parser/arguments): remove from impl Remove the `From<&str>` impl for `Arguments` in favor of using `Arguments::new`. Signed-off-by: Vivian Hellyer --- command-parser/src/arguments.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/command-parser/src/arguments.rs b/command-parser/src/arguments.rs index 393190bc0e0..59abdf47658 100644 --- a/command-parser/src/arguments.rs +++ b/command-parser/src/arguments.rs @@ -14,7 +14,11 @@ pub struct Arguments<'a> { impl<'a> Arguments<'a> { /// Returns a new iterator of arguments from a buffer. pub fn new(buf: &'a str) -> Self { - Self::from(buf) + Self { + buf: buf.trim(), + indices: buf.trim().char_indices(), + idx: 0, + } } /// Returns a view of the underlying buffer of arguments. @@ -63,16 +67,6 @@ impl<'a> Arguments<'a> { } } -impl<'a> From<&'a str> for Arguments<'a> { - fn from(buf: &'a str) -> Self { - Self { - buf: buf.trim(), - indices: buf.trim().char_indices(), - idx: 0, - } - } -} - impl<'a> Debug for Arguments<'a> { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { f.debug_struct("Arguments") @@ -139,11 +133,11 @@ mod tests { use static_assertions::assert_impl_all; use std::fmt::Debug; - assert_impl_all!(Arguments<'_>: Clone, Debug, From<&'static str>, Iterator, Send, Sync); + assert_impl_all!(Arguments<'_>: Clone, Debug, Iterator, Send, Sync); #[test] fn test_as_str() { - let args = Arguments::from("foo bar baz"); + let args = Arguments::new("foo bar baz"); assert_eq!("foo bar baz", args.as_str()); }