This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From bea85b28a25dcc23711a681d8620e3d3e371eb36 Mon Sep 17 00:00:00 2001 | |
| From: Adam Chalmers <adam.s.chalmers@gmail.com> | |
| Date: Tue, 25 Apr 2023 12:17:43 -0500 | |
| Subject: [PATCH] no macro | |
| --- | |
| src/obj.rs | 52 +++++++++++++++++++++++++--------------------------- | |
| 1 file changed, 25 insertions(+), 27 deletions(-) | |
| diff --git a/src/obj.rs b/src/obj.rs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use axum::{ | |
| body::Bytes, | |
| extract::{self, multipart::MultipartError}, | |
| Extension, | |
| }; | |
| use futures::Stream; | |
| use reqwest::StatusCode; | |
| async fn upload( | |
| mp: extract::Multipart, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // async_zip = { git = "https://github.com/majored/rs-async-zip.git", branch = "main" } | |
| // quick-xml = { git = "https://github.com/itsgreggreg/quick-xml.git", branch = "async", features = ["asynchronous"]} | |
| use async_zip::read::seek::ZipFileReader; | |
| use quick_xml::{events::Event, AsyncReader}; | |
| use tokio::io::BufReader; | |
| use tokio::sync::mpsc; | |
| #[tokio::main] | |
| async fn main() -> anyhow::Result<()> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use array_init::array_init; | |
| fn permutations<T: Copy, const N: usize>(items: &[T; N]) -> Vec<[T; N]> { | |
| permute_naturals::<N>(1, vec![[0; N]]) | |
| .into_iter() | |
| .map(|perm| array_init(|i| items[perm[i]])) | |
| .collect() | |
| } | |
| /// Generate all `n!` permutations of the natural numbers 0..n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::ffi::OsStr; | |
| use std::io; | |
| use std::fs::{self}; | |
| use std::path::{Path, PathBuf}; | |
| // Find all files in the given directory with the given extension | |
| fn paths_matching(extension: &str, dir: &Path) -> io::Result<Vec<PathBuf>> { | |
| let mut paths: Vec<PathBuf> = Vec::new(); | |
| for entry in fs::read_dir(dir)? { | |
| let entry = entry?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let array = Array(0..<10) | |
| let slice = array[2..<5] | |
| // Mixing Array/ArraySlice compiles! | |
| print(extend(array, withNewElems: array)) | |
| print(extend(array, withNewElems: slice)) | |
| print(extend(slice, withNewElems: slice)) | |
| // Mixing Ints/Bools doesn't compile! | |
| print(extend(array, withNewElems: [true, false])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func extend<T>(_: [T], withNewElems: [T]) -> [T] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func extend<T>(_: Collection, withNewElems: Collection) -> [T] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func extend<T: Collection>(_ base: T, withNewElems: T) -> T { | |
| // Ignore the function body for now, | |
| // we’re just trying to make it compile. | |
| return base | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func extend<T: Collection, U: Collection>(_ base: T, withNewElems: U) |