Skip to content

Commit

Permalink
add azure pipeline, mergify, rustfmt, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmocatta committed Jul 20, 2019
1 parent 0bca76d commit 77c993f
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hard_tabs = true
imports_layout = "Horizontal"
merge_imports = true
fn_args_layout = "Compressed"
use_field_init_shorthand = true

# To enable when stable
# wrap_comments = true # https://github.com/rust-lang/rustfmt/issues/3347
# reorder_impl_items = true # https://github.com/rust-lang/rustfmt/issues/3363
16 changes: 14 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
[package]
name = "template"
name = "template-rust"
version = "0.1.0"
license = "MIT OR Apache-2.0"
authors = ["Alec Mocatta <alec@mocatta.net>"]
categories = []
keywords = []
description = """
A template Rust library crate.
"""
repository = "https://github.com/alecmocatta/template-rust"
homepage = "https://github.com/alecmocatta/template-rust"
documentation = "https://docs.rs/template-rust/0.1.0"
readme = "README.md"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[badges]
azure-devops = { project = "alecmocatta/template-rust", pipeline = "tests" }
maintenance = { status = "passively-maintained" }

[dependencies]
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# template-rust

[![Crates.io](https://img.shields.io/crates/v/template-rust.svg?maxAge=86400)](https://crates.io/crates/template-rust)
[![MIT / Apache 2.0 licensed](https://img.shields.io/crates/l/template-rust.svg?maxAge=2592000)](#License)
[![Build Status](https://dev.azure.com/alecmocatta/template-rust/_apis/build/status/tests?branchName=master)](https://dev.azure.com/alecmocatta/template-rust/_build/latest?definitionId=1&branchName=master)

[Docs](https://docs.rs/template-rust/0.1.0)

A template Rust library crate.

This is template for Rust libraries, comprising a [`hello_world()`](https://docs.rs/template-rust/0.1.0/template_rust/fn.hello_world.html) function.

## Example

```rust
use template_rust::hello_world;

hello_world();
```

## Note

Caveat emptor.

## License
Licensed under either of

* Apache License, Version 2.0, ([LICENSE-APACHE.txt](LICENSE-APACHE.txt) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT.txt](LICENSE-MIT.txt) or http://opensource.org/licenses/MIT)

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
31 changes: 31 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
trigger: ["master"]
pr: ["master"]

resources:
repositories:
- repository: templates
type: github
name: alecmocatta/azure-pipeline-templates
endpoint: alecmocatta

jobs:
- template: rust.yml@templates
parameters:
default:
rust_toolchain: stable nightly
rust_lint_toolchain: nightly-2019-07-19
rust_flags: ''
rust_features: ''
rust_target_check: ''
rust_target_build: ''
rust_target_run: ''
matrix:
windows:
imageName: 'vs2017-win2016'
rust_target_run: 'x86_64-pc-windows-msvc x86_64-pc-windows-gnu i686-pc-windows-msvc i686-pc-windows-gnu'
mac:
imageName: 'macos-10.13'
rust_target_run: 'x86_64-apple-darwin i686-apple-darwin'
linux:
imageName: 'ubuntu-16.04'
rust_target_run: 'x86_64-unknown-linux-gnu i686-unknown-linux-gnu x86_64-unknown-linux-musl i686-unknown-linux-musl'
61 changes: 57 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
//! A template Rust library crate.
//!
//! **[Crates.io](https://crates.io/crates/template-rust) │ [Repo](https://github.com/alecmocatta/template-rust)**
//!
//! This is template for Rust libraries, comprising a [`hello_world()`] function.
//!
//! # Example
//!
//! ```
//! use template_rust::hello_world;
//!
//! hello_world();
//! // prints: Hello, world!
//! ```
//!
//! # Note
//!
//! Caveat emptor.
#![doc(html_root_url = "https://docs.rs/template-rust/0.1.0")]
#![warn(
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
trivial_casts,
trivial_numeric_casts,
unused_import_braces,
unused_qualifications,
unused_results,
clippy::pedantic
)] // from https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md
#![allow()]

/// Print "Hello, world!".
///
/// # Example
///
/// ```
/// use template_rust::hello_world;
///
/// hello_world();
/// // prints: Hello, world!
/// ```
///
/// # Panics
///
/// Will panic if printing fails.
pub fn hello_world() {
print!("Hello, world!");
}

#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
use super::hello_world;

#[test]
fn succeeds() {
hello_world();
}
}

0 comments on commit 77c993f

Please sign in to comment.