Skip to content

Commit

Permalink
refactor: add non_exhaustive to all pub items with pub members
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Jun 16, 2024
1 parent 5513cfa commit 598dbd1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use walkdir::Error as WalkdirError;
use rhai::{EvalAltResult, ParseError};

/// Error when rendering data on template.
#[non_exhaustive]
#[derive(Debug)]
pub struct RenderError {
pub template_name: Option<String>,
Expand Down Expand Up @@ -60,6 +61,7 @@ impl From<TemplateError> for RenderError {
}

/// Template rendering error
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum RenderErrorReason {
#[error("Template not found {0}")]
Expand Down Expand Up @@ -192,6 +194,7 @@ impl StdError for RenderError {
}

/// Template parsing error
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum TemplateErrorReason {
#[error("helper {0:?} was opened, but {1:?} is closing")]
Expand Down Expand Up @@ -329,6 +332,7 @@ impl fmt::Display for TemplateError {
}

#[cfg(feature = "script_helper")]
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum ScriptError {
#[error(transparent)]
Expand Down
6 changes: 0 additions & 6 deletions src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ pub(crate) mod scripting;
#[cfg(feature = "string_helpers")]
pub(crate) mod string_helpers;

// pub type HelperDef = for <'a, 'b, 'c> Fn<(&'a Context, &'b Helper, &'b Registry, &'c mut RenderContext), Result<String, RenderError>>;
//
// pub fn helper_dummy (ctx: &Context, h: &Helper, r: &Registry, rc: &mut RenderContext) -> Result<String, RenderError> {
// h.template().unwrap().render(ctx, r, rc).unwrap()
// }
//
#[cfg(test)]
mod test {
use std::collections::BTreeMap;
Expand Down
1 change: 1 addition & 0 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn rhai_engine() -> Engine {
}

/// Options for importing template files from a directory.
#[non_exhaustive]
#[cfg(feature = "dir_source")]
pub struct DirectorySourceOptions {
/// The name extension for template files
Expand Down
9 changes: 9 additions & 0 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ use crate::support;

use self::TemplateElement::*;

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct TemplateMapping(pub usize, pub usize);

/// A handlebars template
#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug, Default)]
pub struct Template {
pub name: Option<String>,
Expand All @@ -40,6 +42,7 @@ impl TemplateOptions {
}
}

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Subexpression {
// we use box here avoid resursive struct definition
Expand Down Expand Up @@ -100,12 +103,14 @@ impl Subexpression {
}
}

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum BlockParam {
Single(Parameter),
Pair((Parameter, Parameter)),
}

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ExpressionSpec {
pub name: Parameter,
Expand All @@ -116,6 +121,7 @@ pub struct ExpressionSpec {
pub omit_pro_ws: bool,
}

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum Parameter {
// for helper name only
Expand All @@ -126,6 +132,7 @@ pub enum Parameter {
Subexpression(Subexpression),
}

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct HelperTemplate {
pub name: Parameter,
Expand Down Expand Up @@ -259,6 +266,7 @@ impl HelperTemplate {
}
}

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct DecoratorTemplate {
pub name: Parameter,
Expand Down Expand Up @@ -1024,6 +1032,7 @@ impl Template {
}
}

#[non_exhaustive]
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum TemplateElement {
Indent,
Expand Down

0 comments on commit 598dbd1

Please sign in to comment.