1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-03 18:54:05 +02:00

split multiple values by whitespace

This commit is contained in:
Quaternions 2025-02-22 09:12:34 -08:00
commit dd3000d330
3 changed files with 5 additions and 5 deletions

View file

@ -162,7 +162,7 @@ where
[T; N]: Default, [T; N]: Default,
{ {
fn parse(raw: &'_ str) -> Result<Self, EntityParseError> { fn parse(raw: &'_ str) -> Result<Self, EntityParseError> {
let mut values = raw.split(' ').map(T::from_str); let mut values = raw.split_whitespace().map(T::from_str);
let mut result = <[T; N]>::default(); let mut result = <[T; N]>::default();
for item in result.iter_mut() { for item in result.iter_mut() {
*item = values.next().ok_or(EntityParseError::ElementCount)??; *item = values.next().ok_or(EntityParseError::ElementCount)??;
@ -200,7 +200,7 @@ impl FromStr for Color {
type Err = EntityParseError; type Err = EntityParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut floats = s.split(' ').map(u8::from_str); let mut floats = s.split_whitespace().map(u8::from_str);
let r = floats.next().ok_or(EntityParseError::ElementCount)??; let r = floats.next().ok_or(EntityParseError::ElementCount)??;
let g = floats.next().ok_or(EntityParseError::ElementCount)??; let g = floats.next().ok_or(EntityParseError::ElementCount)??;
let b = floats.next().ok_or(EntityParseError::ElementCount)??; let b = floats.next().ok_or(EntityParseError::ElementCount)??;
@ -235,7 +235,7 @@ impl FromStr for LightColor {
type Err = EntityParseError; type Err = EntityParseError;
fn from_str(str: &str) -> Result<Self, Self::Err> { fn from_str(str: &str) -> Result<Self, Self::Err> {
let mut values = str.split(' '); let mut values = str.split_whitespace();
let r = values let r = values
.next() .next()
.ok_or(EntityParseError::ElementCount)? .ok_or(EntityParseError::ElementCount)?

View file

@ -558,7 +558,7 @@ impl FromStr for Angles {
type Err = EntityParseError; type Err = EntityParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut floats = s.split(' ').map(f32::from_str); let mut floats = s.split_whitespace().map(f32::from_str);
let pitch = floats.next().ok_or(EntityParseError::ElementCount)??; let pitch = floats.next().ok_or(EntityParseError::ElementCount)??;
let yaw = floats.next().ok_or(EntityParseError::ElementCount)??; let yaw = floats.next().ok_or(EntityParseError::ElementCount)??;
let roll = floats.next().ok_or(EntityParseError::ElementCount)??; let roll = floats.next().ok_or(EntityParseError::ElementCount)??;

View file

@ -99,7 +99,7 @@ impl FromStr for Vector {
type Err = EntityParseError; type Err = EntityParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut floats = s.split(' ').map(f32::from_str); let mut floats = s.split_whitespace().map(f32::from_str);
let x = floats.next().ok_or(EntityParseError::ElementCount)??; let x = floats.next().ok_or(EntityParseError::ElementCount)??;
let y = floats.next().ok_or(EntityParseError::ElementCount)??; let y = floats.next().ok_or(EntityParseError::ElementCount)??;
let z = floats.next().ok_or(EntityParseError::ElementCount)??; let z = floats.next().ok_or(EntityParseError::ElementCount)??;