mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Use slice::split_first instead of manuall slicing
This commit is contained in:
parent
c5a96fb797
commit
6b66749e17
@ -1610,9 +1610,9 @@ impl fmt::Display for Ipv6Addr {
|
|||||||
/// Write a colon-separated part of the address
|
/// Write a colon-separated part of the address
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt_subslice(f: &mut fmt::Formatter<'_>, chunk: &[u16]) -> fmt::Result {
|
fn fmt_subslice(f: &mut fmt::Formatter<'_>, chunk: &[u16]) -> fmt::Result {
|
||||||
if let Some(first) = chunk.first() {
|
if let Some((first, tail)) = chunk.split_first() {
|
||||||
fmt::LowerHex::fmt(first, f)?;
|
fmt::LowerHex::fmt(first, f)?;
|
||||||
for segment in &chunk[1..] {
|
for segment in tail {
|
||||||
f.write_char(':')?;
|
f.write_char(':')?;
|
||||||
fmt::LowerHex::fmt(segment, f)?;
|
fmt::LowerHex::fmt(segment, f)?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user