Function insta::dynamic_redaction

source ·
pub fn dynamic_redaction<I, F>(func: F) -> Redactionwhere
    I: Into<Content>,
    F: Fn(Content, ContentPath<'_>) -> I + Send + Sync + 'static,
Available on crate feature redactions only.
Expand description

Creates a dynamic redaction.

This can be used to redact a value with a different value but instead of statically declaring it a dynamic value can be computed. This can also be used to perform assertions before replacing the value.

The closure is passed two arguments: the value as Content and the path that was selected (as ContentPath)


settings.add_redaction(".id", dynamic_redaction(|value, path| {
    assert_eq!(path.to_string(), ".id");
            .filter(|&c| c == '-')