Skip to content

Commit 676f640

Browse files
author
Bryant Mairs
committed
Remove unnecessary impl Clones
1 parent 0e41649 commit 676f640

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

src/sys/socket/addr.rs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl AddressFamily {
222222
}
223223
}
224224

225-
#[derive(Copy)]
225+
#[derive(Clone, Copy)]
226226
pub enum InetAddr {
227227
V4(libc::sockaddr_in),
228228
V6(libc::sockaddr_in6),
@@ -348,12 +348,6 @@ impl hash::Hash for InetAddr {
348348
}
349349
}
350350

351-
impl Clone for InetAddr {
352-
fn clone(&self) -> InetAddr {
353-
*self
354-
}
355-
}
356-
357351
impl fmt::Display for InetAddr {
358352
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
359353
match *self {
@@ -421,7 +415,7 @@ impl fmt::Display for IpAddr {
421415
*
422416
*/
423417

424-
#[derive(Copy)]
418+
#[derive(Clone, Copy)]
425419
pub struct Ipv4Addr(pub libc::in_addr);
426420

427421
impl Ipv4Addr {
@@ -469,12 +463,6 @@ impl hash::Hash for Ipv4Addr {
469463
}
470464
}
471465

472-
impl Clone for Ipv4Addr {
473-
fn clone(&self) -> Ipv4Addr {
474-
*self
475-
}
476-
}
477-
478466
impl fmt::Display for Ipv4Addr {
479467
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
480468
let octets = self.octets();
@@ -550,7 +538,7 @@ impl fmt::Display for Ipv6Addr {
550538
/// does not require that `sun_len` include the terminating null even for normal
551539
/// sockets. Note that the actual sockaddr length is greater by
552540
/// `offset_of!(libc::sockaddr_un, sun_path)`
553-
#[derive(Copy)]
541+
#[derive(Clone, Copy)]
554542
pub struct UnixAddr(pub libc::sockaddr_un, pub usize);
555543

556544
impl UnixAddr {
@@ -657,12 +645,6 @@ impl hash::Hash for UnixAddr {
657645
}
658646
}
659647

660-
impl Clone for UnixAddr {
661-
fn clone(&self) -> UnixAddr {
662-
*self
663-
}
664-
}
665-
666648
impl fmt::Display for UnixAddr {
667649
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
668650
if self.1 == 0 {
@@ -683,7 +665,7 @@ impl fmt::Display for UnixAddr {
683665
*/
684666

685667
/// Represents a socket address
686-
#[derive(Copy)]
668+
#[derive(Clone, Copy)]
687669
pub enum SockAddr {
688670
Inet(InetAddr),
689671
Unix(UnixAddr),
@@ -802,12 +784,6 @@ impl hash::Hash for SockAddr {
802784
}
803785
}
804786

805-
impl Clone for SockAddr {
806-
fn clone(&self) -> SockAddr {
807-
*self
808-
}
809-
}
810-
811787
impl fmt::Display for SockAddr {
812788
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
813789
match *self {

src/sys/utsname.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ use std::ffi::CStr;
44
use std::str::from_utf8_unchecked;
55

66
#[repr(C)]
7-
#[derive(Copy)]
7+
#[derive(Clone, Copy)]
88
pub struct UtsName(libc::utsname);
99

10-
// workaround for `derive(Clone)` not working for fixed-length arrays
11-
impl Clone for UtsName { fn clone(&self) -> UtsName { *self } }
12-
1310
impl UtsName {
1411
pub fn sysname(&self) -> &str {
1512
to_str(&(&self.0.sysname as *const c_char ) as *const *const c_char)

0 commit comments

Comments
 (0)