Skip to content

Commit

Permalink
Fix typos (#19)
Browse files Browse the repository at this point in the history
# Objective

Improve code quality.

## Solution

Fix typos found with the `typos` utility.
  • Loading branch information
doonv authored Feb 25, 2024
1 parent 0c5e8f4 commit b7cb13c
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion examples/custom_functions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! A simple exmaple
//! A simple example

use bevy::log::{Level, LogPlugin};
use bevy::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/builtin_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use runner::error::EvalError;
pub use runner::unique_rc::*;
pub use runner::Value;

/// Additonal traits for span.
/// Additional traits for span.
pub trait SpanExtension {
/// Wrap this value with a [`Spanned`].
#[must_use]
Expand Down
4 changes: 2 additions & 2 deletions src/builtin_parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum Token {
String,

#[regex("[a-zA-Z_][a-zA-Z0-9_]*")]
Identifer,
Identifier,

#[regex(r#"[0-9]+"#)]
IntegerNumber,
Expand Down Expand Up @@ -189,7 +189,7 @@ mod tests {
fn var_assign() {
let mut lexer = TokenStream::new("x = 1 + 2 - 30.6");

assert_eq!(lexer.next(), Some(Ok(Token::Identifer)));
assert_eq!(lexer.next(), Some(Ok(Token::Identifier)));
assert_eq!(lexer.slice(), "x");

assert_eq!(lexer.next(), Some(Ok(Token::Equals)));
Expand Down
2 changes: 1 addition & 1 deletion src/builtin_parser/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Number {

/// Returns the kind of [`Number`] as a [string slice](str).
/// You may want to use [`natural_kind`](Self::natural_kind)
/// instead for more natural sounding error messsages
/// instead for more natural sounding error messages
pub const fn kind(&self) -> &'static str {
match self {
Number::Float(_) => "float",
Expand Down
10 changes: 5 additions & 5 deletions src/builtin_parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ macro_rules! expect {
};
}

/// A type that repreesnts an expression.
/// A type that represents an expression.
#[derive(Debug, Clone)]
pub enum Expression {
// Primitives
Expand Down Expand Up @@ -262,7 +262,7 @@ impl std::error::Error for ParseError {}
const FLOAT_PARSE_EXPECT_REASON: &str =
"Float parsing errors are handled by the lexer, and floats cannot overflow.";
const NUMBER_TYPE_WILDCARD_UNREACHABLE_REASON: &str =
"Lexer gurantees `NumberType`'s slice to be included one of the match arms.";
"Lexer guarantees `NumberType`'s slice to be included one of the match arms.";

pub fn parse(tokens: &mut TokenStream, environment: &Environment) -> Result<Ast, ParseError> {
let mut ast = Vec::new();
Expand Down Expand Up @@ -448,7 +448,7 @@ fn parse_value(
}
}
}
Some(Ok(Token::Identifer)) => {
Some(Ok(Token::Identifier)) => {
let start = tokens.span().start;
let name = tokens.slice().to_string();

Expand Down Expand Up @@ -581,7 +581,7 @@ fn parse_value(
while let Some(Ok(Token::Dot)) = tokens.peek() {
tokens.next(); // Skip the dot
match tokens.next() {
Some(Ok(Token::Identifer)) => {
Some(Ok(Token::Identifier)) => {
let right = tokens.slice().to_string();
expr = Spanned {
span: expr.span.start..tokens.span().end,
Expand Down Expand Up @@ -732,7 +732,7 @@ fn parse_object(
environment: &Environment,
) -> Result<HashMap<String, Spanned<Expression>>, ParseError> {
let mut map = HashMap::new();
while let Some(Ok(Token::Identifer)) = tokens.peek() {
while let Some(Ok(Token::Identifier)) = tokens.peek() {
tokens.next();
let ident = tokens.slice().to_string();
expect!(tokens, Token::Colon);
Expand Down
6 changes: 3 additions & 3 deletions src/builtin_parser/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,16 @@ fn eval_expression(
Ok(Value::Reference(weak))
}
Path::Resource(resource) => {
let registeration = registrations.create_registration(resource.id);
let mut dyn_reflect = resource.mut_dyn_reflect(world, registeration);
let registration = registrations.create_registration(resource.id);
let mut dyn_reflect = resource.mut_dyn_reflect(world, registration);

let reflect = dyn_reflect
.reflect_path_mut(resource.path.as_str())
.unwrap();

match reflect.reflect_mut() {
ReflectMut::Enum(dyn_enum) => {
let TypeInfo::Enum(enum_info) = registeration.type_info() else {
let TypeInfo::Enum(enum_info) = registration.type_info() else {
unreachable!()
};
let Spanned { span, value } = *value_expr;
Expand Down
2 changes: 1 addition & 1 deletion src/builtin_parser/runner/environment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Environment and function registeration
//! Environment and function registration

use std::collections::HashMap;
use std::fmt::Debug;
Expand Down
4 changes: 2 additions & 2 deletions src/builtin_parser/runner/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::command::{CommandHint, CommandHintColor};

use super::Value;

/// An error occuring during the while executing the [`AST`](Ast) of the command.
/// An error occurring during the while executing the [`AST`](Ast) of the command.
#[derive(Debug)]
#[allow(missing_docs)]
pub enum EvalError {
Expand Down Expand Up @@ -186,7 +186,7 @@ impl std::fmt::Display for EvalError {
expected, actual, ..
} => write!(
f,
"Mismatched function paramater type. Expected {expected} but got {actual}"
"Mismatched function parameter type. Expected {expected} but got {actual}"
),
E::ExpectedVariableGotFunction(Spanned { value, .. }) => write!(
f,
Expand Down
2 changes: 1 addition & 1 deletion src/builtin_parser/runner/unique_rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<T: ?Sized> UniqueRc<T> {
/// # Safety
///
/// This function is unsafe because it allows direct access to the [`Rc`].
/// If cloned then the gurantee that there is only ever one strong reference is no longer satisfied.
/// If cloned then the guarantee that there is only ever one strong reference is no longer satisfied.
const unsafe fn get_rc(&self) -> &Rc<RefCell<T>> {
&self.0
}
Expand Down
20 changes: 10 additions & 10 deletions src/builtin_parser/runner/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Value {

/// Returns the kind of [`Value`] as a [string slice](str).
/// You may want to use [`natural_kind`](Self::natural_kind)
/// instead for more natural sounding error messsages
/// instead for more natural sounding error messages
pub const fn kind(&self) -> &'static str {
match self {
Value::None => "none",
Expand Down Expand Up @@ -248,7 +248,7 @@ fn fancy_debug_print(
fn debug_subprint(reflect: &dyn Reflect, indentation: usize) -> String {
let mut f = String::new();
let reflect_ref = reflect.reflect_ref();
let identation_string = TAB.repeat(indentation);
let indentation_string = TAB.repeat(indentation);
match reflect_ref {
ReflectRef::Struct(struct_info) => {
f += "{\n";
Expand All @@ -258,21 +258,21 @@ fn fancy_debug_print(

let field_value = debug_subprint(field, indentation + 1);
f += &format!(
"{identation_string}{TAB}{field_name}: {} = {field_value},\n",
"{indentation_string}{TAB}{field_name}: {} = {field_value},\n",
field.reflect_short_type_path(),
);
}
f += &identation_string;
f += &indentation_string;
f += "}";
}
ReflectRef::TupleStruct(_) => todo!(),
ReflectRef::Tuple(tuple_info) => {
f += "(\n";
for field in tuple_info.iter_fields() {
let field_value = debug_subprint(field, indentation + 1);
f += &format!("{identation_string}{TAB}{field_value},\n",);
f += &format!("{indentation_string}{TAB}{field_value},\n",);
}
f += &identation_string;
f += &indentation_string;
f += ")";
}
ReflectRef::List(_) => todo!(),
Expand All @@ -287,25 +287,25 @@ fn fancy_debug_print(
f += " {\n";
for field in variant.iter_fields() {
f += &format!(
"{identation_string}{TAB}{}: {} = {},\n",
"{indentation_string}{TAB}{}: {} = {},\n",
field.name().unwrap(),
field.value().reflect_short_type_path(),
debug_subprint(field.value(), indentation + 1)
);
}
f += &identation_string;
f += &indentation_string;
f += "}";
}
VariantType::Tuple => {
f += "(\n";
for field in variant.iter_fields() {
f += &format!(
"{identation_string}{TAB}{} = {},\n",
"{indentation_string}{TAB}{} = {},\n",
field.value().reflect_short_type_path(),
debug_subprint(field.value(), indentation + 1)
);
}
f += &identation_string;
f += &indentation_string;
f += ")";
}
VariantType::Unit => {}
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ops::Range;
use bevy::ecs::system::Command;
use bevy::prelude::*;

/// The command parser currrently being used by the dev console.
/// The command parser currently being used by the dev console.
#[derive(Resource)]
pub struct DefaultCommandParser(pub Box<dyn CommandParser>);

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl ConsoleTheme {
debug: Color::rgb(0.29, 0.65, 0.94),
trace: Color::rgb(0.78, 0.45, 0.89),
};
/// High constrast theme, might help some people.
/// High contrast theme, might help some people.
pub const HIGH_CONTRAST: Self = Self {
font: FontId::monospace(14.0),
dark: Color::rgb(0.5, 0.5, 0.5),
Expand Down
10 changes: 5 additions & 5 deletions src/logging/log_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ impl Plugin for ConsoleLogPlugin {
}));
}

let (sender, reciever) = mpsc::channel::<LogMessage>();
let (sender, receiver) = mpsc::channel::<LogMessage>();

let finished_subscriber;
let default_filter = { format!("{},{}", self.level, self.filter) };
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new(&default_filter))
.unwrap();

let log_events = CapturedLogEvents(reciever);
let log_events = CapturedLogEvents(receiver);

let log_event_handler = LogCaptureLayer { sender };

Expand Down Expand Up @@ -251,10 +251,10 @@ pub struct LogMessage {

/// Transfers information from the [`CapturedLogEvents`] resource to [`Events<LogMessage>`](LogMessage).
fn transfer_log_events(
reciever: NonSend<CapturedLogEvents>,
receiver: NonSend<CapturedLogEvents>,
mut log_events: EventWriter<LogMessage>,
) {
log_events.send_batch(reciever.0.try_iter());
log_events.send_batch(receiver.0.try_iter());
}

/// This struct temporarily stores [`LogMessage`]s before they are
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<S: Subscriber> Layer<S> for LogCaptureLayer {
}
}

/// A [`Visit`]or that records log messages that are transfered to [`LogCaptureLayer`].
/// A [`Visit`]or that records log messages that are transferred to [`LogCaptureLayer`].
struct LogEventVisitor<'a>(&'a mut Option<String>);
impl Visit for LogEventVisitor<'_> {
fn record_debug(
Expand Down
4 changes: 2 additions & 2 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub const COMMAND_RESULT_NAME: &str = "console_result";

#[derive(Default, Resource)]
pub(crate) struct ConsoleUiState {
/// Whever the console is open or not.
/// Wherever the console is open or not.
pub(crate) open: bool,
/// A list of all log messages receieved plus an
/// A list of all log messages received plus an
/// indicator indicating if the message is new.
pub(crate) log: Vec<(LogMessage, bool)>,
/// The command in the text bar.
Expand Down

0 comments on commit b7cb13c

Please sign in to comment.