run cargo fmt

This commit is contained in:
Skgland
2023-08-26 01:29:53 +02:00
committed by Bennet Bleßmann
parent 5585e83fd6
commit b2130c2a48
50 changed files with 10821 additions and 9258 deletions

View File

@@ -1,9 +1,9 @@
use indexmap::IndexSet;
use rustyline::completion::{Completer, Candidate};
use rustyline::completion::{Candidate, Completer};
use rustyline::highlight::{Highlighter, MatchingBracketHighlighter};
use rustyline::hint::Hinter;
use rustyline::validate::Validator;
use rustyline::highlight::{MatchingBracketHighlighter, Highlighter};
use rustyline::{Helper as RlHelper, Result, Context};
use rustyline::{Context, Helper as RlHelper, Result};
use crate::atom_table::{Atom, STATIC_ATOMS_MAP};
@@ -43,7 +43,7 @@ fn get_prefix(line: &str, pos: usize) -> Option<usize> {
}
if i == pos {
break
break;
}
}
@@ -58,27 +58,29 @@ pub struct StrPtr(*const str);
impl Candidate for StrPtr {
fn display(&self) -> &str {
unsafe {
self.0.as_ref().unwrap()
}
unsafe { self.0.as_ref().unwrap() }
}
fn replacement(&self) -> &str {
unsafe {
self.0.as_ref().unwrap()
}
unsafe { self.0.as_ref().unwrap() }
}
}
impl Completer for Helper {
type Candidate = StrPtr;
fn complete(&self, line: &str, pos: usize, _ctx: &Context<'_>) -> Result<(usize, Vec<Self::Candidate>)> {
fn complete(
&self,
line: &str,
pos: usize,
_ctx: &Context<'_>,
) -> Result<(usize, Vec<Self::Candidate>)> {
let start_of_prefix = get_prefix(line, pos);
if let Some(idx) = start_of_prefix {
let sub_str = line.get(idx..pos).unwrap();
Ok((idx, unsafe {
let mut matching = (*self.atoms).iter()
let mut matching = (*self.atoms)
.iter()
.chain(STATIC_ATOMS_MAP.values())
.filter(|a| a.as_str().starts_with(sub_str))
.map(|s| StrPtr(s.as_str()))