yanais/crates/yn-qgy4hbz-core/src/lib.rs

81 lines
1.7 KiB
Rust
Raw Normal View History

/*
* SPDX-FileCopyrightText: 2023 Alain Zscheile <fogti+devel@ytrizja.de>
*
* SPDX-License-Identifier: Apache-2.0
*/
2023-09-24 21:58:28 +00:00
//use bitflags::bitflags;
pub mod parser;
2023-09-26 12:20:35 +00:00
mod expr;
2023-10-01 13:08:29 +00:00
pub use expr::{Expr, RpLit, TyLit, ReprOpaque};
2023-09-24 21:58:28 +00:00
2023-09-26 09:40:05 +00:00
mod pat;
pub use pat::{FullPattern, Pattern};
2023-09-26 12:12:43 +00:00
mod record;
pub use record::{Record, RecordEntry};
2023-09-26 09:45:07 +00:00
pub mod typeck;
2023-09-25 20:26:15 +00:00
2023-09-26 13:27:43 +00:00
use core::{cmp, fmt};
2023-09-25 20:26:15 +00:00
use miette::SourceSpan;
2023-09-25 21:27:58 +00:00
/// A SourceSpan which is always equal to all other SourceSpans
/// (to be used to ignore span differences in expression comparisons)
2023-09-26 13:27:43 +00:00
#[derive(Clone, Copy)]
pub struct EvEqSourceSpan(pub SourceSpan);
impl cmp::PartialEq for EvEqSourceSpan {
#[inline(always)]
fn eq(&self, _: &Self) -> bool {
true
}
}
2023-09-26 13:27:43 +00:00
impl fmt::Display for EvEqSourceSpan {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}..+{}", self.0.offset(), self.0.len())
}
}
impl fmt::Debug for EvEqSourceSpan {
#[inline(always)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
<Self as fmt::Display>::fmt(self, f)
}
}
impl From<(usize, usize)> for EvEqSourceSpan {
#[inline]
fn from(x: (usize, usize)) -> Self {
Self(x.into())
}
}
impl From<core::ops::Range<usize>> for EvEqSourceSpan {
#[inline]
fn from(x: core::ops::Range<usize>) -> Self {
Self(x.into())
}
2023-09-24 21:58:28 +00:00
}
impl From<EvEqSourceSpan> for SourceSpan {
#[inline(always)]
fn from(x: EvEqSourceSpan) -> SourceSpan {
x.0
2023-09-25 20:26:15 +00:00
}
}
impl<'a> From<&'a EvEqSourceSpan> for SourceSpan {
#[inline(always)]
fn from(x: &'a EvEqSourceSpan) -> SourceSpan {
x.0
2023-09-25 20:26:15 +00:00
}
}
2023-09-26 12:17:24 +00:00
pub trait Subst {
fn incr_refs(&mut self, keep: usize, offset: usize);
fn subst(&mut self, bnest: usize, with_e: &Expr);
}