mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 10:44:07 +02:00
split multiple values by whitespace
This commit is contained in:
parent
bf27b6c892
commit
dd3000d330
3 changed files with 5 additions and 5 deletions
|
|
@ -162,7 +162,7 @@ where
|
|||
[T; N]: Default,
|
||||
{
|
||||
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();
|
||||
for item in result.iter_mut() {
|
||||
*item = values.next().ok_or(EntityParseError::ElementCount)??;
|
||||
|
|
@ -200,7 +200,7 @@ impl FromStr for Color {
|
|||
type Err = EntityParseError;
|
||||
|
||||
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 g = 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;
|
||||
|
||||
fn from_str(str: &str) -> Result<Self, Self::Err> {
|
||||
let mut values = str.split(' ');
|
||||
let mut values = str.split_whitespace();
|
||||
let r = values
|
||||
.next()
|
||||
.ok_or(EntityParseError::ElementCount)?
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ impl FromStr for Angles {
|
|||
type Err = EntityParseError;
|
||||
|
||||
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 yaw = floats.next().ok_or(EntityParseError::ElementCount)??;
|
||||
let roll = floats.next().ok_or(EntityParseError::ElementCount)??;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ impl FromStr for Vector {
|
|||
type Err = EntityParseError;
|
||||
|
||||
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 y = floats.next().ok_or(EntityParseError::ElementCount)??;
|
||||
let z = floats.next().ok_or(EntityParseError::ElementCount)??;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue