initial commit

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-10-26 11:47:17 +05:30
commit fcce234a10
15 changed files with 268 additions and 0 deletions

2
rust/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/target
*~

7
rust/Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "eulerfunt"
version = "0.1.0"

4
rust/Cargo.toml Normal file
View File

@@ -0,0 +1,4 @@
[package]
name = "eulerfunt"
version = "0.1.0"
edition = "2021"

5
rust/README.org Normal file
View File

@@ -0,0 +1,5 @@
* Run
Just run =cargo run --bin p<x>= where <x> is the problem number
* Environment
If you use nix just run =nix develop= or =nix develop .#withLsp= if you want rust-analyzer.

94
rust/flake.lock generated Normal file
View File

@@ -0,0 +1,94 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1666610816,
"narHash": "sha256-q4F2VNe5bpxXOvp16DyLwE1SgNZMbNO29ZQJPIomedg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "6107f97012a0c134c5848125b5aa1b149b76d2c9",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "release-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1665296151,
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"utils": "utils"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1666752703,
"narHash": "sha256-8l/yUNj3eH89T5uPDOZKjYNeOTSmn8xJCRC0c/Jedl8=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "b20d7b01b37268f240d185f5a2902d5fecb48ad3",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

36
rust/flake.nix Normal file
View File

@@ -0,0 +1,36 @@
{
description = "eulerfunt in Rust";
inputs = {
nixpkgs.url = github:nixos/nixpkgs/release-22.05;
utils.url = github:numtide/flake-utils;
rust-overlay.url = github:oxalica/rust-overlay;
};
outputs = { self, nixpkgs, utils, rust-overlay }:
utils.lib.eachDefaultSystem
(system:
let
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs {
inherit system overlays;
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
in
{
devShells = rec {
default = pkgs.mkShell {
buildInputs = [ toolchain ];
};
withLsp = pkgs.mkShell {
buildInputs = [
toolchain
pkgs.rust-analyzer
];
};
};
}
);
}

26
rust/gentoml Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env sh
toml=Cargo.toml
name=eulerfunt
cat > $toml <<EOF
[package]
name = "$name"
version = "0.1.0"
edition = "2021"
EOF
if ! [ -e ./src/p*.rs ]; then
exit 0
fi
for problem in ./src/p*.rs; do
file=${problem##*/}
bin=${file%.*}
cat >> $toml <<EOF
[[bin]]
name = "$bin"
path = "$problem"
EOF
done

3
rust/rust-toolchain Normal file
View File

@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2022-10-26"
components = [ "rustfmt", "clippy" ]

0
rust/src/lib.rs Normal file
View File