Format Rust code using rustfmt
This commit is contained in:
committed by
GitHub
parent
9a5c4df2b1
commit
cba6c16414
@@ -1,4 +1,4 @@
|
||||
use crate::{AnimationFrames, Image, Position, from_base36, ToBase36, optional_data_line};
|
||||
use crate::{from_base36, optional_data_line, AnimationFrames, Image, Position, ToBase36};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct Sprite {
|
||||
@@ -22,7 +22,11 @@ impl Sprite {
|
||||
|
||||
fn room_position_line(&self) -> String {
|
||||
if self.room_id.is_some() && self.position.is_some() {
|
||||
format!("\nPOS {} {}", self.room_id.unwrap().to_base36(), self.position.as_ref().unwrap().to_string())
|
||||
format!(
|
||||
"\nPOS {} {}",
|
||||
self.room_id.unwrap().to_base36(),
|
||||
self.position.as_ref().unwrap().to_string()
|
||||
)
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
@@ -72,11 +76,20 @@ impl From<String> for Sprite {
|
||||
// todo dedupe
|
||||
let animation_frames = lines[1..].join("");
|
||||
let animation_frames: Vec<&str> = animation_frames.split(">").collect();
|
||||
let animation_frames: Vec<Image> = animation_frames.iter().map(|&frame| {
|
||||
Image::from(frame.to_string())
|
||||
}).collect();
|
||||
let animation_frames: Vec<Image> = animation_frames
|
||||
.iter()
|
||||
.map(|&frame| Image::from(frame.to_string()))
|
||||
.collect();
|
||||
|
||||
Sprite { id, name, animation_frames, dialogue_id, room_id, position, colour_id }
|
||||
Sprite {
|
||||
id,
|
||||
name,
|
||||
animation_frames,
|
||||
dialogue_id,
|
||||
room_id,
|
||||
position,
|
||||
colour_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +110,7 @@ impl ToString for Sprite {
|
||||
|
||||
#[test]
|
||||
fn test_sprite_from_string() {
|
||||
let output = Sprite::from(
|
||||
include_str!("test-resources/sprite").to_string()
|
||||
);
|
||||
let output = Sprite::from(include_str!("test-resources/sprite").to_string());
|
||||
|
||||
let expected = crate::mock::sprite();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user