fn encode_socket_addr(addr: &SocketAddr) -> Vec<u8> {
    let mut buffer = match addr {
        SocketAddr::V4(addr) => {
            let mut buffer = Vec::with_capacity(6);
            buffer.extend(addr.ip().octets().as_ref());
            buffer
        }
        SocketAddr::V6(addr) => {
            let mut buffer = Vec::with_capacity(18);
            buffer.extend(addr.ip().octets().as_ref());
            buffer
        }
    };

    buffer.extend(addr.port().to_be_bytes().as_ref());
    buffer
}
// TODO: consider returning `ArrayVec` to avoid lot of small allocations.
consider returning `ArrayVec` to avoid lot of small allocations.
consider returning ` ArrayVec ` to avoid lot of small allocations .
fn encode_socket_addr(addr: &SocketAddr) -> Vec<u8> {
    let mut buffer = match addr {
        SocketAddr::V4(addr) => {
            let mut buffer = Vec::with_capacity(6);
            buffer.extend(addr.ip().octets().as_ref());
            buffer
        }
        SocketAddr::V6(addr) => {
            let mut buffer = Vec::with_capacity(18);
            buffer.extend(addr.ip().octets().as_ref());
            buffer
        }
    };
    buffer.extend(addr.port().to_be_bytes().as_ref());
    buffer
}
fn encode_socket_addr ( addr : & SocketAddr ) -> Vec < u8 > { let mut buffer = match addr { SocketAddr :: V4 ( addr ) => { let mut buffer = Vec :: with_capacity ( 6 ) ; buffer . extend ( addr . ip ( ) . octets ( ) . as_ref ( ) ) ; buffer } SocketAddr :: V6 ( addr ) => { let mut buffer = Vec :: with_capacity ( 18 ) ; buffer . extend ( addr . ip ( ) . octets ( ) . as_ref ( ) ) ; buffer } } ; buffer . extend ( addr . port ( ) . to_be_bytes ( ) . as_ref ( ) ) ; buffer }
TODO: consider returning `ArrayVec` to avoid lot of small allocations.
TODO : consider returning ` ArrayVec ` to avoid lot of small allocations .
addr
&SocketAddr
addr
&SocketAddr