how would I go about changing a str into a array of bytes or chars?
for example:
"1.1.1.1" -> ["1", ".", "1", ".", "1", ".", "1"]
The string is an ip so no usual characters.
I have tried doing try_into()
but got
expected array `[u8; 10]`
found struct `std::slice::Iter<'_, u8>`
Any guidance would be appreciated.
Edit: In my use case I have a struct called Player:
struct Player {
cards: [i32, 2],
chips: u32,
ip: [u8; 10],
folded: bool,
hand: u8,
}
And I'd like to set the id to a string that would be received and store it as a array. Ideally the struct would impl
copy, so a vec
can't be used.
a player being made:
Player {
cards: [4,5],
chips: 500,
ip: "localhost", // how to change this to an array
folded: false,
hand: 0,
}