text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>- 1].is_uppercase())) { abbreviation.push(*c); } } } abbreviation.to_uppercase() }<|fim_prefix|>// repo: raymundovr/exercism-rust path: /acronym/src/lib.rs pub fn abbreviate(phrase: &str) -> String { let words = phrase .split(|c| c == '...
code_fim
medium
{ "lang": "rust", "repo": "raymundovr/exercism-rust", "path": "/acronym/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/fluvio path: /future-aio/src/io_util_3.rs use std::io; use std::io::ErrorKind::Other; use std::task::Poll; use std::task::Poll::Ready; use std::task::Poll::Pending; use futures::future::poll_fn; /// Borrowed from Tokio io utils but generalize to return any error <|fim_suffix|>fn bloc...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/fluvio", "path": "/future-aio/src/io_util_3.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>where F: FnOnce() -> Result<R,E>, E: From<io::Error> { match tokio_threadpool_2::blocking(f) { Ready(Ok(v)) => Ready(v), Ready(Err(_)) => Ready(Err(blocking_err().into())), Pending => Pending, } } pub async fn asyncify<F,R,E>(f: F) -> Result<R,E> where F: FnOnc...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/fluvio", "path": "/future-aio/src/io_util_3.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut d = HashSet::new(); let mut s = 0; d.insert(s); // could just loop { also for line in b.lines().cycle() { let v = line.parse::<i32>().expect("unable to parse"); s += v; if !d.insert(s) { println!("{}", s); return Ok(()); }...
code_fim
medium
{ "lang": "rust", "repo": "zachschuermann/advent-of-code", "path": "/2018/d01/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zachschuermann/advent-of-code path: /2018/d01/src/main.rs use std::io::{self, Read}; use std::collections::HashSet; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; fn main() -> Result<()> { <|fim_suffix|> p1(&buffer)?; p2(&buffer)?; Ok(()) } fn p1(b: &str) -> R...
code_fim
medium
{ "lang": "rust", "repo": "zachschuermann/advent-of-code", "path": "/2018/d01/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Watcher { path, pos, reader, create_time, }) } fn reregister_on_rotation(&mut self) -> Result<(), std::io::Error> { let file = match std::fs::File::open(&self.path) { Ok(f) => f, Err(err) => return ...
code_fim
hard
{ "lang": "rust", "repo": "christocs/regex_log", "path": "/src/watcher.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: christocs/regex_log path: /src/watcher.rs use std::io::{BufRead, Seek}; pub struct Watcher { path: std::path::PathBuf, pos: u64, reader: std::io::BufReader<std::fs::File>, create_time: std::time::SystemTime, // store create time, if this changes it means we have a new log file }...
code_fim
hard
{ "lang": "rust", "repo": "christocs/regex_log", "path": "/src/watcher.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } pub fn watch<F>(&mut self, action: F) -> Result<(), std::io::Error> where F: Fn(&str), { loop { let mut line = String::new(); let bytes_read = self.reader.read_line(&mut line); match bytes_read { Ok(by...
code_fim
hard
{ "lang": "rust", "repo": "christocs/regex_log", "path": "/src/watcher.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let server_fut = async { let conn = server.next().await; let _incoming_req = server::Connection::new(conn).await.unwrap(); }; tokio::join!(server_fut, client_fut); }<|fim_prefix|>// repo: fimbault/h3 path: /tests/h3-tests/tests/connection.rs use h3::{client, server}; use h3_t...
code_fim
medium
{ "lang": "rust", "repo": "fimbault/h3", "path": "/tests/h3-tests/tests/connection.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fimbault/h3 path: /tests/h3-tests/tests/connection.rs use h3::{client, server}; use h3_tests::Pair; #[tokio::test] async fn connect() { let mut pair = Pair::new(); let mut server = pair.server(); <|fim_suffix|> let server_fut = async { let conn = server.next().await; ...
code_fim
medium
{ "lang": "rust", "repo": "fimbault/h3", "path": "/tests/h3-tests/tests/connection.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pruthvi2103/DSADOD path: /CODECHEF/DecemberLong/4.rs #[allow(unused_imports)] use std::cmp::{min,max}; use std::io::{BufWriter, stdin, stdout, Write}; const BITS: usize = 19; #[derive(Default)] struct Scanner { buffer: Vec<String> } impl Scanner { fn next<T: std::str::FromStr>(&mut sel...
code_fim
hard
{ "lang": "rust", "repo": "pruthvi2103/DSADOD", "path": "/CODECHEF/DecemberLong/4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } else if tempz==kc && count > 0{ print!("{}",-1*(tempz as i32)); kc+=2; count -=1; } else{ print!("{}",tempz); }; for z in 2..N+1{ if(z>=thresh){ ...
code_fim
hard
{ "lang": "rust", "repo": "pruthvi2103/DSADOD", "path": "/CODECHEF/DecemberLong/4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } else if z==kc && count > 0{ print!(" {}",-1*(z as i32)); kc+=2; count -=1; } else{ print!(" {}",z); }; } print!("\n"); } } ...
code_fim
hard
{ "lang": "rust", "repo": "pruthvi2103/DSADOD", "path": "/CODECHEF/DecemberLong/4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> creation_options .open(sec_key_loc) .or_else(|e| Err(format!("File already exists? : {}", e.to_string())))? .write(&sec_key[..])?; Ok(()) } // TODO: Split this so that key generation and key retrieval is separated pub fn generate_key_and_nonce(key_loc: &str) -> Result<(se...
code_fim
hard
{ "lang": "rust", "repo": "8176135/rust-winapi-keylogger", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 8176135/rust-winapi-keylogger path: /src/lib.rs ic")] extern crate sodiumoxide; extern crate time; extern crate termsize; mod win_key_codes; use win_key_codes::*; use sodiumoxide::crypto::secretbox; use sodiumoxide::crypto::sealedbox; use sodiumoxide::crypto::box_; use std::io::Write; use std...
code_fim
hard
{ "lang": "rust", "repo": "8176135/rust-winapi-keylogger", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 8176135/rust-winapi-keylogger path: /src/lib.rs tatic")] extern crate sodiumoxide; extern crate time; extern crate termsize; mod win_key_codes; use win_key_codes::*; use sodiumoxide::crypto::secretbox; use sodiumoxide::crypto::sealedbox; use sodiumoxide::crypto::box_; use std::io::Write; use ...
code_fim
hard
{ "lang": "rust", "repo": "8176135/rust-winapi-keylogger", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FauxFaux/deb2pg path: /serve/src/main.rs extern crate byteorder; extern crate catfight; extern crate index; extern crate iron; extern crate logger; extern crate lz4; extern crate persistent; extern crate postgres; extern crate r2d2; extern crate r2d2_postgres; extern crate router; #[macro_use] e...
code_fim
hard
{ "lang": "rust", "repo": "FauxFaux/deb2pg", "path": "/serve/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} paths found; going to open index...", paths.len()); index::find::Index::open(paths).unwrap() }; println!("index loaded"); let mut router = Router::new(); router.get("/ds/status", status, "status"); router.get("/ds/blob/:bid", blob, "blob-details"); ro...
code_fim
hard
{ "lang": "rust", "repo": "FauxFaux/deb2pg", "path": "/serve/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uran0sH/notes path: /rust/essential_rust/exercise_ownership.rs fn main() { let s1 = String::from("hello world"); // let s2 = s1; // value borrowed here after move // println!("{}", s1); let s2 = s1.clone(); println!("s1 = {}", s1); println!("s2 = {}", s2); let s3...
code_fim
medium
{ "lang": "rust", "repo": "uran0sH/notes", "path": "/rust/essential_rust/exercise_ownership.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("The length of s3 = {}", calcaulate_length(&s3)); println!("s3 = {}", s3); let mut s4 = String::from("Hello"); change(&mut s4); println!("s4 = {}", s4); } // take s's ownership and give back fn takes_and_gives_back(s: String) -> String { s } fn calcaulate_length(s: &Stri...
code_fim
medium
{ "lang": "rust", "repo": "uran0sH/notes", "path": "/rust/essential_rust/exercise_ownership.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn calcaulate_length(s: &String) -> usize { s.len() } fn change(s: &mut String) { s.push_str("!"); }<|fim_prefix|>// repo: uran0sH/notes path: /rust/essential_rust/exercise_ownership.rs fn main() { let s1 = String::from("hello world"); // let s2 = s1; // value borrowed here after mov...
code_fim
medium
{ "lang": "rust", "repo": "uran0sH/notes", "path": "/rust/essential_rust/exercise_ownership.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if k>n || k == 0 {return None} Some((1..=k).fold( //https://en.wikipedia.org/wiki/Binomial_coefficient#Multiplicative_formula 1, |acc, i| acc*(n+1-i)/i )) }<|fim_prefix|>// repo: darakian/projecteuler path: /pe0015/src/main.rs fn main() { println!("{:?}", n_chose_k(40,20).unwrap...
code_fim
easy
{ "lang": "rust", "repo": "darakian/projecteuler", "path": "/pe0015/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darakian/projecteuler path: /pe0015/src/main.rs fn main() { println!("{:?}", n_chose_k(40,20).unwrap()); } <|fim_suffix|> if k>n || k == 0 {return None} Some((1..=k).fold( //https://en.wikipedia.org/wiki/Binomial_coefficient#Multiplicative_formula 1, |acc, i| acc*(n+1-i)/i ...
code_fim
easy
{ "lang": "rust", "repo": "darakian/projecteuler", "path": "/pe0015/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zeta1999/lambda_calculus path: /benches/lists.rs #![cfg(feature = "encoding")] #![feature(test)] extern crate test; extern crate lambda_calculus as lambda; use test::Bencher; use lambda::*; use lambda::data::list::{church, scott, parigot}; macro_rules! test_list { ($enc:ident, $name:iden...
code_fim
medium
{ "lang": "rust", "repo": "zeta1999/lambda_calculus", "path": "/benches/lists.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! test_list { ($enc:ident, $name:ident, $fun:ident, $conv:ident) => ( #[bench] fn $name(b: &mut Bencher) { b.iter(|| { beta(app!($enc::$fun(), vec![1.into_scott(), 2.into_scott(), 3.into_scott()].$conv()), HAP, 0) } ); } ); } test_list!( church, chu...
code_fim
medium
{ "lang": "rust", "repo": "zeta1999/lambda_calculus", "path": "/benches/lists.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaiCw4J/leetcode.rs path: /src/algorithms/remove_duplicates_26.rs // https://leetcode.com/problems/remove-duplicates-from-sorted-array/ // 双指针 判断 i 与 i + 1位 是否相等 相等时原地删除i位置上的值,不相等时指针前移一位, 最后返回nums.len() pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 { if nums.is_empty() { retu...
code_fim
medium
{ "lang": "rust", "repo": "MaiCw4J/leetcode.rs", "path": "/src/algorithms/remove_duplicates_26.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test() { assert_eq!(5, remove_duplicates(&mut vec![0,0,1,1,1,2,2,3,3,4])) } }<|fim_prefix|>// repo: MaiCw4J/leetcode.rs path: /src/algorithms/remove_duplicates_26.rs // https://leetcode.com/problems/remove-duplicates-from-sorted-...
code_fim
hard
{ "lang": "rust", "repo": "MaiCw4J/leetcode.rs", "path": "/src/algorithms/remove_duplicates_26.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krummelur/rust-pong path: /src/constants.rs pub const BALL_SIZE: u32 = 20; pub const PADDLE_WID<|fim_suffix|>_WIDTH: u32 = 400; pub const SIG_RESET: i32 = 0xfff;<|fim_middle|>TH: u32 = 10; pub const PADDLE_HEIGHT: u32 = 100; pub const WINDOW_HEIGHT: u32 = 400; pub const WINDOW
code_fim
medium
{ "lang": "rust", "repo": "krummelur/rust-pong", "path": "/src/constants.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_WIDTH: u32 = 400; pub const SIG_RESET: i32 = 0xfff;<|fim_prefix|>// repo: krummelur/rust-pong path: /src/constants.rs pub const BALL_SIZE: u32 = 20; pub const PADDLE_WIDTH: u32 = 10; pub const PADDLE_HEIGHT: u32 = 100; p<|fim_middle|>ub const WINDOW_HEIGHT: u32 = 400; pub const WINDOW
code_fim
easy
{ "lang": "rust", "repo": "krummelur/rust-pong", "path": "/src/constants.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Srinjana/rust_hangman path: /src/main.rs //generate random numbers extern crate rand; use rand::Rng; //imported for file handling use std::fs::File; use std::io::prelude::*; //imported code for user input use std::io; const ALLOWED_ATTEMPTS: u8 = 10; struct Letter { character: char, ...
code_fim
hard
{ "lang": "rust", "repo": "Srinjana/rust_hangman", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for letter in letters.iter_mut() { if letter.character == user_char { letter.revealed = true; atleast_one_letter_revealed = true; } } //lose turn for wrong guess if !atleast_one_lette...
code_fim
hard
{ "lang": "rust", "repo": "Srinjana/rust_hangman", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: telpalbrox/moon-web-server path: /src/http/url.rs // https://github.com/SerenityOS/serenity/blob/6c087480cf0b179918bd7b2b8c7d2017553043ad/AK/URL.cpp #[derive(PartialEq, Debug)] pub struct URL { pub protocol: String, pub host: String, pub port: u16, pub path: String, pub quer...
code_fim
hard
{ "lang": "rust", "repo": "telpalbrox/moon-web-server", "path": "/src/http/url.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn parse_simple_url() { assert_eq!( URLParser::new("http://example.com/").parse(), URL { protocol: String::from("http"), host: String::from("example.com"), port: 80, path: String::from("/"), ...
code_fim
hard
{ "lang": "rust", "repo": "telpalbrox/moon-web-server", "path": "/src/http/url.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ch = self.input.chars().nth(self.index); let ch = match ch { Some(ch) => ch, None => panic!( "URLParser: Expected char at index '{}' but input length is '{}'", self.index, self.input.len() ), };...
code_fim
hard
{ "lang": "rust", "repo": "telpalbrox/moon-web-server", "path": "/src/http/url.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for file in files { if file.nlink().to_string().chars().count() > max.0 { max.0 = file.nlink().to_string().chars().count(); } if file.owner().chars().count() > max.1 { max.1 = file.owner().chars().count(); } if file.group().chars().count(...
code_fim
hard
{ "lang": "rust", "repo": "gmorer/ls-rs", "path": "/src/print.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (index, file) in files.iter().enumerate() { if option::option_rr(options) && file.is_directory() { let mut new_path = old_path.clone(); new_path.push(file.name()); new_paths.push(new_path); } match *TERM_SIZE { Some(size) => {...
code_fim
hard
{ "lang": "rust", "repo": "gmorer/ls-rs", "path": "/src/print.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gmorer/ls-rs path: /src/print.rs extern crate libc; use std::path::PathBuf; use std::os::raw::{c_ulong, c_ushort}; use file; use std; use option; #[cfg(target_os = "macos")] const TIOCGWINSZ: c_ulong = 0x40087468; #[cfg(all(target_env = "musl", not(target_os = "macos")))] const TIOCGWINSZ: c_...
code_fim
hard
{ "lang": "rust", "repo": "gmorer/ls-rs", "path": "/src/print.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thedodd/simple_jwt path: /src/lib.rs //! # Introduction //! //! A very simple crate to deal with [json web token](http://jwt.io), //! this lib use the `rust-openssl`, so you may want to check the //! [rust-openssl](https://github.com/sfackler/rust-openssl) to find the //! set-up of openssl runt...
code_fim
hard
{ "lang": "rust", "repo": "thedodd/simple_jwt", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Serialize, Deserialize)] struct TestStruct { field_u32: u32, field_str: String } #[test] fn header_can_be_convert_from_and_to_base64() { let header = Header::new(Algorithm::default()); let b_string = header.to_base64_str().unwrap(); let...
code_fim
hard
{ "lang": "rust", "repo": "thedodd/simple_jwt", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simonbuchan/rust-vk path: /src/scene/mod.rs use std::collections::BTreeMap; use std::time::Duration; use ash::prelude::VkResult; use ash::vk; use crate::device::{self, AsRawHandle}; use crate::error::*; use crate::math::*; use crate::resources; use crate::scene::camera::Projection; use notify:...
code_fim
hard
{ "lang": "rust", "repo": "simonbuchan/rust-vk", "path": "/src/scene/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn render(&self, recorder: &device::CommandBufferRenderPassRecorder) -> Result<()> { self.view_uniform_buffer.write( 0, &ViewUniforms { view: self.camera.transform.matrix(), proj: self.camera.projection.matrix(), camer...
code_fim
hard
{ "lang": "rust", "repo": "simonbuchan/rust-vk", "path": "/src/scene/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod frame; mod class; mod enums; mod vm; #[derive(Debug, StructOpt)] struct Cli { /// Input file to read file: String, classpath: String } fn main() -> CliResult { let matches = Cli::from_args(); let myfile = &matches.file; let mycp = &matches.classpath; let vm = VM::new(my...
code_fim
easy
{ "lang": "rust", "repo": "helicopter88/rust-jvm", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn main() -> CliResult { let matches = Cli::from_args(); let myfile = &matches.file; let mycp = &matches.classpath; let vm = VM::new(myfile, mycp); VM::start(vm.unwrap(), "Add".to_string()); Ok(()) }<|fim_prefix|>// repo: helicopter88/rust-jvm path: /src/main.rs use quicli::pre...
code_fim
medium
{ "lang": "rust", "repo": "helicopter88/rust-jvm", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: helicopter88/rust-jvm path: /src/main.rs use quicli::prelude::*; use structopt::StructOpt; use crate::vm::VM; <|fim_suffix|> fn main() -> CliResult { let matches = Cli::from_args(); let myfile = &matches.file; let mycp = &matches.classpath; let vm = VM::new(myfile, mycp); ...
code_fim
medium
{ "lang": "rust", "repo": "helicopter88/rust-jvm", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(compare("x", "y", 3) < 1.0); } #[test] fn compare_eq_large() { assert_eq!(compare("alphabet", "alphabet", 3), 1.0); } #[test] fn compare_ne_large() { assert!(compare("alphabet", "alphabte", 3) < 1.0); }<|fim_prefix|>// repo: hamersaw/ruzzy path: /src/ngram.rs pub fn compare(a: &str,...
code_fim
medium
{ "lang": "rust", "repo": "hamersaw/ruzzy", "path": "/src/ngram.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hamersaw/ruzzy path: /src/ngram.rs pub fn compare(a: &str, b: &str, size: usize) -> f64 { if a == b { return 1.0; } //loop through first string add unique ngrams to vec let mut ngrams = Vec::new(); for ngram in compute_ngram_tokens(a, size) { if !ngrams.conta...
code_fim
medium
{ "lang": "rust", "repo": "hamersaw/ruzzy", "path": "/src/ngram.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn compare_eq_small() { assert_eq!(compare("x", "x", 3), 1.0); } #[test] fn compare_ne_small() { assert!(compare("x", "y", 3) < 1.0); } #[test] fn compare_eq_large() { assert_eq!(compare("alphabet", "alphabet", 3), 1.0); } #[test] fn compare_ne_large() { assert!(compare("alphabe...
code_fim
hard
{ "lang": "rust", "repo": "hamersaw/ruzzy", "path": "/src/ngram.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlessandroStamatto/Rust_book_-_course_Solutions path: /hw01/src/tests_student.rs #![cfg(test)] use problem1::{sum, dedup, filter}; use problem2::mat_mult; use problem3::sieve; use problem4::{hanoi, Peg}; //My Problem 1 Tests #[test] fn test_sum_big() { <|fim_suffix|> assert_eq!(vec![2,3,5,7...
code_fim
hard
{ "lang": "rust", "repo": "AlessandroStamatto/Rust_book_-_course_Solutions", "path": "/hw01/src/tests_student.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = hanoi(3, Peg::A, Peg::B, Peg::C); assert_eq!(vec![ (Peg::A, Peg::C), (Peg::A, Peg::B), (Peg::C, Peg::B), (Peg::A, Peg::C), (Peg::B, Peg::A), (Peg::B, Peg::C), (Peg::A, Peg::C) ], result); assert_eq!(7, result.len()); }<|fim_prefix|>// repo: ...
code_fim
hard
{ "lang": "rust", "repo": "AlessandroStamatto/Rust_book_-_course_Solutions", "path": "/hw01/src/tests_student.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iotaledger/bee path: /bee-ledger/bee-ledger-types/src/snapshot/kind.rs // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|>/// The kind of a snapshot. #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, packable::Packable)] #[packable(unpack_error = Err...
code_fim
medium
{ "lang": "rust", "repo": "iotaledger/bee", "path": "/bee-ledger/bee-ledger-types/src/snapshot/kind.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// The kind of a snapshot. #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, packable::Packable)] #[packable(unpack_error = Error)] #[packable(tag_type = u8, with_error = Error::InvalidSnapshotKind)] pub enum SnapshotKind { /// Full is a snapshot which contains the full ledger entry for a given...
code_fim
medium
{ "lang": "rust", "repo": "iotaledger/bee", "path": "/bee-ledger/bee-ledger-types/src/snapshot/kind.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust-enhanced path: /tests/error-tests/tests/error_across_mod.rs mod error_across_mod_f; fn test() { error_across_mod_f::f(1); // ^ERR(<1.24.0-beta) this function takes 0 parameters but 1 // ^ERR(<1.24.0-beta) expected 0 parameters // ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-enhanced", "path": "/tests/error-tests/tests/error_across_mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>5.0-beta,<1.69.0-beta) remove the extra argument // ^^^HELP(>=1.65.0-beta,<1.69.0-beta) /Accept Replacement:.*/ // ^HELP(>=1.69.0-beta) remove the extra argument // ^HELP(>=1.69.0-beta) /Accept Replacement:.*/ // ^^^^^^^^^^^^^^^^^^^^^MSG...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-enhanced", "path": "/tests/error-tests/tests/error_across_mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for OpCode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let s = match *self { OpCode::NOP => "NOP", OpCode::EXT => "EXT", OpCode::SYS => "SYS", OpCode::MOV => "MOV", OpCode::JMP => "JMP", OpCo...
code_fim
hard
{ "lang": "rust", "repo": "Syphonx/qcpu-rust", "path": "/src/qcpu/opcode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Syphonx/qcpu-rust path: /src/qcpu/opcode.rs use std::fmt; #[derive(Clone, Copy)] pub enum AddressingMode { IMMEDIATE = 0b00, ABSOLUTE = 0b01, INDIRECT = 0b10, REGISTER = 0b11, } #[derive(PartialEq)] pub enum OpCode { // system operations NOP = 0x0, // does nothing ...
code_fim
hard
{ "lang": "rust", "repo": "Syphonx/qcpu-rust", "path": "/src/qcpu/opcode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = match *self { AddressingMode::IMMEDIATE => "I", AddressingMode::INDIRECT => "N", AddressingMode::REGISTER => "R", AddressingMode::ABSOLUTE => "A", }; write!(f, "{}", s) } } impl OpCode { pub fn from_int(num: u16) -> O...
code_fim
hard
{ "lang": "rust", "repo": "Syphonx/qcpu-rust", "path": "/src/qcpu/opcode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> From<&'a http::Method> for HttpMethod { fn from(m: &'a http::Method) -> Self { HttpMethod { r#type: Some(m.into()), } } } // === impl Scheme === impl<'a> From<&'a http::uri::Scheme> for Scheme { fn from(scheme: &'a http::uri::Scheme) -> Self { sch...
code_fim
hard
{ "lang": "rust", "repo": "gridgentoo/linkerd2-proxy-api", "path": "/src/http_types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gridgentoo/linkerd2-proxy-api path: /src/http_types.rs use std::{ borrow::Cow, convert::{TryFrom, TryInto}, }; use thiserror::Error; include!("gen/io.linkerd.proxy.http_types.rs"); /// Indicates an HTTP Method could not be decoded. #[derive(Clone, Debug, Error)] #[error("invalid HTTP m...
code_fim
hard
{ "lang": "rust", "repo": "gridgentoo/linkerd2-proxy-api", "path": "/src/http_types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pcwalton/compute-shader path: /src/api/gl/program.rs // Copyright 2017 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http...
code_fim
medium
{ "lang": "rust", "repo": "pcwalton/compute-shader", "path": "/src/api/gl/program.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>unsafe fn destroy(this: &Program) { let mut shader = 0; gl::GetAttachedShaders(this.data() as GLuint, 1, &mut 0, &mut shader); gl::UseProgram(0); gl::DeleteProgram(this.data() as GLuint); gl::DeleteShader(shader); }<|fim_prefix|>// repo: pcwalton/compute-shader path: /src/api/gl/progr...
code_fim
medium
{ "lang": "rust", "repo": "pcwalton/compute-shader", "path": "/src/api/gl/program.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(1) } #[async] fn retrieve_data_2() -> Result<i32, i32> { Ok(2) } #[async_move] fn add_data() -> Result<i32, i32> { Ok(await!(retrieve_data_1())? + await!(retrieve_data_2())?) } fn main() { println!("Result: {:?}", block_on(add_data())); }<|fim_prefix|>// repo: PacktPublishing/Rust-Hi...
code_fim
medium
{ "lang": "rust", "repo": "PacktPublishing/Rust-High-Performance", "path": "/Chapter11/example8/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(await!(retrieve_data_1())? + await!(retrieve_data_2())?) } fn main() { println!("Result: {:?}", block_on(add_data())); }<|fim_prefix|>// repo: PacktPublishing/Rust-High-Performance path: /Chapter11/example8/src/main.rs #![feature(proc_macro, conservative_impl_trait, generators)] extern crate...
code_fim
medium
{ "lang": "rust", "repo": "PacktPublishing/Rust-High-Performance", "path": "/Chapter11/example8/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/Rust-High-Performance path: /Chapter11/example8/src/main.rs #![feature(proc_macro, conservative_impl_trait, generators)] <|fim_suffix|> Ok(await!(retrieve_data_1())? + await!(retrieve_data_2())?) } fn main() { println!("Result: {:?}", block_on(add_data())); }<|fim_middle...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Rust-High-Performance", "path": "/Chapter11/example8/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0345.rs // @ @<Cases where character is ignored@>= // any_state_plus(ignore),skip_blanks+spacer,new_line+spacer pub(crate) macro State_plus_cur_cmd_matches_cases_wh<|fim_suffix|>0207::ignore) || $state_plus_cur_cmd =...
code_fim
medium
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0345.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>_cur_cmd == crate::section_0303::new_line + crate::section_0207::spacer; use crate::section_0344::state_plus_cur_cmd_matches_any_case_plus; result }}<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0345.rs // @ @<Cases where character is ignored@>= // any_state_plus(igno...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0345.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(super) fn parse_footnote(input: &str) -> IResult<&str, Block> { map(terminated(footnote, line_ending), |(label, content)| { Block::Footnote(Footnote { label, content, ..Default::default() }) })(input) }<|fim_prefix|>// repo: meritozh/ex_markd...
code_fim
hard
{ "lang": "rust", "repo": "meritozh/ex_markdown", "path": "/src/block/footnote.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meritozh/ex_markdown path: /src/block/footnote.rs use nom::{ bytes::complete::{tag, take_until}, character::complete::{char, line_ending, not_line_ending, space1}, combinator::{map, map_parser, peek, rest}, error::context, sequence::{delimited, preceded, terminated, tuple}, ...
code_fim
hard
{ "lang": "rust", "repo": "meritozh/ex_markdown", "path": "/src/block/footnote.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn mod_rendering_opengl_unload(state: &mut State) { state.on_render_unload(); }<|fim_prefix|>// repo: dwerner/sg-engine path: /mod_rendering_opengl/src/lib.rs use std::time::Duration; use game_state::winit::EventsLoop; use std::sync::{Arc, Mutex}; mod renderer; use gam...
code_fim
hard
{ "lang": "rust", "repo": "dwerner/sg-engine", "path": "/mod_rendering_opengl/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dwerner/sg-engine path: /mod_rendering_opengl/src/lib.rs use std::time::Duration; use game_state::winit::EventsLoop; use std::sync::{Arc, Mutex}; mod renderer; use game_state::state::{DrawMode, RenderAccess, State, WindowAccess}; <|fim_suffix|>#[no_mangle] pub extern "C" fn mod_rendering_op...
code_fim
medium
{ "lang": "rust", "repo": "dwerner/sg-engine", "path": "/mod_rendering_opengl/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MattLangsenkamp/fightyboiscorpse path: /src/image-mangler.rs extern crate image; mod imagemangler { pub fn dice_image(filename: &String, spots:i32) -> Vec<String> { /* let img = image::open(filename).unwrap(); let dims = img.dimensions() let full_pixel_col = ...
code_fim
medium
{ "lang": "rust", "repo": "MattLangsenkamp/fightyboiscorpse", "path": "/src/image-mangler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let c = (pixel_col*spots/pixel_row).sqrt(); let r = (pixel_row*spots/pixel_col).sqrt(); let l = pixel_col/c; return (r, c, l) } fn create_image_for_spot(row:i32, col:i32, pixel_row:i32, pixel_col:i32, img:DynamicImage) { } }<|fim_prefix|>// repo: MattLangsenk...
code_fim
medium
{ "lang": "rust", "repo": "MattLangsenkamp/fightyboiscorpse", "path": "/src/image-mangler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn extract_webp_image(input: &str, exif: Option<&str>) { let file = File::open(format!("tests/images/{}", input)).expect("open webp"); let mut reader = BufReader::new(file); let webp = WebP::read(&mut reader).unwrap(); let exif_meta = webp.exif(); if let Some(exif) = exif { l...
code_fim
medium
{ "lang": "rust", "repo": "content-authenticity-initiative/img-parts", "path": "/tests/exif_webp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: content-authenticity-initiative/img-parts path: /tests/exif_webp.rs use std::fs::{self, File}; use std::io::BufReader; use img_parts::webp::WebP; use img_parts::ImageEXIF; <|fim_suffix|> extract_webp_image("P1133897_AdobeRGB.webp", Some("P1133897_AdobeRGB.exif")); } fn extract_webp_image(i...
code_fim
hard
{ "lang": "rust", "repo": "content-authenticity-initiative/img-parts", "path": "/tests/exif_webp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut machine = Machine::new(); machine.append(MOV(MutRegister(R0), Literal(42))); // mov r0 42 machine.run(); println!("R0={}", machine.get(R0)); }<|fim_prefix|>// repo: senior-sigan/fantasy-asm path: /src/main.rs use crate::instructions::Instruction::MOV; use crate::machine::ConstOpe...
code_fim
easy
{ "lang": "rust", "repo": "senior-sigan/fantasy-asm", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: senior-sigan/fantasy-asm path: /src/main.rs use crate::instructions::Instruction::MOV; use crate::machine::ConstOperand::Literal; use crate::machine::Machine; use crate::machine::MutOperand::MutRegister; use crate::machine::Register::R0; <|fim_suffix|> let mut machine = Machine::new(); m...
code_fim
easy
{ "lang": "rust", "repo": "senior-sigan/fantasy-asm", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("R0={}", machine.get(R0)); }<|fim_prefix|>// repo: senior-sigan/fantasy-asm path: /src/main.rs use crate::instructions::Instruction::MOV; use crate::machine::ConstOperand::Literal; use crate::machine::Machine; use crate::machine::MutOperand::MutRegister; use crate::machine::Register::R0; <|...
code_fim
medium
{ "lang": "rust", "repo": "senior-sigan/fantasy-asm", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fuchsch1234/lpc178x_7x path: /src/iocon/p2_10.rs #[doc = "Reader of register P2_10"] pub type R = crate::R<u32, super::P2_10>; #[doc = "Writer for register P2_10"] pub type W = crate::W<u32, super::P2_10>; #[doc = "Selects pin function for pin P2\\[10\\]"] #[derive(Clone, Copy, Debug, PartialEq)...
code_fim
hard
{ "lang": "rust", "repo": "fuchsch1234/lpc178x_7x", "path": "/src/iocon/p2_10.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>0 } #[doc = "Checks if the value of the field is `NMI`"] #[inline(always)] pub fn is_nmi(&self) -> bool { *self == FUNC_A::NMI } } #[doc = "Write proxy for field `FUNC`"] pub struct FUNC_W<'a> { w: &'a mut W, } impl<'a> FUNC_W<'a> { #[doc = r"Writes `variant` to the fie...
code_fim
hard
{ "lang": "rust", "repo": "fuchsch1234/lpc178x_7x", "path": "/src/iocon/p2_10.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>."] #[inline(always)] pub fn eint0(self) -> &'a mut W { self.variant(FUNC_A::EINT0) } #[doc = "Non-maskable interrupt input."] #[inline(always)] pub fn nmi(self) -> &'a mut W { self.variant(FUNC_A::NMI) } #[doc = r"Writes raw bits to the field"] #[inline...
code_fim
hard
{ "lang": "rust", "repo": "fuchsch1234/lpc178x_7x", "path": "/src/iocon/p2_10.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fanatid/ripple-rs path: /rrd/main.rs #![warn(elided_lifetimes_in_paths)] #![warn(missing_debug_implementations)] #![warn(missing_docs)] #![warn(single_use_lifetimes)] #![warn(trivial_casts)] #![warn(trivial_numeric_casts)] #![warn(unused_import_braces)] #![warn(unused_qualifications)] #![warn(un...
code_fim
hard
{ "lang": "rust", "repo": "fanatid/ripple-rs", "path": "/rrd/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> logj::init(); let _args = args::get_args(); let mut runtime = tokio::runtime::Builder::new() .core_threads(num_cpus::get()) .enable_io() .enable_time() .threaded_scheduler() .build() .expect("Building runtime"); let mut network = Network::n...
code_fim
hard
{ "lang": "rust", "repo": "fanatid/ripple-rs", "path": "/rrd/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut runtime = tokio::runtime::Builder::new() .core_threads(num_cpus::get()) .enable_io() .enable_time() .threaded_scheduler() .build() .expect("Building runtime"); let mut network = Network::new(); if let Err(error) = runtime.block_on(networ...
code_fim
medium
{ "lang": "rust", "repo": "fanatid/ripple-rs", "path": "/rrd/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.input = input; Ok(()) } fn inputs(&self) -> Vec<Arc<dyn IProcessor>> { vec![self.input.clone()] } fn as_any(&self) -> &dyn Any { self } async fn execute(&self) -> Result<SendableDataBlockStream> { let projected_schema = self.schema.cl...
code_fim
hard
{ "lang": "rust", "repo": "rostamn739/datafuse", "path": "/fusequery/query/src/pipelines/transforms/transform_projection.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> vec![self.input.clone()] } fn as_any(&self) -> &dyn Any { self } async fn execute(&self) -> Result<SendableDataBlockStream> { let projected_schema = self.schema.clone(); let input_stream = self.input.execute().await?; let executor = |schema: DataS...
code_fim
hard
{ "lang": "rust", "repo": "rostamn739/datafuse", "path": "/fusequery/query/src/pipelines/transforms/transform_projection.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rostamn739/datafuse path: /fusequery/query/src/pipelines/transforms/transform_projection.rs // Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. use std::any::Any; use std::sync::Arc; use common_datablocks::DataBlock; use common_datavalues::DataSchemaRef; use...
code_fim
hard
{ "lang": "rust", "repo": "rostamn739/datafuse", "path": "/fusequery/query/src/pipelines/transforms/transform_projection.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alberthuang24/kube-rust path: /crates/kubernetes-client/src/models/v1_persistent_volume_claim_template.rs /* * Kubernetes * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v1.21.1 * * Ge...
code_fim
hard
{ "lang": "rust", "repo": "alberthuang24/kube-rust", "path": "/crates/kubernetes-client/src/models/v1_persistent_volume_claim_template.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl V1PersistentVolumeClaimTemplate { /// PersistentVolumeClaimTemplate is used to produce PersistentVolumeClaim objects as part of an EphemeralVolumeSource. pub fn new(spec: crate::models::V1PersistentVolumeClaimSpec) -> V1PersistentVolumeClaimTemplate { V1PersistentVolumeClaimTemplate {...
code_fim
hard
{ "lang": "rust", "repo": "alberthuang24/kube-rust", "path": "/crates/kubernetes-client/src/models/v1_persistent_volume_claim_template.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct V1PersistentVolumeClaimTemplate { #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] pub metadata: Option<Box<crate::models::V1ObjectMeta>>, #[serde(rename = "spec")] pub spec: Box<crate::models::V1P...
code_fim
medium
{ "lang": "rust", "repo": "alberthuang24/kube-rust", "path": "/crates/kubernetes-client/src/models/v1_persistent_volume_claim_template.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oberblastmeister/macro_grammar path: /common/src/macros.rs /// Same as `bail!` in anyhow but for syn Errors. Turns tokens into span. #[macro_export] macro_rules! <|fim_suffix|>es)) }; } /// Same as `bail!` in anyhow but for syn Errors. Must provide span #[macro_export] macro_rules! bail { ...
code_fim
medium
{ "lang": "rust", "repo": "oberblastmeister/macro_grammar", "path": "/common/src/macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_rules! bail { ($span:expr, $mes:expr) => { return Err(syn::Error::new($span, $mes)) } }<|fim_prefix|>// repo: oberblastmeister/macro_grammar path: /common/src/macros.rs /// Same as `bail!` in anyhow but for syn Errors. Turns tokens into span. #[macro_export] macro_rules! bail_s { ($t...
code_fim
medium
{ "lang": "rust", "repo": "oberblastmeister/macro_grammar", "path": "/common/src/macros.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mhils/pyo3 path: /tests/test_no_imports.rs //! Tests that various macros work correctly without any PyO3 imports. #![cfg(feature = "macros")] #[pyo3::pyfunction] #[pyo3(name = "identity", signature = (x = None))] fn basic_function(py: pyo3::Python<'_>, x: Option<pyo3::PyObject>) -> pyo3::PyObj...
code_fim
hard
{ "lang": "rust", "repo": "mhils/pyo3", "path": "/tests/test_no_imports.rs", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pyo3::Python::with_gil(|py| { let module = pyo3::wrap_pymodule!(basic_module)(py); let cls = py.get_type::<BasicClass>(); let d = pyo3::types::IntoPyDict::into_py_dict( &[ ("mod", module.as_ref(py).as_ref()), ("cls", cls.as_ref()), ...
code_fim
hard
{ "lang": "rust", "repo": "mhils/pyo3", "path": "/tests/test_no_imports.rs", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> } } } impl Mul<f32> for Vec3{ type Output = Vec3; fn mul(self, rhs:f32) -> Vec3{ Vec3{ x: self.x * rhs, y: self.y * rhs, z: self.z * rhs, } } } impl Div<f32 >for Vec3{ type Output = Vec3; fn div(self, rhs:f32) -> Vec3...
code_fim
hard
{ "lang": "rust", "repo": "pratik2709/Ray-Tracing-Rust", "path": "/src/VectorLib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pratik2709/Ray-Tracing-Rust path: /src/VectorLib.rs use std::ops::Add; use std::ops::Sub; use std::ops::Mul; use std::ops::Div; use std::ops::Neg; #[derive(Clone)] #[derive(Debug)] pub struct Vec3{ pub x: f32, pub y: f32, pub z: f32, } impl Add for Vec3{ type Output = Vec3; ...
code_fim
hard
{ "lang": "rust", "repo": "pratik2709/Ray-Tracing-Rust", "path": "/src/VectorLib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // triangle is adjacent to plane with one side if (side_a == Side::On && side_b == Side::On) || (side_b == Side::On && side_c == Side::On) || (side_c == Side::On && side_a == Side::On) { return None; } // one point is on the plane, rest on one side if (side...
code_fim
hard
{ "lang": "rust", "repo": "YoshieraHuang/crab-claw", "path": "/src/triangle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YoshieraHuang/crab-claw path: /src/triangle.rs use crate::math::{dot_v3, sub_v3}; use crate::plane::Side; use crate::{Plane, Vertex, EPSILON}; pub enum TriangleSplit<V> { UpperLower { upper: Triangle<V>, lower: Triangle<V>, }, UpperTwoLower { upper: Triangle<...
code_fim
hard
{ "lang": "rust", "repo": "YoshieraHuang/crab-claw", "path": "/src/triangle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// clean this up pub(crate) fn intersect_triangle<V: Vertex + Clone>( plane: Plane, triangle: Triangle<V>, ) -> Option<([V; 2], TriangleSplit<V>)> { // TODO: could return a Result<TriangleSplit<V>, Side> instead, returning the side the triangle is on // would allow to remove the repeated c...
code_fim
hard
{ "lang": "rust", "repo": "YoshieraHuang/crab-claw", "path": "/src/triangle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_selected_codec(&mut self, codec: &Option<CodecId>) { self.selected_codec = codec.map(|c| self.inspect_node.create_string("selected_codec", &c.to_string())); } /// Record the inspect data for a finished procedure. pub fn record_procedure(&mut self, node: insp...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/bluetooth/profiles/bt-hfp-audio-gateway/src/inspect.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/bluetooth/profiles/bt-hfp-audio-gateway/src/inspect.rs ate::peer::service_level_connection::SlcState; lazy_static! { static ref PEER_ID: inspect::StringReference<'static> = "peer_id".into(); } #[derive(Default, Debug)] pub struct HfpInspect { pu...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/bluetooth/profiles/bt-hfp-audio-gateway/src/inspect.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Self { recent_procedures: VecDeque::with_capacity(MAX_RECENT_PROCEDURES), inspect_node: Default::default(), } } } #[derive(Default, Debug, Inspect)] pub struct HfFeaturesInspect { echo_canceling_and_noise_reduction: inspect::BoolProperty, three_way_call...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/bluetooth/profiles/bt-hfp-audio-gateway/src/inspect.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }