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 lib.rs 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! [Read More]

Rust: Add an Example Program to your Library Crate

Recently I decided that I might actually publish my little rust crate. To that end I started looking into some of the things that are needed and what can be done. I have published a perl module in the past. And as a rule for myself, I like to provide an example program that uses a module or library. That is what I will look at today.

[Read More]
rust  crate  lib