简体   繁体   English

如何在Rust中将SocketAddr转换为字符串?

[英]How to convert a SocketAddr to a String in Rust?

How can I convert a SocketAddr into a String ? 如何将SocketAddr转换为String I know how to do the conversion the other way round . 我知道如何进行转换

You convert it to a string by calling to_string : 您可以通过调用to_string将其转换为字符串:

fn example(addr: &SocketAddr) -> String {
    addr.to_string()
}

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM