rust_crate_template/
lib.rs

1// This file is part of Rust Crate Template <https://github.com/Fuwn/rust-crate-template>.
2// Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, version 3.
7//
8// This program is distributed in the hope that it will be useful, but
9// WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
17// SPDX-License-Identifier: GPL-3.0-only
18
19//! # Rust Crate Template
20//!
21//! [![crates.io](https://img.shields.io/crates/v/rust-crate-template.svg)](https://crates.io/crates/rust-crate-template)
22//! [![docs.rs](https://docs.rs/rust-crate-template/badge.svg)](https://docs.rs/rust-crate-template)
23//! [![github.com](https://github.com/Fuwn/rust-crate-template/actions/workflows/check.yaml/badge.svg?branch=main)](https://github.com/Fuwn/rust-crate-template/actions/workflows/check.yaml)
24//!
25//! Rust Crate Template is a Rust crate template.
26//!
27//! ## Usage
28//!
29//! > Using this as a template? Try
30//! > `cargo generate --git https://github.com/Fuwn/rust-crate-template` with
31//! > [`cargo-generate`](https://github.com/cargo-generate/cargo-generate)!
32//!
33//! ### Add Rust Crate Template as a dependency
34//!
35//! ```toml
36//! # Cargo.toml
37//!
38//! [dependencies]
39//! rust-crate-template = "0.1.1"
40//! ```
41//!
42//! ## Examples
43//!
44//! Examples can be found within the
45//! [`examples/`](https://github.com/Fuwn/rust-crate-template/tree/main/examples) directory.
46//!
47//! ## License
48//!
49//! This project is licensed with the
50//! [GNU General Public License v3.0](https://github.com/Fuwn/rust-crate-template/blob/main/LICENSE).
51
52#![deny(
53  warnings,
54  nonstandard_style,
55  unused,
56  future_incompatible,
57  rust_2018_idioms,
58  unsafe_code,
59  clippy::all,
60  clippy::nursery,
61  clippy::pedantic
62)]
63#![recursion_limit = "128"]
64
65pub struct Adder<T> {
66  a: T,
67  b: T,
68}
69impl<T> Adder<T>
70where T: std::ops::Add<Output = T>
71{
72  pub const fn new(a: T, b: T) -> Self {
73    Self {
74      a,
75      b,
76    }
77  }
78
79  pub fn add(self) -> T { self.a + self.b }
80}