Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

eliminate redundantcopy #4

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tun2"
version = "0.6.2"
version = "0.6.3"
edition = "2021"

authors = ["meh. <[email protected]>", "@ssrlive"]
Expand Down
20 changes: 10 additions & 10 deletions src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ impl<'a> IntoAddress for &'a str {

impl IntoAddress for String {
fn into_address(&self) -> Result<Ipv4Addr> {
(**self).into_address()
self.as_str().into_address()
}
}

impl<'a> IntoAddress for &'a String {
fn into_address(&self) -> Result<Ipv4Addr> {
(**self).into_address()
self.as_str().into_address()
}
}

Expand All @@ -79,14 +79,14 @@ impl IntoAddress for Ipv4Addr {

impl<'a> IntoAddress for &'a Ipv4Addr {
fn into_address(&self) -> Result<Ipv4Addr> {
(**self).into_address()
(*self).into_address()
}
}

impl IntoAddress for IpAddr {
fn into_address(&self) -> Result<Ipv4Addr> {
match *self {
IpAddr::V4(ref value) => Ok(*value),
match self {
IpAddr::V4(value) => Ok(*value),

IpAddr::V6(_) => Err(Error::InvalidAddress),
}
Expand All @@ -95,7 +95,7 @@ impl IntoAddress for IpAddr {

impl<'a> IntoAddress for &'a IpAddr {
fn into_address(&self) -> Result<Ipv4Addr> {
(**self).into_address()
(*self).into_address()
}
}

Expand All @@ -107,14 +107,14 @@ impl IntoAddress for SocketAddrV4 {

impl<'a> IntoAddress for &'a SocketAddrV4 {
fn into_address(&self) -> Result<Ipv4Addr> {
(**self).into_address()
(*self).into_address()
}
}

impl IntoAddress for SocketAddr {
fn into_address(&self) -> Result<Ipv4Addr> {
match *self {
SocketAddr::V4(ref value) => Ok(*value.ip()),
match self {
SocketAddr::V4(value) => Ok(*value.ip()),

SocketAddr::V6(_) => Err(Error::InvalidAddress),
}
Expand All @@ -123,6 +123,6 @@ impl IntoAddress for SocketAddr {

impl<'a> IntoAddress for &'a SocketAddr {
fn into_address(&self) -> Result<Ipv4Addr> {
(**self).into_address()
(*self).into_address()
}
}
2 changes: 1 addition & 1 deletion src/platform/macos/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Device {
/// Split the interface into a `Reader` and `Writer`.
pub fn split(self) -> (posix::Reader, posix::Writer) {
let fd = Arc::new(self.queue.tun);
(posix::Reader(fd.clone()), posix::Writer(fd.clone()))
(posix::Reader(fd.clone()), posix::Writer(fd))
}

/// Return whether the device has packet information
Expand Down