Printing for Custom Types

To use custom types for print and debug, or convert its value into a string, it is necessary that the following functions be registered (assuming the custom type is T: Display + Debug):

FunctionSignatureTypical implementationUsage
to_string|x: &mut T| -> Stringx.to_string()converts the custom type into a string
print|x: &mut T| -> Stringx.to_string()converts the custom type into a string for the print statement
to_debug|x: &mut T| -> Stringformat!("{:?}", x)converts the custom type into a string in debug format
debug|x: &mut T| -> Stringformat!("{:?}", x)converts the custom type into a string for the debug statement
+|s: &str, x: T| -> Stringformat!("{}{}", s, x)concatenates the custom type with another string
+|x: &mut T, s: &str| -> Stringx.to_string().push_str(s);concatenates another string with the custom type
+=|s: &mut ImmutableString, x: T|s += x.to_string()appends the custom type to an existing string