Browse Source

Initial commit.

main
Bauke 1 year ago
commit
a246c65527
Signed by: Bauke <me@bauke.xyz> GPG Key ID: C1C0F29952BCF558
6 changed files with 115 additions and 0 deletions
  1. +8
    -0
      .gitignore
  2. +12
    -0
      Cargo.toml
  3. +24
    -0
      License
  4. +46
    -0
      ReadMe.md
  5. +2
    -0
      rustfmt.toml
  6. +23
    -0
      source/lib.rs

+ 8
- 0
.gitignore View File

@@ -0,0 +1,8 @@
# Compiled files and executables.
/target/

# Cargo lockfile.
Cargo.lock

# Backup files generated by rustfmt.
**/*.rs.bk

+ 12
- 0
Cargo.toml View File

@@ -0,0 +1,12 @@
# https://doc.rust-lang.org/cargo/reference/manifest.html

[package]
name = "rust-lib-template"
authors = ["Bauke <me@bauke.xyz>"]
version = "0.1.0"
edition = "2018"

[lib]
path = "source/main.rs"

[dependencies]

+ 24
- 0
License View File

@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>

+ 46
- 0
ReadMe.md View File

@@ -0,0 +1,46 @@
# Rust Library Template

## "Features"

AKA personal preferences.

* `source/` instead of `src/` directory.
* Rustfmt configuration with:
* 80 character max line length.
* 2 space indentation.
* Cargo lockfile gitignored as per [The Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html).

## Usage

The command below will:

* Clone the project to `new-project`.
* Change directory into it.
* Remove the existing git history.
* Initialize git to start anew.

```sh
git clone "https://gitlab.com/Bauke/rust-lib-template.git" new-project &&
cd $_ &&
rm -rf .git/ &&
git init
```

### Reusable Function

Add this to your `.bashrc`, `.zshrc` (or similar) configuration so you don't have to copy-paste that whole command every time.

```sh
new-rust-lib () {
git clone "https://gitlab.com/Bauke/rust-lib-template.git" "$1" &&
cd "$1" &&
rm -rf .git/ &&
git init
}
```

Then use it as `new-rust-lib new-project`.

## License

Open-sourced with [the Unlicense](License).

+ 2
- 0
rustfmt.toml View File

@@ -0,0 +1,2 @@
max_width = 80
tab_spaces = 2

+ 23
- 0
source/lib.rs View File

@@ -0,0 +1,23 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
println!(
"
╭── Rust Library Template ────────────────────────────────
╰────────────────────────────────────────────────────────╮
╭────── https://gitlab.com/Bauke/rust-bin-template ──────╯
╰────── https://gitlab.com/Bauke/rust-lib-template ──────╮
╭────────────────────────────────────────────────────────╯
╰── Open-sourced with the Unlicense ──────────────────────
"
);

assert_eq!(2 + 2, 4);
}
}

Loading…
Cancel
Save