#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MethodDecorator {
pub name: String,
pub description: String,
}
impl MethodDecorator {
#[must_use]
pub fn new(name: &str, description: &str) -> Self {
Self {
name: name.to_string(),
description: description.to_string(),
}
}
}
#[cfg(test)]
mod tests {
use super::MethodDecorator;
#[test]
fn new_method_decorator_stores_fields() {
let decorator = MethodDecorator::new(
"login_required",
"Marks methods that require authentication.",
);
assert_eq!(decorator.name, "login_required");
assert_eq!(
decorator.description,
"Marks methods that require authentication."
);
}
#[test]
fn method_decorator_derives_clone_and_equality() {
let original = MethodDecorator::new("csrf_exempt", "Documents a CSRF exemption marker.");
let cloned = original.clone();
assert_eq!(original, cloned);
}
}