use std::ops::Div;
use super::core::Path;
impl Div<&Path> for &Path {
type Output = Path;
fn div(self, rhs: &Path) -> Self::Output {
self.join(rhs)
}
}
impl Div<&Path> for Path {
type Output = Path;
fn div(self, rhs: &Path) -> Self::Output {
self.join(rhs)
}
}
impl Div<Path> for &Path {
type Output = Path;
fn div(self, rhs: Path) -> Self::Output {
self.join(&rhs)
}
}
impl Div<Path> for Path {
type Output = Path;
fn div(self, rhs: Path) -> Self::Output {
self.join(&rhs)
}
}
impl Div<&str> for &Path {
type Output = Path;
fn div(self, rhs: &str) -> Self::Output {
self.join(rhs)
}
}
impl Div<&String> for &Path {
type Output = Path;
fn div(self, rhs: &String) -> Self::Output {
self.join(rhs.as_str())
}
}
impl Div<String> for &Path {
type Output = Path;
fn div(self, rhs: String) -> Self::Output {
self.join(rhs.as_str())
}
}
impl Div<&str> for Path {
type Output = Path;
fn div(self, rhs: &str) -> Self::Output {
self.join(rhs)
}
}
impl Div<&String> for Path {
type Output = Path;
fn div(self, rhs: &String) -> Self::Output {
self.join(rhs.as_str())
}
}
impl Div<String> for Path {
type Output = Path;
fn div(self, rhs: String) -> Self::Output {
self.join(rhs.as_str())
}
}
#[cfg(test)]
mod tests {
use super::Path;
#[test]
fn test_div_ref_path_ref_path() {
let path = Path::new("/test/path");
let subpath = Path::new("subpath");
let result = &path / &subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_ref_path_owned_path() {
let path = Path::new("/test/path");
let subpath = Path::new("subpath");
let result = &path / subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_owned_path_ref_path() {
let path = Path::new("/test/path");
let subpath = Path::new("subpath");
let result = path / &subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_owned_path_owned_path() {
let path = Path::new("/test/path");
let subpath = Path::new("subpath");
let result = path / subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_ref_path_ref_str() {
let path = Path::new("/test/path");
let subpath = "subpath";
let result = &path / subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_ref_path_string() {
let path = Path::new("/test/path");
let subpath = String::from("subpath");
let result = &path / subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_ref_path_ref_string() {
let path = Path::new("/test/path");
let subpath = &String::from("subpath");
let result = &path / subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_owned_path_ref_str() {
let path = Path::new("/test/path");
let result = path / "subpath";
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_owned_path_string() {
let path = Path::new("/test/path");
let result = path / String::from("subpath");
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_div_owned_path_ref_string() {
let path = Path::new("/test/path");
let subpath = &String::from("subpath");
let result = path / subpath;
assert_eq!(result, Path::new("/test/path/subpath"));
}
#[test]
fn test_multiple_div() {
let path = Path::new("/test");
let result = path / "path" / "to" / "file.txt";
assert_eq!(result, Path::new("/test/path/to/file.txt"));
}
#[test]
fn test_div_empty_string() {
let path = Path::new("/test/path");
let result = path / "";
assert_eq!(result, Path::new("/test/path"));
}
#[test]
fn test_div_with_separator() {
let path = Path::new("/test/path");
let result = path / "to/file.txt";
assert_eq!(result, Path::new("/test/path/to/file.txt"));
}
#[test]
fn test_div_preserves_original_owned() {
let original = Path::new("/test/path");
let _result = original.clone() / "subpath";
assert_eq!(original, Path::new("/test/path"));
}
#[test]
fn test_div_preserves_original_ref() {
let original = Path::new("/test/path");
let _result = &original / "subpath";
assert_eq!(original, Path::new("/test/path"));
}
}