Tidy up lifetimes and warnings
This commit is contained in:
parent
938eed66eb
commit
05ceedad82
10 changed files with 23 additions and 57 deletions
|
@ -1,37 +1,3 @@
|
|||
#![warn(absolute_paths_not_starting_with_crate)]
|
||||
#![warn(box_pointers)]
|
||||
#![warn(elided_lifetimes_in_paths)]
|
||||
#![warn(explicit_outlives_requirements)]
|
||||
#![warn(keyword_idents)]
|
||||
#![warn(macro_use_extern_crate)]
|
||||
#![warn(meta_variable_misuse)]
|
||||
#![warn(missing_abi)]
|
||||
// #![warn(missing_copy_implementations)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
// #![warn(missing_docs)]
|
||||
#![warn(non_ascii_idents)]
|
||||
#![warn(noop_method_call)]
|
||||
#![warn(pointer_structural_match)]
|
||||
#![warn(rust_2021_incompatible_closure_captures)]
|
||||
#![warn(rust_2021_incompatible_or_patterns)]
|
||||
#![warn(rust_2021_prefixes_incompatible_syntax)]
|
||||
#![warn(rust_2021_prelude_collisions)]
|
||||
#![warn(single_use_lifetimes)]
|
||||
#![warn(trivial_casts)]
|
||||
#![warn(trivial_numeric_casts)]
|
||||
#![warn(unreachable_pub)]
|
||||
#![warn(unsafe_code)]
|
||||
#![warn(unsafe_op_in_unsafe_fn)]
|
||||
#![warn(unstable_features)]
|
||||
#![warn(unused_crate_dependencies)]
|
||||
#![warn(unused_extern_crates)]
|
||||
#![warn(unused_import_braces)]
|
||||
#![warn(unused_lifetimes)]
|
||||
#![warn(unused_macro_rules)]
|
||||
#![warn(unused_qualifications)]
|
||||
#![warn(unused_results)]
|
||||
#![warn(variant_size_differences)]
|
||||
|
||||
pub mod world;
|
||||
pub use world::{TerrainCell, World, WorldGenError};
|
||||
pub mod biome;
|
||||
|
|
|
@ -26,7 +26,7 @@ impl Error for CartesianError {
|
|||
}
|
||||
}
|
||||
impl Display for CartesianError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
CartesianError::InvalidAlpha(alpha) => {
|
||||
f.write_fmt(format_args!("Alpha value must be [0..PI], was {}", alpha))
|
||||
|
|
|
@ -50,7 +50,7 @@ impl<'de> Deserialize<'de> for World {
|
|||
impl<'de> Visitor<'de> for WorldVisitor {
|
||||
type Value = World;
|
||||
|
||||
fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
|
||||
fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
|
||||
formatter.write_str("struct World")
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ impl Error for WorldGenError {
|
|||
}
|
||||
}
|
||||
impl Display for WorldGenError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
WorldGenError::CartesianError(err) => Display::fmt(err, f),
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Error for LoadError {
|
|||
}
|
||||
}
|
||||
impl Display for LoadError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
LoadError::MissingSave(_) => f.write_str("No save found at given path"),
|
||||
LoadError::InvalidSave(_) => f.write_str("Loaded file is not a valid save"),
|
||||
|
@ -70,7 +70,7 @@ impl Error for SaveError {
|
|||
}
|
||||
}
|
||||
impl Display for SaveError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
SaveError::MissingWorld => f.write_str("No world to save found."),
|
||||
SaveError::SerializationError(_) => f.write_str("Failed to serialize world."),
|
||||
|
|
|
@ -28,7 +28,7 @@ pub(crate) fn widget<S: 'static + WidgetSystem>(world: &mut World, ui: &mut Ui,
|
|||
instances: HashMap::new(),
|
||||
});
|
||||
}
|
||||
world.resource_scope(|world, mut states: Mut<'_, StateInstances<S>>| {
|
||||
world.resource_scope(|world, mut states: Mut<StateInstances<S>>| {
|
||||
if !states.instances.contains_key(&id) {
|
||||
debug!(
|
||||
"Registering system state for widget {id:?} of type {}",
|
||||
|
|
|
@ -31,7 +31,7 @@ iterable_enum!(ToolbarButton {
|
|||
|
||||
impl ToolbarButton {
|
||||
fn clicked(self, world: &mut World) {
|
||||
world.resource_scope(|world, mut world_manager: Mut<'_, WorldManager>| {
|
||||
world.resource_scope(|world, mut world_manager: Mut<WorldManager>| {
|
||||
match self {
|
||||
ToolbarButton::GenerateWorld => {
|
||||
let generate_world_task = &mut world.resource_mut::<GenerateWorldTask>();
|
||||
|
|
|
@ -49,7 +49,7 @@ fn window<S: 'static + WindowSystem>(world: &mut World, ctx: &Context) {
|
|||
instances: HashMap::new(),
|
||||
});
|
||||
}
|
||||
world.resource_scope(|world, mut states: Mut<'_, StateInstances<S>>| {
|
||||
world.resource_scope(|world, mut states: Mut<StateInstances<S>>| {
|
||||
let id: WindowId = S::name().into();
|
||||
if !states.instances.contains_key(&id) {
|
||||
debug!(
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -37,10 +37,10 @@ use {
|
|||
|
||||
#[cfg(feature = "render")]
|
||||
fn update_cursor_map_position(
|
||||
mut cursor_map_position: ResMut<'_, CursorMapPosition>,
|
||||
transform: Query<'_, '_, (&Camera, &GlobalTransform), With<Camera2d>>,
|
||||
windows: Res<'_, Windows>,
|
||||
world_manager: Res<'_, WorldManager>,
|
||||
mut cursor_map_position: ResMut<CursorMapPosition>,
|
||||
transform: Query<(&Camera, &GlobalTransform), With<Camera2d>>,
|
||||
windows: Res<Windows>,
|
||||
world_manager: Res<WorldManager>,
|
||||
) {
|
||||
let Some(world) = world_manager.get_world() else {
|
||||
return
|
||||
|
@ -70,9 +70,9 @@ fn update_cursor_map_position(
|
|||
}
|
||||
|
||||
fn handle_generate_world_task(
|
||||
mut generate_world_task: ResMut<'_, GenerateWorldTask>,
|
||||
mut world_manager: ResMut<'_, WorldManager>,
|
||||
#[cfg(feature = "render")] mut should_redraw: ResMut<'_, ShouldRedraw>,
|
||||
mut generate_world_task: ResMut<GenerateWorldTask>,
|
||||
mut world_manager: ResMut<WorldManager>,
|
||||
#[cfg(feature = "render")] mut should_redraw: ResMut<ShouldRedraw>,
|
||||
) {
|
||||
if let Some(task) = &mut generate_world_task.0 {
|
||||
if task.is_finished() {
|
||||
|
@ -100,10 +100,10 @@ fn handle_generate_world_task(
|
|||
|
||||
#[cfg(feature = "render")]
|
||||
fn generate_graphics(
|
||||
mut commands: Commands<'_, '_>,
|
||||
images: ResMut<'_, Assets<Image>>,
|
||||
egui_context: ResMut<'_, EguiContext>,
|
||||
render_settings: ResMut<'_, WorldRenderSettings>,
|
||||
mut commands: Commands,
|
||||
images: ResMut<Assets<Image>>,
|
||||
egui_context: ResMut<EguiContext>,
|
||||
render_settings: ResMut<WorldRenderSettings>,
|
||||
) {
|
||||
// Add Julia-Mono font to egui
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ fn open_tile_info(mut windows: ResMut<OpenedWindows>, keys: Res<Input<KeyCode>>)
|
|||
|
||||
#[cfg(feature = "render")]
|
||||
fn update_gui(world: &mut World) {
|
||||
world.resource_scope(|world, mut ctx: Mut<'_, EguiContext>| {
|
||||
world.resource_scope(|world, mut ctx: Mut<EguiContext>| {
|
||||
let ctx = ctx.ctx_mut();
|
||||
#[cfg(feature = "logging")]
|
||||
{
|
||||
|
@ -215,9 +215,9 @@ fn update_gui(world: &mut World) {
|
|||
fn redraw_map(
|
||||
mut should_redraw: ResMut<ShouldRedraw>,
|
||||
world_manager: Res<WorldManager>,
|
||||
render_settings: Res<'_, WorldRenderSettings>,
|
||||
render_settings: Res<WorldRenderSettings>,
|
||||
mut images: ResMut<Assets<Image>>,
|
||||
mut map_sprite: Query<'_, '_, &mut Sprite>,
|
||||
mut map_sprite: Query<&mut Sprite>,
|
||||
) {
|
||||
let Some(world) = world_manager.get_world() else {
|
||||
#[cfg(feature = "logging")]
|
||||
|
|
|
@ -13,7 +13,7 @@ pub(crate) struct CursorMapPosition {
|
|||
}
|
||||
#[cfg(feature = "render")]
|
||||
impl Display for CursorMapPosition {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
f.write_fmt(format_args!("x: {}, y: {}", self.x, self.y))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue