Video - Rust Tip - Customize Mutable Colors in VSCode
In the settings.json
add the following:
"editor.semanticTokenColorCustomizations": {
[package] | |
name = "yourpackage" | |
version = "0.1.0" | |
authors = ["John Doe"] | |
edition = "2018" | |
[[bin]] | |
name = "example" | |
path = "stream-a-file-using-rust-hyper.rs" |
Video - Rust Tip - Customize Mutable Colors in VSCode
In the settings.json
add the following:
"editor.semanticTokenColorCustomizations": {
// Here is an extremely simple version of work scheduling for multiple | |
// processors. | |
// | |
// The Problem: | |
// We have a lot of numbers that need to be math'ed. Doing this on one | |
// CPU core is slow. We have 4 CPU cores. We would thus like to use those | |
// cores to do math, because it will be a little less slow (ideally | |
// 4 times faster actually). | |
// | |
// The Solution: |
[package] | |
name = "Upload to S3" | |
version = "0.1.0" | |
authors = ["Ugo Varetto <ugo.varetto@csiro.au>"] | |
edition = 2021 | |
[dependencies] | |
aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } | |
# snippet-start:[s3.rust.s3-object-lambda-cargo.toml] | |
aws-endpoint = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } |
use std::thread::spawn; | |
// #1 Create type to move pointer can extend with new | |
// returning either wrapped pointer or ~None when pointer null | |
#[derive(Copy, Clone)] | |
struct Movable<T>(*mut T); | |
impl<T> Movable<T> { | |
fn get(&self) -> Option<*mut T> { | |
if self.0.is_null() { return None; } |
#![feature(unique)] | |
use std::thread::spawn; | |
// operating on a vector in parallel | |
fn main() { | |
let mut data:Vec<u32> = vec![1u32, 2, 3]; | |
println!("{:?}", data); | |
let head = data.as_mut_ptr(); | |
let mut guards = (0..3).map(|i| |
//https://docs.rs/aws-types/0.9.0/aws_types/credentials/struct.Credentials.html | |
use aws_types::Credentials; | |
use aws_types::region::Region; | |
let creds = Credentials::from_keys("akid", "secret_key", None); | |
let config = Config::builder() | |
.credentials_provider(creds) | |
.region(Region::new("us-east-1")) | |
.build(); |
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-gnu |
/// Tower equaliser: givern list of tower heights return the minimum number | |
/// of moves required to obtain tower of the same height or return "No solution" | |
fn towers(t: &[u32]) -> Option<u32> { | |
let mut moves: u32 = 0; | |
let mut n = t.to_vec(); | |
let max_moves: u32 = n.iter().sum(); | |
loop { | |
let imax = match n.iter().enumerate().max_by(|&(_, x), &(_, y)| x.cmp(&y)) { | |
Some((m, _)) => m, | |
_ => usize::MIN, |