text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: csixteen/LeetCode path: /Problems/Algorithms/src/Rust/find-the-difference/src/lib.rs
// https://leetcode.com/c0x10/
struct Solution;
impl Solution {
pub fn find_the_difference(s: String, t: String) -> char {
s.bytes().chain(t.bytes()).fold(0_u8, |acc, c| acc ^ c) as char
}
}
#... | code_fim | medium | {
"lang": "rust",
"repo": "csixteen/LeetCode",
"path": "/Problems/Algorithms/src/Rust/find-the-difference/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/cargo path: /tests/testsuite/cargo_remove/mod.rs
mod avoid_empty_tables;
mod build;
mod dev;
mod dry_run;
mod gc_patch;
mod gc_profile;
mod gc_replace;
mod invalid_arg;
mod invalid_dep;
mod invalid_package;
mod invalid_package_multiple;
mod invalid_section;
mod invalid_section_dep;
mod inv... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/cargo",
"path": "/tests/testsuite/cargo_remove/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for name in ["semver", "serde"] {
cargo_test_support::registry::Package::new(name, "0.1.1")
.alternative(alt)
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new(name, "0.9.0")
.alternative(alt)
.featur... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/cargo",
"path": "/tests/testsuite/cargo_remove/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let numbers = parse_input().expect("Unable to read input");
let sum: i32 = numbers.iter().sum();
println!("Solution 1 = {}", sum);
let mut cache = HashSet::new();
cache.insert(0);
let mut result = None;
let mut sum = 0;
while result.is_none() {
for &n in &numbers {
... | code_fim | medium | {
"lang": "rust",
"repo": "MaikKlein/aoc-2018",
"path": "/src/bin/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaikKlein/aoc-2018 path: /src/bin/day1.rs
use std::collections::HashSet;
use std::io::{self, BufRead, BufReader};
fn parse_input() -> io::Result<Vec<i32>> {
<|fim_suffix|>fn main() {
let numbers = parse_input().expect("Unable to read input");
let sum: i32 = numbers.iter().sum();
prin... | code_fim | hard | {
"lang": "rust",
"repo": "MaikKlein/aoc-2018",
"path": "/src/bin/day1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>andler(stack_frame: &mut InterruptStackFrame) {
unsafe {
PICS.lock().notify_end_of_interrupt(Interrupts::Timer.as_u8());
}
}<|fim_prefix|>// repo: dalalsunil1986/ltmaOS path: /src/kernel/interrupts/handlers/timer.rs
use x86_64::structures::idt::InterruptStackFrame;
use crate::kernel::<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "dalalsunil1986/ltmaOS",
"path": "/src/kernel/interrupts/handlers/timer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dalalsunil1986/ltmaOS path: /src/kernel/interrupts/handlers/timer.rs
use x86_64::structures::idt::InterruptStackFrame;
use crate::kernel::<|fim_suffix|>andler(stack_frame: &mut InterruptStackFrame) {
unsafe {
PICS.lock().notify_end_of_interrupt(Interrupts::Timer.as_u8());
}
}<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "dalalsunil1986/ltmaOS",
"path": "/src/kernel/interrupts/handlers/timer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pandaman64/scoped-spawn path: /src/lib.rs
use futures::future::{abortable, AbortHandle, Aborted};
use pin_project::pin_project;
use std::future::Future;
use std::marker::PhantomData;
use std::mem::transmute;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
use toki... | code_fim | hard | {
"lang": "rust",
"repo": "pandaman64/scoped-spawn",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
use std::time::Duration;
use tokio::time::delay_for;
#[test]
fn test_scoped() {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let handle = rt.handle().clone();
rt.block_on(async {
{
let ... | code_fim | hard | {
"lang": "rust",
"repo": "pandaman64/scoped-spawn",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: webbestmaster/rust-lesson path: /yandex-contest/b-number-reverse/src/main.rs
use std::io;
fn main() {
let mut number_str = String::new();
io::stdin().read_line(&mut number_str).expect("Wring file, should contain 1 line with numbers");
println!("number str {}", number_str.trim());
... | code_fim | hard | {
"lang": "rust",
"repo": "webbestmaster/rust-lesson",
"path": "/yandex-contest/b-number-reverse/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if current_char != '0' {
result.push(current_char);
}
}
if !is_negative {
result.push(first_char);
}
let result_str: String = result.into_iter().collect();
println!("result str {:?}", result_str);
}<|fim_prefix|>// repo: webbestmaster/rust-lesson ... | code_fim | hard | {
"lang": "rust",
"repo": "webbestmaster/rust-lesson",
"path": "/yandex-contest/b-number-reverse/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let current_char = match char_list.next_back() {
Some(char) => char,
None => break
};
if current_char != '0' {
result.push(current_char);
}
}
if !is_negative {
result.push(first_char);
}
let result_st... | code_fim | hard | {
"lang": "rust",
"repo": "webbestmaster/rust-lesson",
"path": "/yandex-contest/b-number-reverse/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn del(&self, game_id: &GameId, req_id: &ReqId) -> Result<(), WriteErr> {
let key = redis_key(&game_id, &req_id);
if let Ok(mut conn) = self.get_connection() {
conn.del(&key).map_err(|_| WriteErr)
} else {
Err(WriteErr)
}
}
}
fn redis_key(ga... | code_fim | hard | {
"lang": "rust",
"repo": "Terkwood/BUGOUT",
"path": "/micro-sync/src/repo/reply.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Terkwood/BUGOUT path: /micro-sync/src/repo/reply.rs
use super::*;
use crate::core_model::*;
use redis::Client;
use std::rc::Rc;
use sync_model::api::ReqSync;
/// "Do we need to form a reply?"
/// Used when client is ahead of the system. Stores
/// a requested sync event which can later be merg... | code_fim | hard | {
"lang": "rust",
"repo": "Terkwood/BUGOUT",
"path": "/micro-sync/src/repo/reply.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dem42/MLPlayground path: /src/q_learning/human_agent.rs
use super::game_definition::*;
use super::agent::Agent;
pub struct Human {}
impl Human {
fn get_action() -> Action {
<|fim_suffix|>impl Agent for Human {
fn act(&mut self, game: &mut Game) {
game.print_state();
... | code_fim | hard | {
"lang": "rust",
"repo": "dem42/MLPlayground",
"path": "/src/q_learning/human_agent.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> game.print_state();
let mut action = Action::Invalid;
while action == Action::Invalid {
println!("Type 'A' to move left, 'D' to move right, 'Q' else to quit, and then press 'Enter'.");
action = Self::get_action();
}
game.update(action);... | code_fim | hard | {
"lang": "rust",
"repo": "dem42/MLPlayground",
"path": "/src/q_learning/human_agent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Agent for Human {
fn act(&mut self, game: &mut Game) {
game.print_state();
let mut action = Action::Invalid;
while action == Action::Invalid {
println!("Type 'A' to move left, 'D' to move right, 'Q' else to quit, and then press 'Enter'.");
act... | code_fim | hard | {
"lang": "rust",
"repo": "dem42/MLPlayground",
"path": "/src/q_learning/human_agent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: input-output-hk/chain-libs path: /cardano-legacy-address/benches/cbor.rs
use cardano_legacy_address::cbor::util::{encode_with_crc32_, raw_with_crc32};
use cbor_event::{
self,
de::Deserializer,
se::{Serialize, Serializer},
};
use criterion::{criterion_group, criterion_main, Criterion}... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/chain-libs",
"path": "/cardano-legacy-address/benches/cbor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn decode_crc32_with_cbor_event(c: &mut Criterion) {
c.bench_function("decode_crc32_with_cbor_event", |b| {
b.iter(|| {
let mut raw = Deserializer::from(CBOR);
let _bytes = raw_with_crc32(&mut raw).unwrap();
})
});
}
criterion_group!(
benches,
encod... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/chain-libs",
"path": "/cardano-legacy-address/benches/cbor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.len() == 3 {
if let Ok(row) = read_one_digit(args[1]) {
if let Ok(col) = read_one_digit(args[2]) {
return Box::new(move |game| {
match game.fill_cell((row - 1) as usize, (col - 1) as usize, 0) {
Ok(_) => game.set_m... | code_fim | hard | {
"lang": "rust",
"repo": "cyrilguerard/sudoku",
"path": "/src/input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyrilguerard/sudoku path: /src/input.rs
use std::collections::HashMap;
use std::io;
use crate::board::BOARD_SIZE;
use crate::game::Game;
use crate::generator::Difficulty;
pub type InputCommand = Box<dyn FnOnce(&mut Game) -> ()>;
pub type ParseCommand = fn(Vec<&str>) -> InputCommand;
lazy_stat... | code_fim | hard | {
"lang": "rust",
"repo": "cyrilguerard/sudoku",
"path": "/src/input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(args.len(), 1);
let message = args[0];
Box::new(move |game| {
game.set_message(format!("Error: {}", message));
})
}
fn cmd_new(args: Vec<&str>) -> InputCommand {
let difficulty = args
.get(1)
.map(|s| s.to_lowercase())
.map(|s| match s.as_str... | code_fim | hard | {
"lang": "rust",
"repo": "cyrilguerard/sudoku",
"path": "/src/input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/cargo-gccrs path: /tests/rustflags_project/src/main.rs
fn main() {
// Create an unused variable on purpose so that when using -D warn<|fim_suffix|> specific compiler flag.
let a = 15;
}<|fim_middle|>ing, rustc errors out
// and we get a | code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/cargo-gccrs",
"path": "/tests/rustflags_project/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> specific compiler flag.
let a = 15;
}<|fim_prefix|>// repo: iCodeIN/cargo-gccrs path: /tests/rustflags_project/src/main.rs
fn main() {
// Create an unused variable on purpose so that when using -D warn<|fim_middle|>ing, rustc errors out
// and we get a | code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/cargo-gccrs",
"path": "/tests/rustflags_project/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut the_vec = Vec::new();
let mut count =0;
loop {
sleep(Duration::new(1,0));
the_vec.push(Vec::with_capacity(1024).fill(1024));
count+=1;
println!("use {:?} M",count);
}
}<|fim_prefix|>// repo: Eson-Jia/huffman path: /src/bin/memory_test.rs
#![feature(... | code_fim | easy | {
"lang": "rust",
"repo": "Eson-Jia/huffman",
"path": "/src/bin/memory_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eson-Jia/huffman path: /src/bin/memory_test.rs
#![feature(slice_fill)]
use std::thread::sleep;
use std::time::Duration;
<|fim_suffix|> let mut the_vec = Vec::new();
let mut count =0;
loop {
sleep(Duration::new(1,0));
the_vec.push(Vec::with_capacity(1024).fill(1024));... | code_fim | easy | {
"lang": "rust",
"repo": "Eson-Jia/huffman",
"path": "/src/bin/memory_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut a = 2;
let b = testf(1.3, 1.4);
while a <= 10 {
println!("Hello, world: {} {}!", a, b);
a += 1;
}
return a;
}
fn main() {
main2();
}<|fim_prefix|>// repo: Nanoseb/gede path: /testapps/rust/test.rs
// A single line comment
#[cfg(feature = "test")]
fn te... | code_fim | medium | {
"lang": "rust",
"repo": "Nanoseb/gede",
"path": "/testapps/rust/test.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nanoseb/gede path: /testapps/rust/test.rs
// A single line comment
#[cfg(feature = "test")]
fn test(a: i32, b: i32) -> u8 {
return a+10+b;
}
fn testf(a: f32, b: f32) -> f32 {
return a+b+10.0;
}
/*
* a multi line comment
*/
<|fim_suffix|> let mut a = 2;
let b = testf(1.3, 1.4... | code_fim | easy | {
"lang": "rust",
"repo": "Nanoseb/gede",
"path": "/testapps/rust/test.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
* a multi line comment
*/
fn main2() -> i32 {
let mut a = 2;
let b = testf(1.3, 1.4);
while a <= 10 {
println!("Hello, world: {} {}!", a, b);
a += 1;
}
return a;
}
fn main() {
main2();
}<|fim_prefix|>// repo: Nanoseb/gede path: /testapps/rust/test.rs
// A s... | code_fim | medium | {
"lang": "rust",
"repo": "Nanoseb/gede",
"path": "/testapps/rust/test.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: howl111/ton-eth-bridge-relay path: /src/engine/handle_panic.rs
use std::{
panic::{self, PanicInfo},
process, thread, time,
};
use backtrace::Backtrace;
use serde::Serialize;
use sled::Db;
#[derive(Debug, Serialize)]
pub struct CrashInfo {
details: String,
backtrace: String,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "howl111/ton-eth-bridge-relay",
"path": "/src/engine/handle_panic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The Display formatter for a PanicInfo contains the message, payload and location.
let details = format!("{}", panic_info);
let backtrace = format!("{:#?}", Backtrace::new());
match db.flush() {
Ok(a) => log::info!("Flushed db on panic. Written {} bytes", a),
Err(e) => lo... | code_fim | hard | {
"lang": "rust",
"repo": "howl111/ton-eth-bridge-relay",
"path": "/src/engine/handle_panic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiberseq/fibertools-rs path: /src/main.rs
use anyhow::{bail, Error, Ok, Result};
use bio_io::*;
use colored::Colorize;
use env_logger::{Builder, Target};
use fibertools_rs::cli::Commands;
#[cfg(feature = "predict")]
use fibertools_rs::predict_m6a::PredictOptions;
use fibertools_rs::*;
use log::L... | code_fim | hard | {
"lang": "rust",
"repo": "fiberseq/fibertools-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match &args.command {
Some(Commands::Extract {
bam,
reference,
molecular: _molecular,
simplify,
quality,
min_ml_score,
m6a,
cpg,
msp,
nuc,
all,
full_f... | code_fim | hard | {
"lang": "rust",
"repo": "fiberseq/fibertools-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let cone = Cone::new(0.5f32, 0.75);
// Build the reflection.
let _ = Reflection::new(&cone);
}<|fim_prefix|>// repo: porky11/ncollide path: /examples/reflection.rs
extern crate ncollide;
<|fim_middle|>use ncollide::shape::{Cone, Reflection};
| code_fim | easy | {
"lang": "rust",
"repo": "porky11/ncollide",
"path": "/examples/reflection.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: porky11/ncollide path: /examples/reflection.rs
extern crate ncollide;
<|fim_suffix|> // Build the reflection.
let _ = Reflection::new(&cone);
}<|fim_middle|>use ncollide::shape::{Cone, Reflection};
fn main() {
let cone = Cone::new(0.5f32, 0.75);
| code_fim | medium | {
"lang": "rust",
"repo": "porky11/ncollide",
"path": "/examples/reflection.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file = File::create("output.txt").expect("Could not create file!");
file.write_all(b"Wellcome to dcode!")
.expect("Connot write to the file, sorry mate.");
}<|fim_prefix|>// repo: mateusfg7/rust-lang-study path: /rust-programmin-tutorial/27/write-file/src/main.rs
use std::fs::Fil... | code_fim | easy | {
"lang": "rust",
"repo": "mateusfg7/rust-lang-study",
"path": "/rust-programmin-tutorial/27/write-file/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mateusfg7/rust-lang-study path: /rust-programmin-tutorial/27/write-file/src/main.rs
use std::fs::File;
use std::io::prelude::*;
fn main() {
<|fim_suffix|> file.write_all(b"Wellcome to dcode!")
.expect("Connot write to the file, sorry mate.");
}<|fim_middle|> let mut file = File::c... | code_fim | medium | {
"lang": "rust",
"repo": "mateusfg7/rust-lang-study",
"path": "/rust-programmin-tutorial/27/write-file/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> file.write_all(b"Wellcome to dcode!")
.expect("Connot write to the file, sorry mate.");
}<|fim_prefix|>// repo: mateusfg7/rust-lang-study path: /rust-programmin-tutorial/27/write-file/src/main.rs
use std::fs::File;
use std::io::prelude::*;
fn main() {
<|fim_middle|> let mut file = File::c... | code_fim | medium | {
"lang": "rust",
"repo": "mateusfg7/rust-lang-study",
"path": "/rust-programmin-tutorial/27/write-file/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jd84/moviebay path: /src/model/movie.rs
use super::{FutRes, Model, Table};
use crate::sqlite::{params, Connection, SharedDb};
use serde::{Deserialize, Serialize};
macro_rules! mk_movie {
($x:expr) => {
Ok(Movie {
id: $x.get(0)?,
tmdb_id: $x.get(1)?,
... | code_fim | hard | {
"lang": "rust",
"repo": "jd84/moviebay",
"path": "/src/model/movie.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let movie = t.by_id(1).await.unwrap();
assert_eq!(Some(newmovie), movie);
};
let mut rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(func);
}
#[test]
fn test_all() {
let func = async {
let config = DatabaseConfig {... | code_fim | hard | {
"lang": "rust",
"repo": "jd84/moviebay",
"path": "/src/model/movie.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let movie;
if movies.len() != 1 {
movie = None;
} else {
movie = Some(movies.pop().unwrap());
}
Ok(movie)
}))
.await?;
... | code_fim | hard | {
"lang": "rust",
"repo": "jd84/moviebay",
"path": "/src/model/movie.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfcastellani/towerweb-nubank path: /src/main.rs
#[macro_use]
extern crate tower_web;
extern crate tokio;
use tower_web::ServiceBuilder;
/// This type will be part of the web service as a resource.
#[derive(Clone, Debug)]
struct HelloWorld;
#[derive(Clone, Debug)]
struct ArgResource;
/// This... | code_fim | medium | {
"lang": "rust",
"repo": "mfcastellani/towerweb-nubank",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(format!("We received the query {:?}", query_string))
}
#[post("/request-body")]
fn request_body(&self, body: Vec<u8>) -> Result<String, ()> {
Ok(format!("The BODY {} bytes", body.len()))
}
#[get("/headers")]
fn headers(&self, x_r... | code_fim | hard | {
"lang": "rust",
"repo": "mfcastellani/towerweb-nubank",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// fp256bn Modulus
// Base Bits= 56
pub const MODULUS: [Chunk; NLEN] = [
0x292DDBAED33013,
0x65FB12980A82D3,
0x5EEE71A49F0CDC,
0xFFFCF0CD46E5F2,
0xFFFFFFFF,
];
pub const ROI: [Chunk; NLEN] = [
0x292DDBAED33012,
0x65FB12980A82D3,
0x5EEE71A49F0CDC,
0xFFFCF0CD46E5F2,
0... | code_fim | hard | {
"lang": "rust",
"repo": "miracl/core",
"path": "/rust/rom_fp256bn_64.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: miracl/core path: /rust/rom_fp256bn_64.rs
/*
* Copyright (c) 2012-2020 MIRACL UK Ltd.
*
* This file is part of MIRACL Core
* (see https://github.com/miracl/core).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the ... | code_fim | hard | {
"lang": "rust",
"repo": "miracl/core",
"path": "/rust/rom_fp256bn_64.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 9at8/ipov path: /src/streamer.rs
extern crate hound;
use std::io;
use std::fs;
use std::i16;
use std::f32;
use std::f32::consts::PI;
pub struct Streamer {
writer: hound::WavWriter<io::BufWriter<fs::File>>,
sample_rate: u32,
internal_buffer: i16,
write_now: bool,
}
impl Streame... | code_fim | medium | {
"lang": "rust",
"repo": "9at8/ipov",
"path": "/src/streamer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let amplitude = i16::MAX as f32;
let out = ((ibf as f32) * amplitude) as i16;
//println!("output : {}", ((ibf as f32) * amplitude));
//println!("out : {}", out);
self.writer.write_sample(out).unwrap();
// restore internal buffer stat... | code_fim | medium | {
"lang": "rust",
"repo": "9at8/ipov",
"path": "/src/streamer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Starting with the initial value in `crc`, return the accumulated
/// CRC32 value for unsigned 64-bit integer `v`.
#[inline]
#[target_feature(enable = "sse4.2")]
#[cfg_attr(test, assert_instr(crc32))]
pub unsafe fn _mm_crc32_u64(crc: u64, v: u64) -> u64 {
crate::mem::transmute(crate::myarch::_mm_cr... | code_fim | medium | {
"lang": "rust",
"repo": "viirya/vektor",
"path": "/src/x86_64/sse42.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: viirya/vektor path: /src/x86_64/sse42.rs
// Autogenerated by `scrape.py`.
// See https://github.com/AdamNiederer/vektor-gen
<|fim_suffix|>/// Starting with the initial value in `crc`, return the accumulated
/// CRC32 value for unsigned 64-bit integer `v`.
#[inline]
#[target_feature(enable = "ss... | code_fim | medium | {
"lang": "rust",
"repo": "viirya/vektor",
"path": "/src/x86_64/sse42.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Make sure we distinguish between trait methods correctly.
eq(<u8 as Foo>::foo, <u16 as Foo>::foo);
//~^ ERROR mismatched types
//~| expected u8, found u16
}<|fim_prefix|>// repo: theduke/rust path: /src/test/compile-fail/fn-item-type.rs
// Copyright 2014 The Rust Project Developers. Se... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/compile-fail/fn-item-type.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> eq(bar::<String>, bar::<Vec<u8>>);
//~^ ERROR mismatched types
//~| expected type `fn(isize) -> isize {bar::<std::string::String>}`
//~| found type `fn(isize) -> isize {bar::<std::vec::Vec<u8>>}`
//~| expected struct `std::string::String`, found struct `std::vec::Vec`
// Make s... | code_fim | hard | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/compile-fail/fn-item-type.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theduke/rust path: /src/test/compile-fail/fn-item-type.rs
// Copyright 2014 The Rust 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
// ... | code_fim | medium | {
"lang": "rust",
"repo": "theduke/rust",
"path": "/src/test/compile-fail/fn-item-type.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /testing/jormungandr-automation/src/jcli/services/fragment_sender.rs
use super::{FragmentCheck, FragmentsCheck};
use crate::{jcli::JCli, jormungandr::JormungandrProcess};
pub struct FragmentSender<'a> {
jcli: JCli,
jormungandr: &'a JormungandrProcess,
}... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/testing/jormungandr-automation/src/jcli/services/fragment_sender.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> FragmentCheck::new(self.jcli, self.jormungandr, id, summary)
}
pub fn send_many(self, transactions: &'a [String]) -> FragmentsCheck {
for tx in transactions {
self.jcli
.rest()
.v0()
.message()
.post(tx, s... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/testing/jormungandr-automation/src/jcli/services/fragment_sender.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn send_many(self, transactions: &'a [String]) -> FragmentsCheck {
for tx in transactions {
self.jcli
.rest()
.v0()
.message()
.post(tx, self.jormungandr.rest_uri());
}
FragmentsCheck::new(self.jcli... | code_fim | medium | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/testing/jormungandr-automation/src/jcli/services/fragment_sender.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antonie-coetzee/scrapper path: /src/scrapper/db.rs
use crate::scrapper::scrape;
use rusqlite::{params, Connection, Transaction, Result};
pub fn initialize(dbpath:&str)-> Result<()>{
let conn = Connection::open(dbpath)?;
conn.execute_batch(
"CREATE TABLE IF NOT EXISTS Business (... | code_fim | hard | {
"lang": "rust",
"repo": "antonie-coetzee/scrapper",
"path": "/src/scrapper/db.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for number in phone_numbers {
trans.execute(
"INSERT INTO Telephone (business_id, value) VALUES (?1, ?2)",
params![business_id, number],
)?;
}
Ok(())
}
fn add_businesses(trans:&Transaction, businesses:&Vec<scrape::BusinessRecord>) -> Result<()>{
for... | code_fim | hard | {
"lang": "rust",
"repo": "antonie-coetzee/scrapper",
"path": "/src/scrapper/db.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Pagination with `first` only, when requesting more items than exist
assert_eq!(
TestCase {
first: Some(200),
after: None,
last: None,
before: None,
}
.run()
.unwrap(),
... | code_fim | hard | {
"lang": "rust",
"repo": "walfie/petronel-graphql",
"path": "/src/graphql/relay.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: walfie/petronel-graphql path: /src/graphql/relay.rs
pub start_cursor: Option<String>,
pub end_cursor: Option<String>,
}
pub trait Cursor: Serialize + DeserializeOwned {
type Edge;
fn to_scalar_string(&self) -> String {
let bytes = postcard::to_allocvec(self).expect("fa... | code_fim | hard | {
"lang": "rust",
"repo": "walfie/petronel-graphql",
"path": "/src/graphql/relay.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: walfie/petronel-graphql path: /src/graphql/relay.rs
o_scalar_string(&self) -> String {
let bytes = postcard::to_allocvec(self).expect("failed to stringify cursor");
bs58::encode(&bytes).into_string()
}
fn from_scalar_string(value: &str) -> Option<Self> {
let byte... | code_fim | hard | {
"lang": "rust",
"repo": "walfie/petronel-graphql",
"path": "/src/graphql/relay.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pvandommelen/aoc-2020-rust path: /src/day19/main.rs
use std::{collections::HashMap, fs, iter::{empty, once}};
use aoc_2020_rust::util::bench;
use nom::{IResult, branch::alt, bytes::complete::tag, character::complete::{alpha1, char, digit1}, combinator::{all_consuming, map}, multi::separated_list... | code_fim | hard | {
"lang": "rust",
"repo": "pvandommelen/aoc-2020-rust",
"path": "/src/day19/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let messages = sections[1].lines().collect();
(
rules,
messages,
)
}
fn run(rules: &Rules, messages: &Vec<&str>) -> u64 {
messages.iter().filter(|&&message| {
let mut result = rules.get(&0).unwrap().consume(rules, message);
result.find(|r| {
... | code_fim | hard | {
"lang": "rust",
"repo": "pvandommelen/aoc-2020-rust",
"path": "/src/day19/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct AccountBase {
keys: AccountKeys,
creation_timestamp: u64,
}<|fim_prefix|>// repo: rust-monero/rust-monero path: /src/cryptonote_basic/src/account.rs
use crate::block::AccountPublicAddress;
use crypto::chacha::ChaChaIV;
use crypto::crypto::SecretKey;
use device::Device;
<|fim_middle|>p... | code_fim | hard | {
"lang": "rust",
"repo": "rust-monero/rust-monero",
"path": "/src/cryptonote_basic/src/account.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-monero/rust-monero path: /src/cryptonote_basic/src/account.rs
use crate::block::AccountPublicAddress;
use crypto::chacha::ChaChaIV;
use crypto::crypto::SecretKey;
use device::Device;
<|fim_suffix|>pub struct AccountBase {
keys: AccountKeys,
creation_timestamp: u64,
}<|fim_middle|>p... | code_fim | hard | {
"lang": "rust",
"repo": "rust-monero/rust-monero",
"path": "/src/cryptonote_basic/src/account.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajunlonglive/sauron-native path: /examples/todomvc/src/lib.rs
//#![deny(warnings)]
#[cfg(feature = "with-web")]
use sauron_native::backend::HtmlApp;
use sauron_native::Backend;
#[cfg(feature = "with-web")]
use wasm_bindgen::prelude::*;
<|fim_suffix|>#[cfg(feature = "with-web")]
#[wasm_bindgen]
... | code_fim | easy | {
"lang": "rust",
"repo": "ajunlonglive/sauron-native",
"path": "/examples/todomvc/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "with-web")]
#[wasm_bindgen]
pub fn initialize(initial_state: &str) {
console_error_panic_hook::set_once();
console_log::init_with_level(log::Level::Trace).expect("must init");
log::trace!("Initial state: {}", initial_state);
HtmlApp::init(app::Model::new());
}<|fim_prefix|... | code_fim | easy | {
"lang": "rust",
"repo": "ajunlonglive/sauron-native",
"path": "/examples/todomvc/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tocklime/aoc-rs path: /aoc/src/solutions/y2016/day10.rs
use aoc_harness::aoc_main;
aoc_main!(2016 day 10, generator gen, part1 [p1], part2 [p2]);
use reformation::Reformation;
use nom::lib::std::collections::{HashMap, VecDeque};
use itertools::Itertools;
#[derive(Reformation, Debug, Hash, Par... | code_fim | hard | {
"lang": "rust",
"repo": "tocklime/aoc-rs",
"path": "/aoc/src/solutions/y2016/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn p1(input: &[Line]) -> Option<usize> {
let known_handlings = process(input);
//find bot which handles 61 and 17
known_handlings.iter().find(|(_,v)|
v.contains(&61) && v.contains(&17)
).unwrap().0.bot_value()
}
fn p2(input: &[Line]) -> usize {
let known_handlings = process... | code_fim | hard | {
"lang": "rust",
"repo": "tocklime/aoc-rs",
"path": "/aoc/src/solutions/y2016/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut known_handlings: HashMap<GiveTarget, Vec<usize>> = HashMap::new();
let mut to_handle: VecDeque<&Line> = input.iter().collect();
while !to_handle.is_empty() {
let item = to_handle.pop_front().unwrap();
match item {
Line::Input { bot, value } => known_handling... | code_fim | hard | {
"lang": "rust",
"repo": "tocklime/aoc-rs",
"path": "/aoc/src/solutions/y2016/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result: i32 = range.map(|x| (crit_1(x) && crit_2(x)) as i32).sum();
println!("Only crit 1 and 2: {:?}", result);
let result: i32 = range2
.map(|x| (crit_3(x) && crit_2(x) && crit_1(x)) as i32)
.sum();
println!("Only crit 2 and 3: {:?}", result);
}<|fim_prefix|>// repo:... | code_fim | medium | {
"lang": "rust",
"repo": "HeinerTholen/AdventOfCodeWithRust",
"path": "/_4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HeinerTholen/AdventOfCodeWithRust path: /_4/src/main.rs
use std::collections::HashSet;
const RANGE: (i32, i32) = (172930, 683082);
fn crit_1(num: i32) -> bool {
// dirty way to go via strings
let num_chars = num.to_string().into_bytes();
let mut last_char = num_chars[0];
for i ... | code_fim | hard | {
"lang": "rust",
"repo": "HeinerTholen/AdventOfCodeWithRust",
"path": "/_4/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // dirty way to go via strings
let num_chars = num.to_string().into_bytes();
let mut last_val = num_chars[0];
let mut n_same = 1;
let mut counts = HashSet::new();
for i in 1..6 {
if last_val == num_chars[i] {
n_same += 1;
} else {
counts.in... | code_fim | medium | {
"lang": "rust",
"repo": "HeinerTholen/AdventOfCodeWithRust",
"path": "/_4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match file.take(metadata.len()).read_to_end(&mut buffer) {
Ok(_) => {},
Err(e) => {
let error = format!("Error reading file {}", e);
return Err(S3Error::new(error));
},
}
let mut request = PutObjectRequest::default();
request.bucket = bucket.to_string();
reques... | code_fim | hard | {
"lang": "rust",
"repo": "hanscj1/s3lsio",
"path": "/src/object/put.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use term;
use Client;
use Output;
pub fn commands<P, D>(matches: &ArgMatches,
bucket: &str,
client: &mut Client<P,D>)
-> Result<(), S3Error>
where P: AwsCredentialsProvider,
D: DispatchSign... | code_fim | hard | {
"lang": "rust",
"repo": "hanscj1/s3lsio",
"path": "/src/object/put.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hanscj1/s3lsio path: /src/object/put.rs
// Copyright 2016 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.... | code_fim | hard | {
"lang": "rust",
"repo": "hanscj1/s3lsio",
"path": "/src/object/put.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> App::build(config).run();
}<|fim_prefix|>// repo: thismarvin/cc path: /Rust/001_Chaos_Game/chaos-game/src/main.rs
mod game;
use game::Game;
use rna::*;
<|fim_middle|>fn main() {
let mut config = AppConfig::new();
config.title = "Chaos Game";
config.window_size = (600, 600);
config.v... | code_fim | hard | {
"lang": "rust",
"repo": "thismarvin/cc",
"path": "/Rust/001_Chaos_Game/chaos-game/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thismarvin/cc path: /Rust/001_Chaos_Game/chaos-game/src/main.rs
mod game;
use game::Game;
use rna::*;
<|fim_suffix|> let mut config = AppConfig::new();
config.title = "Chaos Game";
config.window_size = (600, 600);
config.vsync_enabled = true;
config.core = Some(Box::new(Game... | code_fim | easy | {
"lang": "rust",
"repo": "thismarvin/cc",
"path": "/Rust/001_Chaos_Game/chaos-game/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stdrc/obtunnel path: /src/link.rs
use anyhow::Result;
use futures::{channel::mpsc, SinkExt, StreamExt};
use packet::ip;
use serde_json::{json, Value as JsonValue};
use tokio_tungstenite::{connect_async as ws_connect_async, tungstenite};
use tun::TunPacket;
use crate::Config;
/// OBLINK frame s... | code_fim | hard | {
"lang": "rust",
"repo": "stdrc/obtunnel",
"path": "/src/link.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Forward OBLINK frame from OBLINK layer to OneBot impl.
async fn oblink_to_ob(config: &Config, mut oblink: ObLinkSource, mut ob: ObSink) -> Result<()> {
// TODO: maybe to process packets concurrently in the future
while let Some(frame) = oblink.next().await {
debug_assert!(!frame.destin... | code_fim | hard | {
"lang": "rust",
"repo": "stdrc/obtunnel",
"path": "/src/link.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Setup OneBot connection and forward OBLINK frame between
/// OneBot impl and OBLINK layer.
pub async fn oblink_task(
config: &Config,
oblink_send: mpsc::UnboundedReceiver<Frame>,
oblink_recv: mpsc::UnboundedSender<Frame>,
) -> Result<()> {
let url = url::Url::parse(
config
... | code_fim | hard | {
"lang": "rust",
"repo": "stdrc/obtunnel",
"path": "/src/link.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JohnDoneth/hd44780-driver path: /src/display_size.rs
pub struct DisplaySize {
columns: u8,
lines: u8,
}
impl DisplaySize {
pub fn new(columns: u8, lines: u8) -> Self {
Self { columns, lines }
}
<|fim_suffix|>#[cfg(test)]
mod test_display_size {
use super::*;
#[test]
fn test_default_g... | code_fim | medium | {
"lang": "rust",
"repo": "JohnDoneth/hd44780-driver",
"path": "/src/display_size.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test_display_size {
use super::*;
#[test]
fn test_default_get() {
let std = DisplaySize::default();
assert_eq!(20, std.get().0);
assert_eq!(4, std.get().1);
}
}<|fim_prefix|>// repo: JohnDoneth/hd44780-driver path: /src/display_size.rs
pub struct DisplaySize {
columns: u8,
l... | code_fim | medium | {
"lang": "rust",
"repo": "JohnDoneth/hd44780-driver",
"path": "/src/display_size.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_default_get() {
let std = DisplaySize::default();
assert_eq!(20, std.get().0);
assert_eq!(4, std.get().1);
}
}<|fim_prefix|>// repo: JohnDoneth/hd44780-driver path: /src/display_size.rs
pub struct DisplaySize {
columns: u8,
lines: u8,
}
impl DisplaySize {
pub fn new(columns: ... | code_fim | easy | {
"lang": "rust",
"repo": "JohnDoneth/hd44780-driver",
"path": "/src/display_size.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn to_string(&self) -> String {
format!("circle: radius = {}", self.radius)
}
}<|fim_prefix|>// repo: nathanesau/data_structures_and_algorithms path: /_courses/cmpt225/lecture03/exceptions_rust/src/circle.rs
pub enum RadiusError {
NegativeError,
}
pub struct Circle {
pub x: i... | code_fim | medium | {
"lang": "rust",
"repo": "nathanesau/data_structures_and_algorithms",
"path": "/_courses/cmpt225/lecture03/exceptions_rust/src/circle.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>type T = u8;
#[EnumRepr(type = "T")]
enum En {
A = 1,
B = 2
}
#[EnumRepr(type = "T")]
pub enum PubEn {
A = 1,
B = 2
}<|fim_prefix|>// repo: dmnsafonov/enum-repr path: /test/nostdtest/src/lib.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org... | code_fim | medium | {
"lang": "rust",
"repo": "dmnsafonov/enum-repr",
"path": "/test/nostdtest/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[EnumRepr(type = "T")]
enum En {
A = 1,
B = 2
}
#[EnumRepr(type = "T")]
pub enum PubEn {
A = 1,
B = 2
}<|fim_prefix|>// repo: dmnsafonov/enum-repr path: /test/nostdtest/src/lib.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICE... | code_fim | medium | {
"lang": "rust",
"repo": "dmnsafonov/enum-repr",
"path": "/test/nostdtest/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmnsafonov/enum-repr path: /test/nostdtest/src/lib.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, mod... | code_fim | medium | {
"lang": "rust",
"repo": "dmnsafonov/enum-repr",
"path": "/test/nostdtest/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tor_left.product(&factor_right))
// },vec![2usize, 4, 6, 8, 10, 12, 14]);
//}
//
//criterion_group!(product_group, product);
//
//criterion_main!(product_group);<|fim_prefix|>// repo: davenza/Python_Rust_benchmark path: /src/lib.rs
//use criterion::Criterion;
//use test_utils;
//
//fn product(c: &mut ... | code_fim | hard | {
"lang": "rust",
"repo": "davenza/Python_Rust_benchmark",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davenza/Python_Rust_benchmark path: /src/lib.rs
//use criterion::Criterion;
//use test_utils;
//
//fn product(c: &mut Criterion) {
// c.bench_function_over_inputs("TabularFactor_product", |b, &size| {
// <|fim_suffix|>tor_left.product(&factor_right))
// },vec![2usize, 4, 6, 8, 10, 12,... | code_fim | hard | {
"lang": "rust",
"repo": "davenza/Python_Rust_benchmark",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: graphprotocol/graph-node path: /graph/src/runtime/gas/combinators.rs
use super::{Gas, GasSizeOf};
use std::cmp::{max, min};
pub mod complexity {
use super::*;
// Args have additive linear complexity
// Eg: O(N₁+N₂)
pub struct Linear;
// Args have multiplicative complexity
... | code_fim | hard | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/graph/src/runtime/gas/combinators.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T0, T1, T2, C> GasSizeOf for Combine<(T0, T1, T2), C>
where
T0: GasSizeOf,
T1: GasSizeOf,
T2: GasSizeOf,
C: GasCombinator,
{
fn gas_size_of(&self) -> Gas {
let (a, b, c) = &self.0;
C::combine(
C::combine(a.gas_size_of(), b.gas_size_of()),
c.... | code_fim | hard | {
"lang": "rust",
"repo": "graphprotocol/graph-node",
"path": "/graph/src/runtime/gas/combinators.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add all the new values
for value in values {
self.append(&name, value);
}
Ok(())
}
fn insert(&mut self, name: &GuestPtr<[u8]>, value: &GuestPtr<[u8]>) -> Result<(), Error> {
if name.len() > MAX_HEADER_NAME_LEN {
return Err(Error::... | code_fim | hard | {
"lang": "rust",
"repo": "StarpTech/Viceroy",
"path": "/lib/src/wiggle_abi/headers.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> let name = HeaderName::from_bytes(&name.as_slice()?)?;
let values = values
.as_slice()?
// split slice along nul bytes
.split(|b| *b == 0)
// reverse and skip to drop the empty item at the end
.rev()
.skip(1)
... | code_fim | hard | {
"lang": "rust",
"repo": "StarpTech/Viceroy",
"path": "/lib/src/wiggle_abi/headers.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: StarpTech/Viceroy path: /lib/src/wiggle_abi/headers.rs
use {
crate::{error::Error, wiggle_abi::types, wiggle_abi::MultiValueWriter},
http::{header::HeaderName, HeaderMap, HeaderValue},
std::convert::{TryFrom, TryInto},
wiggle::GuestPtr,
};
/// This constant reflects a similar co... | code_fim | hard | {
"lang": "rust",
"repo": "StarpTech/Viceroy",
"path": "/lib/src/wiggle_abi/headers.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Wumpf/blub path: /src/simulation_controller.rs
use crate::scene::Scene;
use crate::{
timer::{SimulationStepResult, Timer},
wgpu_utils::pipelines::PipelineManager,
};
use std::time::{Duration, Instant};
use wgpu_profiler::GpuProfiler;
// The simulation controller orchestrates simulation ... | code_fim | hard | {
"lang": "rust",
"repo": "Wumpf/blub",
"path": "/src/simulation_controller.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!(
"Fast forward of {:?} took {:?} to compute",
simulation_jump_length, self.computation_time_last_fast_forward
);
}
pub fn frame_steps(
&mut self,
scene: &mut Scene,
device: &wgpu::Device,
queue: &wgpu::Queue,
pi... | code_fim | hard | {
"lang": "rust",
"repo": "Wumpf/blub",
"path": "/src/simulation_controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn start_simulation_frame(&mut self) -> bool {
match self.status {
SimulationControllerStatus::Realtime => {}
SimulationControllerStatus::RecordingWithFixedFrameLength(frame_length) => {
self.timer.force_frame_delta(frame_length);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Wumpf/blub",
"path": "/src/simulation_controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /src/tools/clippy/clippy_lints/src/excessive_nesting.rs
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::source::snippet;
use rustc_ast::node_id::NodeSet;
use rustc_ast::visit::{walk_block, walk_item, Visitor};
use rustc_ast::{Block, Crate, Inline, Item, ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/clippy/clippy_lints/src/excessive_nesting.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> {
fn visit_block(&mut self, block: &Block) {
if block.span.from_expansion() {
return;
}
// TODO: This should be rewritten using `LateLintPass` so we can use `is_from_proc_macro` instead,
// but for... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/clippy/clippy_lints/src/excessive_nesting.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.nest_level > self.conf.excessive_nesting_threshold && !in_external_macro(self.cx.sess(), span) {
self.conf.nodes.insert(id);
return true;
}
false
}
}
impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> {
fn visit_block(&mut self, b... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/clippy/clippy_lints/src/excessive_nesting.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.