Some changes
This commit is contained in:
parent
a3058961f8
commit
d3bd38ba13
|
@ -47,17 +47,15 @@ impl IntoContext for Context {
|
|||
}
|
||||
|
||||
/// Chains another piece of context that is equal from a hierarchical perspective.
|
||||
// TODO: should this inline? Would the compiler be allowed to fold the allocations into a
|
||||
// single one with inlining?
|
||||
#[inline]
|
||||
fn chain(self, other: impl IntoContext) -> Self {
|
||||
let items = match self {
|
||||
Context(ContextInner::Compound(match self {
|
||||
Context(ContextInner::Compound(mut items)) => {
|
||||
items.push(other.into_context());
|
||||
items
|
||||
}
|
||||
_ => vec![self, other.into_context()],
|
||||
};
|
||||
Context(ContextInner::Compound(items))
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,8 +74,7 @@ impl IntoContext for &'static str {
|
|||
}
|
||||
|
||||
impl IntoContext for Cow<'static, str> {
|
||||
// TODO: should this always inline?
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn into_context(self) -> Context {
|
||||
Context(ContextInner::String(self))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![doc = include_str!("../README.md")]
|
||||
#![forbid(unsafe_code)]
|
||||
#![cfg_attr(feature = "backtrace", feature(backtrace))]
|
||||
|
||||
mod sealed;
|
||||
pub(crate) use sealed::seal;
|
||||
|
|
|
@ -25,6 +25,7 @@ impl ReportOpts {
|
|||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn should_indent(&self) -> bool {
|
||||
self.was_nl
|
||||
}
|
||||
|
@ -37,6 +38,7 @@ macro_rules! report_write {
|
|||
}
|
||||
pub(crate) use report_write;
|
||||
|
||||
#[inline]
|
||||
fn write_indent(n: usize, f: &mut impl Write) -> std::fmt::Result {
|
||||
for _ in 0..n {
|
||||
f.write_str(" ")?;
|
||||
|
@ -54,6 +56,7 @@ impl<T> Report for T
|
|||
where
|
||||
T: std::fmt::Display,
|
||||
{
|
||||
#[inline(never)]
|
||||
fn fmt(&self, f: &mut impl Write, opts: &ReportOpts) -> std::fmt::Result {
|
||||
use std::fmt::Error;
|
||||
struct IndentedWrite<'a, W: Write> {
|
||||
|
@ -64,6 +67,7 @@ where
|
|||
where
|
||||
W: Write,
|
||||
{
|
||||
#[inline]
|
||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||
// TODO: any room for optimization?
|
||||
// iterates over the lines where each str ends with the line terminator.
|
||||
|
@ -84,6 +88,7 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_char(&mut self, c: char) -> Result<(), Error> {
|
||||
self.f.write_char(c)?;
|
||||
if c == '\n' {
|
||||
|
|
|
@ -8,6 +8,7 @@ pub enum TerminationResult {
|
|||
}
|
||||
|
||||
impl Termination for TerminationResult {
|
||||
#[inline]
|
||||
fn report(self) -> ExitCode {
|
||||
match self {
|
||||
Self::Ok => ExitCode::SUCCESS,
|
||||
|
@ -22,6 +23,7 @@ impl Termination for TerminationResult {
|
|||
}
|
||||
|
||||
impl From<Result<(), How>> for TerminationResult {
|
||||
#[inline]
|
||||
fn from(value: Result<(), How>) -> Self {
|
||||
match value {
|
||||
Ok(()) => Self::Ok,
|
||||
|
|
Loading…
Reference in New Issue