Video - Rust Tip - Customize Mutable Colors in VSCode
In the settings.json
add the following:
"editor.semanticTokenColorCustomizations": {
use std::{ | |
fs::File, | |
io::{Read, Write}, | |
time::Instant, | |
}; | |
use tokio::task::{self, JoinHandle}; | |
async fn compute() { | |
let handles: Vec<JoinHandle<_>> = (0..1000) | |
.map(|_| { |
[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: |
#![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| |
let offset = 20000; | |
let chunk_size = 10000; | |
// File handle: | |
let mut handle = BufReader::new(File::open("data.bin").await?); | |
// Set cursor to needed chunk: | |
let mut chunk_stream = handle | |
.bytes() | |
.skip(offset) |
CL_SUCCESS 0 | |
CL_DEVICE_NOT_FOUND -1 | |
CL_DEVICE_NOT_AVAILABLE -2 | |
CL_COMPILER_NOT_AVAILABLE -3 | |
CL_MEM_OBJECT_ALLOCATION_FAILURE -4 | |
CL_OUT_OF_RESOURCES -5 | |
CL_OUT_OF_HOST_MEMORY -6 | |
CL_PROFILING_INFO_NOT_AVAILABLE -7 | |
CL_MEM_COPY_OVERLAP -8 | |
CL_IMAGE_FORMAT_MISMATCH -9 |
/* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
*/ | |
#include <arpa/inet.h> | |
#include <linux/if_packet.h> | |
#include <stdio.h> |
/* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
*/ | |
#include <arpa/inet.h> | |
#include <linux/if_packet.h> | |
#include <linux/ip.h> |