Notify preprocessors of the mdbook version and add __non_exhaustive elements

This commit is contained in:
Michael Bryan 2018-09-16 14:27:37 +08:00
parent 206a00915b
commit 5dce539928
No known key found for this signature in database
GPG Key ID: E9C602B0D9A998DC
2 changed files with 12 additions and 1 deletions

View File

@ -21,12 +21,21 @@ pub struct PreprocessorContext {
pub config: Config,
/// The `Renderer` this preprocessor is being used with.
pub renderer: String,
/// The calling `mdbook` version.
pub mdbook_version: String,
__non_exhaustive: (),
}
impl PreprocessorContext {
/// Create a new `PreprocessorContext`.
pub(crate) fn new(root: PathBuf, config: Config, renderer: String) -> Self {
PreprocessorContext { root, config, renderer }
PreprocessorContext {
root,
config,
renderer,
mdbook_version: ::MDBOOK_VERSION.to_string(),
__non_exhaustive: (),
}
}
}

View File

@ -64,6 +64,7 @@ pub struct RenderContext {
/// renderers to cache intermediate results, this directory is not
/// guaranteed to be empty or even exist.
pub destination: PathBuf,
__non_exhaustive: (),
}
impl RenderContext {
@ -79,6 +80,7 @@ impl RenderContext {
version: ::MDBOOK_VERSION.to_string(),
root: root.into(),
destination: destination.into(),
__non_exhaustive: (),
}
}