Skip to content

Commit 1960d11

Browse files
committed
Fix order of import statements using rustfmt
1 parent 120aa21 commit 1960d11

30 files changed

+55
-65
lines changed

screeps-game-api/src/constants.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
//! <https://github.com/screeps/common/commits/master/lib/constants.js>.
55
//!
66
//! [the game constants]: https://github.com/screeps/common/blob/master/lib/constants.js
7-
use stdweb::{Number, Reference, Value};
8-
97
use crate::{
108
objects::RoomObject,
119
traits::{FromExpectedType, TryFrom, TryInto},
1210
ConversionError,
1311
};
14-
1512
use log::error;
1613
use num_derive::FromPrimitive;
17-
use serde::{Serialize, Deserialize};
14+
use serde::{Deserialize, Serialize};
15+
use stdweb::{Number, Reference, Value};
1816

1917
#[repr(i32)]
2018
#[derive(Debug, PartialEq, Eq, Clone, Copy, FromPrimitive, Hash)]
@@ -128,17 +126,15 @@ unsafe impl FindConstant for FindObject {
128126
}
129127

130128
pub mod find {
131-
use serde::Deserialize;
132-
129+
use super::FindConstant;
133130
use crate::{
134131
objects::{
135132
ConstructionSite, Creep, Flag, Mineral, Nuke, OwnedStructure, Resource, RoomPosition,
136133
Source, Structure, StructureSpawn, Tombstone,
137134
},
138135
traits::TryFrom,
139136
};
140-
141-
use super::FindConstant;
137+
use serde::Deserialize;
142138

143139
#[derive(Copy, Clone, Debug, Deserialize, PartialEq, Eq, Hash)]
144140
#[serde(transparent)]

screeps-game-api/src/game.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub mod cpu {
102102
/// [http://docs.screeps.com/api/#Game.gcl]: http://docs.screeps.com/api/#Game.gcl
103103
pub mod gcl {
104104
use crate::macros::*;
105+
105106
/// See [http://docs.screeps.com/api/#Game.gcl]
106107
///
107108
/// [http://docs.screeps.com/api/#Game.gcl]: http://docs.screeps.com/api/#Game.gcl
@@ -128,18 +129,16 @@ pub mod gcl {
128129
///
129130
/// [http://docs.screeps.com/api/#Game.map]: http://docs.screeps.com/api/#Game.map
130131
pub mod map {
131-
use crate::macros::*;
132-
use serde::Deserialize;
133-
use std::{collections, mem};
134-
135-
use crate::traits::{TryFrom, TryInto};
136-
use scoped_tls::scoped_thread_local;
137-
use stdweb::Value;
138-
139132
use crate::{
140133
constants::{find::Exit, Direction, ReturnCode},
134+
macros::*,
141135
objects::RoomTerrain,
136+
traits::{TryFrom, TryInto},
142137
};
138+
use scoped_tls::scoped_thread_local;
139+
use serde::Deserialize;
140+
use std::{collections, mem};
141+
use stdweb::Value;
143142

144143
/// See [http://docs.screeps.com/api/#Game.map.describeExits]
145144
///
@@ -271,14 +270,14 @@ pub mod map {
271270
}
272271

273272
pub mod market {
274-
use crate::{macros::*, traits::TryInto};
275-
use serde::Deserialize;
276-
use std::collections::HashMap;
277-
278273
use crate::{
279274
constants::{ResourceType, ReturnCode},
275+
macros::*,
276+
traits::TryInto,
280277
Room,
281278
};
279+
use serde::Deserialize;
280+
use std::collections::HashMap;
282281

283282
#[repr(u32)]
284283
#[derive(Clone, Debug)]

screeps-game-api/src/js_collections/js_vec.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
//! [`JsVec`]
2-
use std::marker::PhantomData;
3-
4-
use stdweb::{Array, InstanceOf, JsSerialize, Reference, ReferenceType, Value};
5-
62
use crate::{
73
macros::*,
84
traits::{FromExpectedType, IntoExpectedType, TryFrom, TryInto},
95
ConversionError,
106
};
7+
use std::marker::PhantomData;
8+
use stdweb::{Array, InstanceOf, JsSerialize, Reference, ReferenceType, Value};
119

1210
//
1311
// - InstanceOf

screeps-game-api/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub use crate::{
3939
positions::{LocalRoomName, LocalRoomNameParseError, LocalRoomPosition},
4040
traits::{FromExpectedType, IntoExpectedType},
4141
};
42-
4342
pub use stdweb::private::ConversionError;
4443

4544
/// Useful for `use screeps::prelude::*;` to bring in screeps traits. Does not

screeps-game-api/src/memory.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@
4949
//! access the memory via creeps, spawns, rooms and flags. Accessing the memory
5050
//! from those objects will also result in a `MemoryReference` which instead
5151
//! points at the root of this object's memory.
52-
//!
53-
use std::fmt;
5452
5553
use crate::{
5654
macros::*,
5755
traits::{TryFrom, TryInto},
5856
ConversionError,
5957
};
58+
use std::fmt;
6059
use stdweb::{JsSerialize, Reference, Value};
6160

6261
#[derive(Clone, Debug)]

screeps-game-api/src/objects/impls/creep.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use std::{marker::PhantomData, mem};
2-
1+
use super::room::Step;
32
use crate::{
43
constants::{Direction, Part, ResourceType, ReturnCode},
54
macros::*,
@@ -12,10 +11,9 @@ use crate::{
1211
traits::TryFrom,
1312
};
1413
use scoped_tls::scoped_thread_local;
14+
use std::{marker::PhantomData, mem};
1515
use stdweb::{Reference, Value};
1616

17-
use super::room::Step;
18-
1917
scoped_thread_local!(static COST_CALLBACK: Box<dyn Fn(String, Reference) -> Option<Reference>>);
2018

2119
impl Creep {

screeps-game-api/src/objects/impls/mineral.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
macros::*,
44
objects::Mineral,
55
};
6+
67
simple_accessors! {
78
Mineral;
89
(density -> density -> u32),

screeps-game-api/src/objects/impls/nuke.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{macros::*, objects::Nuke};
2+
23
simple_accessors! {
34
Nuke;
45
// id from HasID

screeps-game-api/src/objects/impls/resource.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{constants::ResourceType, macros::*, objects::Resource};
2+
23
impl Resource {
34
pub fn resource_type(&self) -> ResourceType {
45
js_unwrap!(__resource_type_str_to_num(@{self.as_ref()}.resourceType))

screeps-game-api/src/objects/impls/room.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
use std::{fmt, marker::PhantomData, mem, ops::Range};
2-
3-
use scoped_tls::scoped_thread_local;
4-
use serde::{
5-
self,
6-
de::{self, Deserializer, MapAccess, Visitor},
7-
Deserialize, Serialize,
8-
};
9-
use serde_json;
10-
use stdweb::{Reference, Value};
11-
121
use crate::{
132
constants::{
143
find::Exit, Color, Direction, FindConstant, LookConstant, ReturnCode, StructureType,
@@ -26,6 +15,15 @@ use crate::{
2615
traits::{TryFrom, TryInto},
2716
ConversionError,
2817
};
18+
use scoped_tls::scoped_thread_local;
19+
use serde::{
20+
self,
21+
de::{self, Deserializer, MapAccess, Visitor},
22+
Deserialize, Serialize,
23+
};
24+
use serde_json;
25+
use std::{fmt, marker::PhantomData, mem, ops::Range};
26+
use stdweb::{Reference, Value};
2927

3028
simple_accessors! {
3129
Room;

screeps-game-api/src/objects/impls/room_position.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::room::{FindOptions, Path};
12
use crate::{
23
constants::{Color, Direction, FindConstant, LookConstant, ReturnCode},
34
game,
@@ -9,8 +10,6 @@ use crate::{
910
};
1011
use std::cmp::{Eq, PartialEq};
1112

12-
use super::room::{FindOptions, Path};
13-
1413
impl RoomPosition {
1514
pub fn new(x: u32, y: u32, room_name: &str) -> Self {
1615
js_unwrap!(new RoomPosition(@{x}, @{y}, @{room_name}))

screeps-game-api/src/objects/impls/source.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{macros::*, objects::Source};
2+
23
simple_accessors! {
34
Source;
45
(energy -> energy -> u32),

screeps-game-api/src/objects/impls/structure_controller.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use stdweb::Value;
2-
31
use crate::{constants::ReturnCode, macros::*, objects::StructureController};
2+
use stdweb::Value;
43
simple_accessors! {
54
StructureController;
65
(level -> level -> u32),

screeps-game-api/src/objects/impls/structure_keeper_lair.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{macros::*, objects::StructureKeeperLair};
2+
23
simple_accessors! {
34
StructureKeeperLair;
45
(ticks_to_spawn -> ticksToSpawn -> u32),

screeps-game-api/src/objects/impls/structure_lab.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
macros::*,
44
objects::{Creep, StructureLab},
55
};
6+
67
simple_accessors! {
78
StructureLab;
89
(mineral_amount -> mineralAmount -> u32),

screeps-game-api/src/objects/impls/structure_link.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{constants::ReturnCode, macros::*, objects::StructureLink};
2+
23
impl StructureLink {
34
pub fn transfer_energy(&self, target: &StructureLink, amount: Option<u32>) -> ReturnCode {
45
match amount {

screeps-game-api/src/objects/impls/structure_nuker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
macros::*,
44
objects::{RoomPosition, StructureNuker},
55
};
6+
67
simple_accessors! {
78
StructureNuker;
89
(ghodium -> ghodium -> u32),

screeps-game-api/src/objects/impls/structure_observer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{constants::ReturnCode, macros::*, objects::StructureObserver};
2+
23
impl StructureObserver {
34
pub fn observe_room(&self, room_name: &str) -> ReturnCode {
45
js_unwrap! {@{self.as_ref()}.observeRoom(@{room_name})}

screeps-game-api/src/objects/impls/structure_portal.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::{
33
objects::{RoomPosition, StructurePortal},
44
traits::TryInto,
55
};
6-
76
use serde::Deserialize;
87

98
#[derive(Deserialize, Debug)]

screeps-game-api/src/objects/impls/structure_power_bank.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{macros::*, objects::StructurePowerBank};
2+
23
simple_accessors! {
34
StructurePowerBank;
45
(power -> power -> u32),

screeps-game-api/src/objects/impls/structure_power_spawn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{constants::ReturnCode, macros::*, objects::StructurePowerSpawn};
2+
23
simple_accessors! {
34
StructurePowerSpawn;
45
(power -> power -> u32),

screeps-game-api/src/objects/impls/structure_rampart.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{constants::ReturnCode, macros::*, objects::StructureRampart};
2+
23
simple_accessors! {
34
StructureRampart;
45
(is_public -> isPublic -> bool),

screeps-game-api/src/objects/impls/structure_spawn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use stdweb::Reference;
2-
31
use crate::{
42
constants::{Direction, Part, ReturnCode},
53
macros::*,
64
memory::MemoryReference,
75
objects::{Creep, HasEnergyForSpawn, SizedRoomObject, Spawning, StructureSpawn},
86
traits::TryInto,
97
};
8+
use stdweb::Reference;
9+
1010
simple_accessors! {
1111
StructureSpawn;
1212
(name -> name -> String),

screeps-game-api/src/objects/impls/structure_terminal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
macros::*,
44
objects::StructureTerminal,
55
};
6+
67
impl StructureTerminal {
78
pub fn send(
89
&self,

screeps-game-api/src/objects/impls/structure_tower.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
macros::*,
44
objects::{Creep, Structure, StructureTower},
55
};
6+
67
impl StructureTower {
78
pub fn attack(&self, target: &Creep) -> ReturnCode {
89
js_unwrap! { @{self.as_ref()}.attack( @{target.as_ref()} ) }

screeps-game-api/src/objects/impls/tombstone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::{
22
macros::*,
33
objects::{Creep, Tombstone},
44
};
5+
56
simple_accessors! {
67
Tombstone;
78
(creep -> creep -> Creep),

screeps-game-api/src/objects/structure.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use stdweb::{InstanceOf, Reference, ReferenceType, Value};
2-
31
use super::*;
42
use crate::{
53
constants::StructureType,
64
objects::{Attackable, CanDecay, CanStoreEnergy, HasCooldown, HasEnergyForSpawn, HasStore},
75
traits::FromExpectedType,
86
ConversionError,
97
};
8+
use stdweb::{InstanceOf, Reference, ReferenceType, Value};
109

1110
/// Wrapper which can be any of the game Structures.
1211
///

screeps-game-api/src/pathfinder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
use std::{f64, marker::PhantomData, mem};
2-
3-
use stdweb::{web::TypedArray, Array, Object, Reference, UnsafeTypedArray};
4-
51
use crate::{
62
macros::*,
73
objects::{HasPosition, RoomPosition},
84
positions::LocalRoomPosition,
95
traits::TryInto,
106
};
117
use scoped_tls::scoped_thread_local;
8+
use std::{f64, marker::PhantomData, mem};
9+
use stdweb::{web::TypedArray, Array, Object, Reference, UnsafeTypedArray};
1210

1311
#[derive(Clone, Debug)]
1412
pub struct LocalCostMatrix {

0 commit comments

Comments
 (0)