├── .editorconfig ├── .github ├── FUNDING.yml └── workflows │ └── ci.yml ├── .gitignore ├── .prettierrc.yml ├── .vscode └── settings.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE.md ├── README.md ├── rustfmt.toml └── src └── main.rs /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # All files 7 | [*] 8 | charset = utf-8 9 | end_of_line = lf 10 | indent_size = 4 11 | indent_style = space 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | 15 | [*.yml] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: "https://3cities.xyz/#/pay?c=CAESFAKY9DMuOFdjE4Wzl2YyUFipPiSfIgICATICCAJaFURvbmF0aW9uIHRvIFBhdWwgQmVyZw" 2 | github: "PaulRBerg" 3 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: "CI" 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | push: 7 | branches: ["main"] 8 | 9 | jobs: 10 | check: 11 | name: "Check" 12 | runs-on: "ubuntu-latest" 13 | steps: 14 | - uses: "actions/checkout@v4" 15 | - uses: "dtolnay/rust-toolchain@stable" 16 | - run: "cargo check" 17 | 18 | test: 19 | name: "Test Suite" 20 | runs-on: "ubuntu-latest" 21 | steps: 22 | - uses: "actions/checkout@v4" 23 | - uses: "dtolnay/rust-toolchain@stable" 24 | - run: "cargo test" 25 | 26 | fmt: 27 | name: "Rustfmt" 28 | runs-on: "ubuntu-latest" 29 | steps: 30 | - uses: "actions/checkout@v4" 31 | - uses: "dtolnay/rust-toolchain@nightly" 32 | with: 33 | components: "rustfmt" 34 | - run: "cargo +nightly fmt --all -- --check" 35 | 36 | clippy: 37 | name: "Clippy" 38 | runs-on: "ubuntu-latest" 39 | steps: 40 | - uses: "actions/checkout@v4" 41 | - uses: "dtolnay/rust-toolchain@nightly" 42 | with: 43 | components: "clippy" 44 | - run: "cargo clippy -- -D warnings" 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # directories 2 | target/ 3 | 4 | # files 5 | **/*.rs.bk 6 | -------------------------------------------------------------------------------- /.prettierrc.yml: -------------------------------------------------------------------------------- 1 | printWidth: 120 2 | trailingComma: "all" 3 | overrides: 4 | - files: "*.md" 5 | options: 6 | proseWrap: "always" 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[toml]": { 3 | "editor.defaultFormatter": "tamasfe.even-better-toml" 4 | }, 5 | "editor.formatOnSave": true, 6 | "rust-analyzer.check.command": "clippy", 7 | "rust-analyzer.checkOnSave": true, 8 | "rust-analyzer.inlayHints.chainingHints.enable": true, 9 | "rust-analyzer.inlayHints.parameterHints.enable": true, 10 | "rust-analyzer.inlayHints.typeHints.enable": true, 11 | "rust-analyzer.rustfmt.extraArgs": ["+nightly"] 12 | } 13 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "itoa" 7 | version = "1.0.9" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" 10 | 11 | [[package]] 12 | name = "proc-macro2" 13 | version = "1.0.70" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" 16 | dependencies = [ 17 | "unicode-ident", 18 | ] 19 | 20 | [[package]] 21 | name = "quote" 22 | version = "1.0.33" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 25 | dependencies = [ 26 | "proc-macro2", 27 | ] 28 | 29 | [[package]] 30 | name = "rust-template" 31 | version = "0.1.0" 32 | dependencies = [ 33 | "serde", 34 | "serde_json", 35 | ] 36 | 37 | [[package]] 38 | name = "ryu" 39 | version = "1.0.15" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" 42 | 43 | [[package]] 44 | name = "serde" 45 | version = "1.0.193" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" 48 | dependencies = [ 49 | "serde_derive", 50 | ] 51 | 52 | [[package]] 53 | name = "serde_derive" 54 | version = "1.0.193" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" 57 | dependencies = [ 58 | "proc-macro2", 59 | "quote", 60 | "syn", 61 | ] 62 | 63 | [[package]] 64 | name = "serde_json" 65 | version = "1.0.108" 66 | source = "registry+https://github.com/rust-lang/crates.io-index" 67 | checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" 68 | dependencies = [ 69 | "itoa", 70 | "ryu", 71 | "serde", 72 | ] 73 | 74 | [[package]] 75 | name = "syn" 76 | version = "2.0.39" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" 79 | dependencies = [ 80 | "proc-macro2", 81 | "quote", 82 | "unicode-ident", 83 | ] 84 | 85 | [[package]] 86 | name = "unicode-ident" 87 | version = "1.0.12" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 90 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 2 | 3 | [package] 4 | authors = ["Paul Razvan Berg"] 5 | description = "A template for developing Rust projects, with sensible defaults" 6 | edition = "2021" 7 | homepage = "https://github.com/PaulRBerg/rust-template" 8 | license = "MIT" 9 | name = "rust-template" 10 | version = "0.1.0" 11 | 12 | [dependencies] 13 | 14 | # The core APIs, including the Serialize and Deserialize traits. Always 15 | # required when using Serde. The "derive" feature is only required when 16 | # using #[derive(Serialize, Deserialize)] to make Serde work with structs 17 | # and enums defined in your crate. 18 | serde = { version = "1.0", features = ["derive"] } 19 | 20 | # Each data format lives in its own crate; the sample code below uses JSON 21 | # but you may be using a different one. 22 | serde_json = "1.0" 23 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Paul Razvan Berg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust Template [![Github Actions][gha-badge]][gha] [![License: MIT][license-badge]][license] 2 | 3 | [gha]: https://github.com/PaulRBerg/rust-template/actions 4 | [gha-badge]: https://github.com/PaulRBerg/rust-template/actions/workflows/ci.yml/badge.svg 5 | [license]: https://opensource.org/licenses/MIT 6 | [license-badge]: https://img.shields.io/badge/License-MIT-blue.svg 7 | 8 | A template for developing Rust projects, with sensible defaults. 9 | 10 | ## Getting Started 11 | 12 | Click the [`Use this template`](https://github.com/PaulRBerg/rust-template/generate) button at the top of the page to 13 | create a new repository with this repo as the initial state. 14 | 15 | ## Features 16 | 17 | ### Sensible Defaults 18 | 19 | This template comes with sensible default configurations in the following files: 20 | 21 | ```text 22 | ├── .editorconfig 23 | ├── .gitignore 24 | ├── .prettierrc.yml 25 | ├── Cargo.toml 26 | └── rustfmt.toml 27 | ``` 28 | 29 | ### GitHub Actions 30 | 31 | This template comes with GitHub Actions pre-configured. Your code will be linted and tested on every push and pull 32 | request made to the `main` branch. 33 | 34 | You can edit the CI script in [.github/workflows/ci.yml](./.github/workflows/ci.yml). 35 | 36 | ## Usage 37 | 38 | See [The Rust Book](https://doc.rust-lang.org/book/) and [The Cargo Book](https://doc.rust-lang.org/cargo/index.html). 39 | 40 | ## License 41 | 42 | This project is licensed under MIT. 43 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | binop_separator = "Back" 2 | comment_width = 120 3 | imports_granularity = "Crate" 4 | max_width = 120 5 | reorder_imports = true 6 | tab_spaces = 4 7 | trailing_semicolon = true 8 | use_field_init_shorthand = true 9 | use_small_heuristics = "Max" 10 | wrap_comments = true 11 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use serde::Serialize; 2 | 3 | #[derive(Serialize, Debug)] 4 | struct Point { 5 | x: i32, 6 | y: i32, 7 | } 8 | 9 | fn main() { 10 | println!("Hello, world!"); 11 | 12 | let point = Point { x: 1, y: 2 }; 13 | 14 | // Convert the Point to a JSON string. 15 | let serialized = serde_json::to_string(&point).unwrap(); 16 | 17 | // Prints serialized = {"x":1,"y":2} 18 | println!("Serialized point = {}", serialized); 19 | } 20 | 21 | #[cfg(test)] 22 | mod tests { 23 | #[test] 24 | fn it_works() { 25 | let result = 2 + 2; 26 | assert_eq!(result, 4); 27 | } 28 | } 29 | --------------------------------------------------------------------------------