implemented for loops

This commit is contained in:
2025-04-20 05:16:50 -04:00
parent b6be68b235
commit 4d16ffa60f
27 changed files with 360 additions and 174 deletions

View File

@@ -114,7 +114,6 @@ impl ShErr {
}
pub fn with_span(sherr: ShErr, span: Span) -> Self {
let (kind,msg,notes,_) = sherr.unpack();
let span = span.into();
Self::Full { kind, msg, notes, span }
}
pub fn kind(&self) -> &ShErrKind {
@@ -300,19 +299,19 @@ impl From<std::io::Error> for ShErr {
impl From<std::env::VarError> for ShErr {
fn from(value: std::env::VarError) -> Self {
ShErr::simple(ShErrKind::InternalErr, &value.to_string())
ShErr::simple(ShErrKind::InternalErr, value.to_string())
}
}
impl From<rustyline::error::ReadlineError> for ShErr {
fn from(value: rustyline::error::ReadlineError) -> Self {
ShErr::simple(ShErrKind::ParseErr, &value.to_string())
ShErr::simple(ShErrKind::ParseErr, value.to_string())
}
}
impl From<Errno> for ShErr {
fn from(value: Errno) -> Self {
ShErr::simple(ShErrKind::Errno, &value.to_string())
ShErr::simple(ShErrKind::Errno, value.to_string())
}
}

View File

@@ -35,6 +35,10 @@ pub fn save_termios() {
}
}
#[allow(static_mut_refs)]
///Access the saved termios
///
///# Safety
///This function is unsafe because it accesses a public mutable static value. This function should only ever be called after save_termios() has already been called.
pub unsafe fn get_saved_termios() -> Option<Termios> {
// SAVED_TERMIOS should *only ever* be set once and accessed once
// Set at the start of the program, and accessed during the exit of the program to reset the termios.

View File

@@ -127,7 +127,7 @@ impl StyleSet {
Self { styles: vec![] }
}
pub fn add(mut self, style: Style) -> Self {
pub fn add_style(mut self, style: Style) -> Self {
if !self.styles.contains(&style) {
self.styles.push(style);
}
@@ -149,7 +149,7 @@ impl BitOr for Style {
type Output = StyleSet;
fn bitor(self, rhs: Self) -> Self::Output {
StyleSet::new().add(self).add(rhs)
StyleSet::new().add_style(self).add_style(rhs)
}
}
@@ -158,12 +158,12 @@ impl BitOr<Style> for StyleSet {
type Output = StyleSet;
fn bitor(self, rhs: Style) -> Self::Output {
self.add(rhs)
self.add_style(rhs)
}
}
impl From<Style> for StyleSet {
fn from(style: Style) -> Self {
StyleSet::new().add(style)
StyleSet::new().add_style(style)
}
}

View File

@@ -71,16 +71,12 @@ impl CharDequeUtils for VecDeque<char> {
impl TkVecUtils<Tk> for Vec<Tk> {
fn get_span(&self) -> Option<Span> {
if let Some(first_tk) = self.first() {
if let Some(last_tk) = self.last() {
Some(
Span::new(
first_tk.span.start..last_tk.span.end,
first_tk.source()
)
self.last().map(|last_tk| {
Span::new(
first_tk.span.start..last_tk.span.end,
first_tk.source()
)
} else {
None
}
})
} else {
None
}