Skip to content

Commit

Permalink
refactor: replace static with const for global constants (#2729)
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech authored Dec 7, 2024
1 parent dded202 commit bc00064
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion components/config/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use utils::globs::build_ignore_glob_set;
use utils::slugs::slugify_paths;

// We want a default base url for tests
static DEFAULT_BASE_URL: &str = "http://a-website.com";
const DEFAULT_BASE_URL: &str = "http://a-website.com";

#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
Expand Down
2 changes: 1 addition & 1 deletion components/content/src/front_matter/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use utils::types::InsertAnchor;
use crate::front_matter::split::RawFrontMatter;
use crate::SortBy;

static DEFAULT_PAGINATE_PATH: &str = "page";
const DEFAULT_PAGINATE_PATH: &str = "page";

/// The front matter of every section
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion components/imageproc/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::format::Format;
use crate::helpers::get_processed_filename;
use crate::{fix_orientation, ImageMeta, ResizeInstructions, ResizeOperation};

pub static RESIZED_SUBDIR: &str = "processed_images";
pub const RESIZED_SUBDIR: &str = "processed_images";

/// Holds all data needed to perform a resize operation
#[derive(Debug, PartialEq, Eq, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion components/imageproc/tests/resize_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn assert_processed_path_matches(path: &str, prefix: &str, extension: &str) {
assert!(filename.ends_with(&suffix), "Path `{}` doesn't end with `{}`", path, suffix);
}

static CONFIG: &str = r#"
const CONFIG: &str = r#"
title = "imageproc integration tests"
base_url = "https://example.com"
compile_sass = false
Expand Down
2 changes: 1 addition & 1 deletion components/markdown/benches/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use libs::tera::Tera;
use markdown::{render_content, RenderContext};
use utils::types::InsertAnchor;

static CONTENT: &str = r#"
const CONTENT: &str = r#"
# Modus cognitius profanam ne duae virtutis mundi
## Ut vita
Expand Down
4 changes: 2 additions & 2 deletions components/templates/src/global_fns/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ impl ResizeImage {
}
}

static DEFAULT_OP: &str = "fill";
static DEFAULT_FMT: &str = "auto";
const DEFAULT_OP: &str = "fill";
const DEFAULT_FMT: &str = "auto";

impl TeraFn for ResizeImage {
fn call(&self, args: &HashMap<String, Value>) -> Result<Value> {
Expand Down
2 changes: 1 addition & 1 deletion components/templates/src/global_fns/load_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use utils::fs::{get_file_time, read_file};

use crate::global_fns::helpers::search_for_file;

static GET_DATA_ARGUMENT_ERROR_MESSAGE: &str =
const GET_DATA_ARGUMENT_ERROR_MESSAGE: &str =
"`load_data`: requires EITHER a `path`, `url`, or `literal` argument";

#[derive(Debug, PartialEq, Clone, Copy, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion components/utils/src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use libs::tera::{Context, Tera};

use errors::{bail, Result};

static DEFAULT_TPL: &str = include_str!("default_tpl.html");
const DEFAULT_TPL: &str = include_str!("default_tpl.html");

macro_rules! render_default_tpl {
($filename: expr, $url: expr) => {{
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ enum WatchMode {
Condition(bool),
}

static METHOD_NOT_ALLOWED_TEXT: &[u8] = b"Method Not Allowed";
static NOT_FOUND_TEXT: &[u8] = b"Not Found";
const METHOD_NOT_ALLOWED_TEXT: &[u8] = b"Method Not Allowed";
const NOT_FOUND_TEXT: &[u8] = b"Not Found";

// This is dist/livereload.min.js from the LiveReload.js v3.2.4 release
const LIVE_RELOAD: &str = include_str!("livereload.js");
Expand Down

0 comments on commit bc00064

Please sign in to comment.