Adding feature required Tag to Rust Documentation

I had a lot of trouble understanding this. Thus I am documenting it here for myself. All credit goes to the original StackOverFlow author. Add one of the following to the root of your crate. Usually 1. #![feature(doc_cfg)]This is less than ideal as it will cause compile errors when used with stable 2. It is better to use: #![cfg_attr(docsrs, feature(doc_cfg))]This allows this to be conditionally compiled and does not give any errors. [Read More]

Display Trait

Define a display trait for a struct or enum

impl std::fmt::Display for MechanismError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            MechanismError::NotValidMechanismFormat(mesg) => {
                write!(f, "{} does not conform to any Mechanism format.", mesg)
            MechanismError::NotIP4Network(mesg) => {
                write!(f, "Was given ip4:{}. This is not an ip4 network.", mesg)
            MechanismError::NotIP6Network(mesg) => {
                write!(f, "Was given ip6:{}. This is not an ip6 network.", mesg)
            MechanismError::NotValidIPNetwork(mesg) => {
                write!(f, "{}.", mesg)
            MechanismError::NotIpNetworkMechanism => {
                write!(f, "Attempt to access TXT as IP.")
            MechanismError::NotStringMechanism => {
                write!(f, "Attempt to access IP as TXT.")


How to to_string() in Rust