fmt + clippy

This commit is contained in:
Erin 2022-09-14 21:46:24 +02:00 committed by ondra05
parent 417a9ac8fd
commit d9e6dc4e36
4 changed files with 11 additions and 9 deletions

View file

@ -168,7 +168,7 @@ pub enum Expr {
Variable(String), Variable(String),
} }
#[derive(Debug, PartialEq, Clone, Hash)] #[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub enum Literal { pub enum Literal {
Char(char), Char(char),
Int(isize), Int(isize),
@ -185,7 +185,7 @@ impl From<Literal> for Value {
} }
} }
#[derive(Debug, PartialEq, Clone, Hash)] #[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub enum BinOpKind { pub enum BinOpKind {
Add, Add,
Subtract, Subtract,

View file

@ -1,6 +1,6 @@
use logos::{Lexer, Logos}; use logos::{Lexer, Logos};
#[derive(Logos, Debug, PartialEq, Clone)] #[derive(Logos, Debug, PartialEq, Eq, Clone)]
pub enum Token { pub enum Token {
// Symbols // Symbols
#[token("(")] #[token("(")]
@ -104,7 +104,7 @@ pub enum Token {
/// Run at the end of the program /// Run at the end of the program
#[token("finally")] #[token("finally")]
Finally, Finally,
/// Crash with random error (see discussion #17) /// Crash with random error (see discussion #17)
#[token("rlyeh")] #[token("rlyeh")]
Rlyeh, Rlyeh,

View file

@ -2,6 +2,8 @@ use super::ValueRef;
use crate::ast::Block; use crate::ast::Block;
use std::{hash::Hash, rc::Rc}; use std::{hash::Hash, rc::Rc};
type BuiltinRc = Rc<dyn Fn(&[ValueRef]) -> Result<(), crate::error::ErrorKind>>;
/// AbleScript Function /// AbleScript Function
#[derive(Debug, PartialEq, Clone, Hash)] #[derive(Debug, PartialEq, Clone, Hash)]
pub enum Functio { pub enum Functio {
@ -49,13 +51,13 @@ impl Functio {
/// Built-in Rust functio /// Built-in Rust functio
#[derive(Clone)] #[derive(Clone)]
pub struct BuiltinFunctio { pub struct BuiltinFunctio {
pub(super) function: Rc<dyn Fn(&[ValueRef]) -> Result<(), crate::error::ErrorKind>>, pub(super) function: BuiltinRc,
pub(super) arity: usize, pub(super) arity: usize,
} }
impl BuiltinFunctio { impl BuiltinFunctio {
/// Wrap a Rust function into AbleScript's built-in functio /// Wrap a Rust function into AbleScript's built-in functio
/// ///
/// Arity used for functio chaining, recommend value for variadic /// Arity used for functio chaining, recommend value for variadic
/// functions is the accepted minimum. /// functions is the accepted minimum.
pub fn new<F>(f: F, arity: usize) -> Self pub fn new<F>(f: F, arity: usize) -> Self
@ -100,7 +102,7 @@ impl Hash for BuiltinFunctio {
} }
/// A method of distributting parameters across functio chain /// A method of distributting parameters across functio chain
#[derive(Debug, PartialEq, Copy, Clone, Hash)] #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)]
pub enum FunctioChainKind { pub enum FunctioChainKind {
/// All parameters are equally distributed /// All parameters are equally distributed
Equal, Equal,

View file

@ -58,7 +58,7 @@ impl Value {
} }
/// Three-state logic value /// Three-state logic value
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd)]
pub enum Abool { pub enum Abool {
Never = -1, Never = -1,
Sometimes = 0, Sometimes = 0,
@ -163,7 +163,7 @@ impl Display for Value {
} }
/// Runtime borrow-checked, counted reference to a [Value] /// Runtime borrow-checked, counted reference to a [Value]
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct ValueRef(Rc<RefCell<Value>>); pub struct ValueRef(Rc<RefCell<Value>>);
impl ValueRef { impl ValueRef {