fmt + clippy

trunk
ondra05 2022-09-14 21:46:24 +02:00
parent c4fda0c0ec
commit 1bb33066ed
4 changed files with 11 additions and 9 deletions

View File

@ -168,7 +168,7 @@ pub enum Expr {
Variable(String),
}
#[derive(Debug, PartialEq, Clone, Hash)]
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub enum Literal {
Char(char),
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 {
Add,
Subtract,

View File

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

View File

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

View File

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