new_rust_project/lib.rs
1//! This project is Erich's personal Rust starter kit for developing new libraries and binaries in
2//! Rust. You shouldn't be seeing this anywhere outside of his
3//! [`new-rust-project`](https://github.com/erichdongubler/new-rust-project) repo.
4//!
5//! ## Overview
6//!
7//! At one point, Erich got tired of accumulating lots of interesting tidbits for starting Rust
8//! projects that he knew he'd forget. So he finally hunkered down and made this repo. An example
9//! of usage:
10//!
11//! ```sh,ignore
12//! #! /bin/sh
13//!
14//! git clone --shallow https://github.com/ErichDonGubler/new-rust-project name-of-new-rust-project
15//! cd name-of-new-rust-project
16//! rm -rf .git
17//! git init
18//! git add .
19//! git commit -m "Initial commit"
20//! git remote add origin git@github.com:ErichDonGubler/name-of-new-rust-project
21//! git push -u origin master
22//! ```
23//!
24//! ## Features
25//!
26//! ### Licensing
27//!
28//! This template uses [MPL 2.0](LICENSE.md) by default. Erich's reasons for MPL by default here are:
29//!
30//! * Very permissive license in general
31//! * Patent protection for that project that suddenly takes off
32//! * Not-terribly-annoying copyleft
33//!
34//! When in doubt, remember that Erich is not a lawyer. change your own project to use what you
35//! deem appropriate.
36//!
37//! ### Contributing
38//!
39//! Contributions, feature requests, and bug reports are warmly welcomed! See the [contribution
40//! guidelines](CONTRIBUTING.md) for getting started.
41//!
42//! The [code of conduct](CODE_OF_CONDUCT.md) uses [Contributor Covenant
43//! v1.4.1](https://www.contributor-covenant.org/version/1/4/code-of-conduct). If there's a newer
44//! version of this, feel free to open a PR!
45//!
46//! ### Crate documentation in README
47//!
48//! Crate documentation is inlined into this README. This means you get doc-tests for freebies!
49//! Try it out by reading the README -- it uses `cargo-sync-readme`. Also, this is integrated into
50//! CI, so you don't forget about it!
51//!
52//! ```rust
53//! println!("This should run just fine.");
54//! ```
55//!
56//! ```rust,should_panic
57//! panic!("This should panic.");
58//! ```
59//!
60//! ```rust,compile_fail
61//! !@#$% // This should fail to compile.
62//! ```
63//!
64//! ### Intelligent defaults for docs
65//!
66//! The [Rust Playground](https://play.rust-lang.org/) is used as the playground service by
67//! default.
68//!
69//! ### `cargo-release` configuration
70//!
71//! `cargo-release` is configured to keep features of this template in sync with version releases,
72//! and has some defaults Erich considers more sensible.
73//!
74//! # CHANGELOG
75//!
76//! Yes, you should maintain a [`CHANGELOG`](CHANGELOG.md). ;)
77//!
78//! ### More aggressive linting and tests
79//!
80//! Several `rustc` and `clippy` lints have been enabled that Erich prefers. See the top of
81//! [`src/lib.rs`](src/lib.rs) for the full list.
82//!
83//! Warnings are denied in doctests and in release mode.
84//!
85//! ### Out-of-the-box CI
86//!
87//! The associated CI configuration (Travis at [`.travis.yml`](.travis.yml)) tests:
88//! * Runs tests on Linux, Windows, and MacOS.
89//! * The full set of lints with `cargo clippy`
90//! * Formatting with `cargo fmt`
91//! * The full suite of built-in tests with `cargo test`
92//!
93//! ### Buttons!
94//!
95//! There are a variety of handy buttons on the top of the README. These are meant to encourage
96//! activity both for maintainers and newcomers. Some buttons may not be suitable for, say,
97//! internal or private projects that won't actually be published on `crates.io`. You are
98//! encouraged to keep the ones you want and throw out the rest.
99
100#![cfg_attr(not(debug_assertions), deny(warnings))]
101#![doc(html_playground_url = "https://play.rust-lang.org/")]
102// UNCOMMENT_BEFORE_RELEASE: #![doc(html_root_url = "https://docs.rs/new-rust-project/0.1.2")]
103#![doc(test(attr(deny(warnings))))]
104#![doc(test(attr(warn(
105 bare_trait_objects,
106 clippy::cargo,
107 clippy::pedantic,
108 elided_lifetimes_in_paths,
109 missing_copy_implementations,
110 single_use_lifetimes,
111 unused_extern_crates,
112))))]
113#![warn(
114 bare_trait_objects,
115 clippy::cargo,
116 clippy::pedantic,
117 elided_lifetimes_in_paths,
118 missing_copy_implementations,
119 missing_docs,
120 single_use_lifetimes,
121 unused_extern_crates
122)]
123#![allow(clippy::multiple_crate_versions)]
124
125#[test]
126fn check_readme_synchronized() {
127 use {
128 cargo_sync_readme::{extract_inner_doc, read_readme, transform_readme},
129 std::path::PathBuf,
130 };
131
132 let crate_docs = extract_inner_doc(file!(), false, cfg!(windows));
133 let readme_path = PathBuf::from(file!())
134 .parent()
135 .and_then(|p| p.parent())
136 .expect("unable to create path to README dir")
137 .join("README.md");
138 let current_readme_content = read_readme(readme_path).expect("unable to read README");
139 if transform_readme(¤t_readme_content, crate_docs, cfg!(windows)).unwrap()
140 != current_readme_content
141 {
142 panic!("README is not sync'd -- make sure to run `cargo sync-readme`");
143 }
144}
145
146#[test]
147fn test_html_root_url() {
148 version_sync::assert_html_root_url_updated!(file!());
149}