cargo install cargo-watch
cargo watch -q -c -w src/ -x 'run'
cargo watch -q -c -w src/ -x 'test'
# Using notepad popup below, place script within
notepad $profile
function cargoWatchR {
cargo watch -q -c -w src/ -x 'run'
}
function cargoWatchT {
cargo watch -q -c -w src/ -x 'test'
}
function cargoWatchTP($a) {
cargo watch -q -c -w src/ -x "test $a"
}
function cargoRun {
cargo run
}
function wasmPackWeb {
wasm-pack build --target web
}
Set-Alias cwr cargoWatchR
Set-Alias cwt cargoWatchT
Set-Alias cwtp cargoWatchTP
New-Alias cr cargoRun
New-Alias wpw wasmPackWeb
if (!(Get-Service ssh-agent | ? {$_.Status -eq 'Running'})) {
Start-Service ssh-agent
}
ssh-add
# enable ps scripts in windows
https://stackoverflow.com/questions/64393455/what-is-difference-between-derive-attribute-and-implementing-traits-for-structur
https://www.reddit.com/r/rust/comments/h8bpj6/a_very_basic_question_in_regard_to_derive_and_impl/
Derive is using a macro to implement trait into struct- cannot do it for Display because there is no one-way to display signed integers for example
struct MyBox<T>(T);
impl<T> MyBox<T> {
fn new(x: T) -> MyBox<T> {
MyBox(x)
}
}
// Declaration of a struct that takes in a generic and creates a tuple with that particular generic type
// {} are missing because everything can be done in a single line declaration
struct MyBox<T>(T);
// impl<T> declares the use of generic parameter
// here is where you can enter generics (either lifetimes or types, eg 'a, T, etc)
// MyBox<T> declares what type the below methods are implemented for
impl<T> MyBox<T> {
fn new(x: T) -> MyBox<T> {
MyBox(x)
}
}
fn main() {
let s = "Hello, World!";
// ::<String> is called turbofish- used to tell rust what type this function should be converted into
let string = s.into::<String>();
}
Need to install this before being able to build anything
sudo apt-get update
sudo apt install build-essential libssl-dev pkg-config