From 77bc3b4b0940bced09bde28dac210978c04cfe89 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Mon, 29 May 2023 18:06:57 -0700 Subject: [PATCH] cargo fmt --- renrs-gui/src/lib.rs | 2 +- renrs/src/parser/block.rs | 16 +++++++--------- renrs/src/parser/command.rs | 4 ++-- renrs/src/parser/event.rs | 4 ++-- renrs/src/parser/mod.rs | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/renrs-gui/src/lib.rs b/renrs-gui/src/lib.rs index 184a44e..13d50ae 100644 --- a/renrs-gui/src/lib.rs +++ b/renrs-gui/src/lib.rs @@ -7,7 +7,7 @@ use std::{ use renrs::State; -use egui_sfml::{SfEgui, egui}; +use egui_sfml::{egui, SfEgui}; use sfml::{ graphics::{Color, RectangleShape, RenderTarget, RenderWindow, Transformable}, system::Vector2f, diff --git a/renrs/src/parser/block.rs b/renrs/src/parser/block.rs index 9d8527e..f79ffd4 100644 --- a/renrs/src/parser/block.rs +++ b/renrs/src/parser/block.rs @@ -1,11 +1,12 @@ -use std::{collections::HashMap, rc::Rc}; use debug_cell::RefCell; +use std::{collections::HashMap, rc::Rc}; use super::{ command::{parse_command, Command}, control::{parse_control, Control}, + event::Event, token::Token, - Pair, Rule, event::Event, + Pair, Rule, }; pub struct CommandBlock { @@ -35,24 +36,21 @@ impl CommandContext { if let Token::Keyword(_) = value { todo!("assignment variable interpolation isn't implemented"); } - let root = self.context - .borrow() - .get_root(&self.context); + let root = self.context.borrow().get_root(&self.context); // Don't want to re-borrow if root is self let root = if Rc::ptr_eq(&self.context, &root) { &self.context } else { &root }; - root - .borrow_mut() + root.borrow_mut() .variables .as_ref() .unwrap() .borrow_mut() .insert(variable.clone(), value.clone()); return None; - }, + } Eat { .. } => return None, } .process(&self.context), @@ -118,7 +116,7 @@ impl CommandBlock { None => HashMap::new(), } } - + pub fn get_root(&self, self_rc: &Rc>) -> Rc> { if let Some(parent) = &self.parent { parent.borrow().get_root(&parent) diff --git a/renrs/src/parser/command.rs b/renrs/src/parser/command.rs index b4a5b21..16af242 100644 --- a/renrs/src/parser/command.rs +++ b/renrs/src/parser/command.rs @@ -38,7 +38,7 @@ pub fn parse_command(pair: Pair) -> Command { variable: variable.clone(), value: value.clone(), } - }, + } [Keyword(keyword), Keyword(variable), Keyword(equals), value] if keyword.eq("$") && equals.eq("=") => { @@ -46,7 +46,7 @@ pub fn parse_command(pair: Pair) -> Command { variable: variable.clone(), value: value.clone(), } - }, + } [Keyword(keyword), Str(food), tail @ ..] if keyword.eq("eat") => Eat { food: food.to_owned(), politely: match tail { diff --git a/renrs/src/parser/event.rs b/renrs/src/parser/event.rs index fe0a402..2ed22d0 100644 --- a/renrs/src/parser/event.rs +++ b/renrs/src/parser/event.rs @@ -1,5 +1,5 @@ -use std::{collections::HashMap, rc::Rc}; use debug_cell::RefCell; +use std::{collections::HashMap, rc::Rc}; use regex::Regex; @@ -28,7 +28,7 @@ impl Event { .as_deref() .map(|name| interpolate_string(&name, &variables)); *text = interpolate_string(&text, &variables); - }, + } } self } diff --git a/renrs/src/parser/mod.rs b/renrs/src/parser/mod.rs index 9cd77d2..db8db4e 100644 --- a/renrs/src/parser/mod.rs +++ b/renrs/src/parser/mod.rs @@ -7,8 +7,8 @@ mod utils; pub type Pair<'a> = pest::iterators::Pair<'a, Rule>; -use std::{fs, path::PathBuf, rc::Rc}; use debug_cell::RefCell; +use std::{fs, path::PathBuf, rc::Rc}; pub use pest::Parser; use pest_derive::Parser;