From 878ae3fedfc3ed882c3435789f9f49a5f6478fe9 Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Sun, 25 Jun 2023 15:56:36 +0200 Subject: [PATCH] change Into implementations to From implementations for LocalPath --- src/common.rs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/common.rs b/src/common.rs index 66c72ea..e545a8c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,7 +1,9 @@ use std::ffi::{OsStr, OsString}; +use std::fmt::Debug; use std::ops::Deref; use std::path::{Path, PathBuf}; +//region LocalPath #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct LocalPath(PathBuf); @@ -54,32 +56,33 @@ impl Deref for LocalPath { } //------------------------------------------ -impl Into for LocalPath { - fn into(self) -> PathBuf { - self.0 +impl From for PathBuf { + fn from(value: LocalPath) -> Self { + value.0 } } -impl Into for LocalPath { - fn into(self) -> OsString { - self.0.into_os_string() +impl From for OsString { + fn from(value: LocalPath) -> Self { + value.0.into_os_string() } } -impl<'a> Into<&'a Path> for &'a LocalPath { - fn into(self) -> &'a Path { - &self.0 +impl<'a> From<&'a LocalPath> for &'a Path { + fn from(value: &'a LocalPath) -> Self { + &value.0 } } -impl<'a> Into<&'a OsStr> for &'a LocalPath { - fn into(self) -> &'a OsStr { - self.0.as_os_str() +impl<'a> From<&'a LocalPath> for &'a OsStr { + fn from(value: &'a LocalPath) -> Self { + value.0.as_os_str() } } -impl<'a> Into<&'a PathBuf> for &'a LocalPath { - fn into(self) -> &'a PathBuf { - &self.0 +impl<'a> From<&'a LocalPath> for &'a PathBuf { + fn from(value: &'a LocalPath) -> Self { + &value.0 } } +//endregion