Module utils

Source
Expand description

This module contains a simple wrapper for formatting Display objects as Debug and an extension method that can be called on strings. Mainly useful for testing.

§Example:

use ast2str::utils::{DisplayAsDebugWrapper, AstToStrExt};

assert_eq!(format!("{:?}", "foo".with_display_as_debug_wrapper()), "foo");
assert_eq!(format!("{:?}", "foo"), "\"foo\"");
assert_eq!(format!("{:?}", DisplayAsDebugWrapper("foo")), "foo");

Structs§

DisplayAsDebugWrapper
Wraps a type that implements Display and provides a Debug implementation that calls Display::fmt.

Traits§

AstToStrExt
This trait provides a convenience method for wrapping types that implement Display with DisplayAsDebugWrapper. Implemented for String, str, and Cow by default.