This sample post exists to verify that Markdown code fences are rendered with server-side syntax highlighting.

The Rust block below uses lifetimes, pattern matching, and Result propagation.

use thiserror::Error;

#[derive(Debug, Clone, PartialEq)]
pub struct BlogSlug(String);

#[derive(Debug, Error, PartialEq)]
pub enum SlugError {
    #[error("slug cannot be empty")]
    Empty,
    #[error("slug contains invalid characters")]
    InvalidCharacters,
}

impl BlogSlug {
    pub fn parse(value: &str) -> Result<Self, SlugError> {
        let trimmed = value.trim();
        if trimmed.is_empty() {
            return Err(SlugError::Empty);
        }

        let valid = trimmed
            .bytes()
            .all(|byte| byte.is_ascii_lowercase() || byte.is_ascii_digit() || byte == b'-');

        if !valid {
            return Err(SlugError::InvalidCharacters);
        }

        Ok(Self(trimmed.to_owned()))
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

Here is a small TypeScript example for contrast.

type SocialPostDraft = {
  headline: string;
  firstParagraph: string;
  canonicalUrl: string;
};

export function formatSocialPost(post: SocialPostDraft): string {
  return `${post.headline}

${post.firstParagraph}

Read full: ${post.canonicalUrl}`;
}

And a shell example.

cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo test