text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: datengx/rustboyadvance-ng path: /core/src/util.rs
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::ops::{Deref, DerefMut};
use std::path::Path;
use std::ptr;
use std::time;
use super::bus::{Addr, Bus, DebugRead};
#[cfg(not(target_arch = "wasm32"))]
type Instant = time::Instant... | code_fim | hard | {
"lang": "rust",
"repo": "datengx/rustboyadvance-ng",
"path": "/core/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Txuritan/stry path: /stry-models/src/pairing.rs
use {
crate::{Character, List},
chrono::{DateTime, TimeZone as _, Utc},
std::fmt,
};
#[rustfmt::skip]
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[derive(serde::Deserialize, serde::Serialize)]
pub struct Pairing {
... | code_fim | hard | {
"lang": "rust",
"repo": "Txuritan/stry",
"path": "/stry-models/src/pairing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub platonic: bool,
}
impl PairingBuilder {
pub fn with_character(mut self, id: impl Into<String>, name: impl Into<String>) -> Self {
self.characters.push(Character {
id: id.into(),
name: name.into(),
created: Utc.ymd(2020, 6, 8).and_hms(7, 22, 3),
... | code_fim | hard | {
"lang": "rust",
"repo": "Txuritan/stry",
"path": "/stry-models/src/pairing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jnu/crucible path: /rust/src/tiny_trie/build.rs
extern crate phf_codegen;
use std::env;
use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::Path;
const CHARS: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
fn main() {
<|fim_suffix|> let mu... | code_fim | hard | {
"lang": "rust",
"repo": "jnu/crucible",
"path": "/rust/src/tiny_trie/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Write map from characters to indexes.
write!(&mut file, "static BASE64_CHAR_TO_INT: phf::Map<char, u32> = ").unwrap();
ctoi.build(&mut file).unwrap();
write!(&mut file, ";\n").unwrap();
// Write map from indexes to characters
write!(&mut file, "static BASE64_INT_TO_CHAR: phf::M... | code_fim | hard | {
"lang": "rust",
"repo": "jnu/crucible",
"path": "/rust/src/tiny_trie/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Generate maps from characters to indexes and vice versa.
let mut ctoi = phf_codegen::Map::new();
let mut itoc = phf_codegen::Map::new();
let mut i: u8 = 0;
for c in CHARS.chars() {
let s = i.to_string();
ctoi.entry(c, &s);
itoc.entry(i, &format!("'{}'", &c))... | code_fim | hard | {
"lang": "rust",
"repo": "jnu/crucible",
"path": "/rust/src/tiny_trie/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rutrum/diet-database path: /api/src/bin/api.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
extern crate chrono;
extern crate rocket_contrib;
extern crate rocket_cors;
use rocket::http::Status;
use rocket_contrib::json::Json;
use rocket_cors::{AllowedOrigins, E... | code_fim | hard | {
"lang": "rust",
"repo": "rutrum/diet-database",
"path": "/api/src/bin/api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[get("/bowel")]
pub fn get_all() -> Json<Vec<Bowel>> {
let conn = db::create_connection();
let bowels = db::bowel::select_all(&conn).unwrap_or_default();
Json(bowels)
}
#[post("/bowel", data = "<bowel>")]
pub fn add(bowel: Json<NewBowel>) -> Status {
l... | code_fim | hard | {
"lang": "rust",
"repo": "rutrum/diet-database",
"path": "/api/src/bin/api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dahliaOS/fuchsia-pi4 path: /src/session/bin/scene_manager/src/main.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::Error,
fidl_fuchsia_input_injection::In... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/session/bin/scene_manager/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input_receiver = Some(input_device_registry_request_stream_receiver);
while let Some(service_request) = fs.next().await {
match service_request {
ExposedServices::Manager(request_stream) => {
if let Some(input_receiver) = input_receiver {
... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/session/bin/scene_manager/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn handle_manager_request_stream(
mut request_stream: ManagerRequestStream,
scene_manager: scene_management::FlatSceneManager,
input_device_registry_request_stream_receiver: futures::channel::mpsc::UnboundedReceiver<
InputDeviceRegistryRequestStream,
>,
) {
let scene_... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/session/bin/scene_manager/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32l0xx-hal path: /src/lib.rs
#![cfg_attr(not(test), no_std)]
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
#[cfg(not(any(feature = "stm32l0x1", feature = "stm32l0x2", feature = "stm32l0x3")))]
compile_error!(
"This crate requires one of the following fea... | code_fim | medium | {
"lang": "rust",
"repo": "stm32-rs/stm32l0xx-hal",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "stm32l0x1")]
pub use stm32l0::stm32l0x1 as pac;
#[cfg(feature = "stm32l0x2")]
pub use stm32l0::stm32l0x2 as pac;
#[cfg(feature = "stm32l0x3")]
pub use stm32l0::stm32l0x3 as pac;
pub mod adc;
pub mod aes;
pub mod calibration;
pub mod crc;
pub mod delay;
pub mod dma;
pub mod encoder;
pub m... | code_fim | medium | {
"lang": "rust",
"repo": "stm32-rs/stm32l0xx-hal",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abhijeetbhagat/rust-gym path: /collatz-conjecture.rs
fn cj(n : i32, c : u32)->u32{
<|fim_suffix|>fn main(){
assert_eq!(cj(20, 0), 8);
}<|fim_middle|> if n == 1{
c + 1
}
else if n & 1 == 0{
cj(n / 2, c + 1)
}
else{
cj(n * 3 + 1, c + 1)
}
}
| code_fim | medium | {
"lang": "rust",
"repo": "abhijeetbhagat/rust-gym",
"path": "/collatz-conjecture.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abhijeetbhagat/rust-gym path: /collatz-conjecture.rs
fn cj(n : i32, c : u32)->u32{
if n == 1{
c + 1
}
else if n & 1 == 0{
cj(n / 2, c + 1)
}
else{
cj(n * 3 + 1, c + 1)
}
}
<|fim_suffix|> assert_eq!(cj(20, 0), 8);
}<|fim_middle|>fn main(){
| code_fim | easy | {
"lang": "rust",
"repo": "abhijeetbhagat/rust-gym",
"path": "/collatz-conjecture.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(cj(20, 0), 8);
}<|fim_prefix|>// repo: abhijeetbhagat/rust-gym path: /collatz-conjecture.rs
fn cj(n : i32, c : u32)->u32{
if n == 1{
c + 1
}
else if n & 1 == 0{
cj(n / 2, c + 1)
}
else{
cj(n * 3 + 1, c + 1)
}
}
<|fim_middle|>fn main(){
| code_fim | easy | {
"lang": "rust",
"repo": "abhijeetbhagat/rust-gym",
"path": "/collatz-conjecture.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ir = v[index-1].clone();
let mut res= vec![];
for i in 0..index-1 {
res.push(v[i].clone());
}
for i in index..v.len() {
res.push(v[i].clone());
}
(ir, res)
}
fn main() {
let s = "abcd";
let res = remove_at(s.as_bytes(), 2);
println!("({}, {:?})"... | code_fim | medium | {
"lang": "rust",
"repo": "Checkmate50/rust99problems",
"path": "/src/bin/20.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let s = "abcd";
let res = remove_at(s.as_bytes(), 2);
println!("({}, {:?})", res.0, res.1);
}<|fim_prefix|>// repo: Checkmate50/rust99problems path: /src/bin/20.rs
// (*) Remove the K'th element from a list.
<|fim_middle|>fn remove_at<T:Clone> (v : &[T], index : usize) -> (T, Vec... | code_fim | hard | {
"lang": "rust",
"repo": "Checkmate50/rust99problems",
"path": "/src/bin/20.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Checkmate50/rust99problems path: /src/bin/20.rs
// (*) Remove the K'th element from a list.
fn remove_at<T:Clone> (v : &[T], index : usize) -> (T, Vec<T>) {
let ir = v[index-1].clone();
let mut res= vec![];
for i in 0..index-1 {
res.push(v[i].clone());
}
for i in ind... | code_fim | easy | {
"lang": "rust",
"repo": "Checkmate50/rust99problems",
"path": "/src/bin/20.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RuntimeMemoryCreator for MemoryCreatorProxy {
fn new_memory(
&self,
plan: &MemoryPlan,
minimum: usize,
maximum: Option<usize>,
_: Option<&Arc<MemoryImage>>,
) -> Result<Box<dyn RuntimeLinearMemory>> {
let ty = MemoryType::from_wasmtime_memory(&p... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/crates/wasmtime/src/trampoline/memory.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexcrichton/wasmtime path: /crates/wasmtime/src/trampoline/memory.rs
use crate::memory::{LinearMemory, MemoryCreator};
use crate::module::BareModuleInfo;
use crate::store::{InstanceId, StoreOpaque};
use crate::MemoryType;
use anyhow::{anyhow, Result};
use std::convert::TryFrom;
use std::sync::A... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/crates/wasmtime/src/trampoline/memory.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn allocate_tables(
&self,
index: usize,
req: &mut InstanceAllocationRequest,
tables: &mut PrimaryMap<DefinedTableIndex, Table>,
) -> Result<()> {
self.ondemand.allocate_tables(index, req, tables)
}
fn deallocate_tables(&self, index: usize, tables: ... | code_fim | hard | {
"lang": "rust",
"repo": "alexcrichton/wasmtime",
"path": "/crates/wasmtime/src/trampoline/memory.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> from {} and is {}", person.0, person.1, person.2);
}<|fim_prefix|>// repo: adeelibr/rust-sandbox path: /chapter_2_cargo/src/tuples.rs
// tuples group together value of different types, m<|fim_middle|>ax 12 elements
pub fn run() {
let person: (&str, &str, i8) = ("Adeel", "Lahore", 27);
println!("{} ... | code_fim | medium | {
"lang": "rust",
"repo": "adeelibr/rust-sandbox",
"path": "/chapter_2_cargo/src/tuples.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adeelibr/rust-sandbox path: /chapter_2_cargo/src/tuples.rs
// tuples group together value of different types, m<|fim_suffix|>str, i8) = ("Adeel", "Lahore", 27);
println!("{} is from {} and is {}", person.0, person.1, person.2);
}<|fim_middle|>ax 12 elements
pub fn run() {
let person: (&str,... | code_fim | easy | {
"lang": "rust",
"repo": "adeelibr/rust-sandbox",
"path": "/chapter_2_cargo/src/tuples.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Telcoltar/AdventOfCodeDay24-Rust path: /src/main.rs
mod test_solutions;
use std::fs::File;
use std::io::{BufReader, BufRead};
use regex::Regex;
use log::{debug, info};
use std::collections::{HashSet};
fn parse_direction(direction: &str) -> i32 {
return match direction {
"e" => 0,
... | code_fim | hard | {
"lang": "rust",
"repo": "Telcoltar/AdventOfCodeDay24-Rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tile_coords: Vec<(i32, i32)> = tiles.iter().
map(|p| get_coordination_from_path(p)).collect();
let mut flipped_tiles: HashSet<(i32, i32)> = HashSet::new();
for coord in &tile_coords {
if flipped_tiles.contains(coord) {
flipped_tiles.remove(coord);
} else... | code_fim | hard | {
"lang": "rust",
"repo": "Telcoltar/AdventOfCodeDay24-Rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tiles = get_input_data(filename);
let flipped_tiles: HashSet<(i32, i32)> = get_flipped_tiles(tiles);
return flipped_tiles.len();
}
fn get_number_of_flipped_neighbors(x: i32, y: i32, flipped_tiles: &HashSet<(i32, i32)>) -> i32 {
let mut count = 0;
for neigh in vec![(0, 2), (-1, 1),... | code_fim | hard | {
"lang": "rust",
"repo": "Telcoltar/AdventOfCodeDay24-Rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SPERAXIO/ckb path: /util/jsonrpc-types/src/indexer.rs
use crate::{BlockNumber, Capacity, CellOutput, Uint64};
use ckb_types::H256;
use serde::{Deserialize, Serialize};
// This is used as return value of get_live_cells_by_lock_hash RPC
#[derive(Debug, Serialize, Deserialize)]
pub struct LiveCell... | code_fim | hard | {
"lang": "rust",
"repo": "SPERAXIO/ckb",
"path": "/util/jsonrpc-types/src/indexer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)]
pub struct LockHashCapacity {
pub capacity: Capacity,
pub cells_count: Uint64,
pub block_number: BlockNumber,
}<|fim_prefix|>// repo: SPERAXIO/ckb path: /util/jsonrpc-types/src/indexer.rs
use crate::{BlockNumber, Capacity, CellOutput, Uint64};
use ckb_... | code_fim | hard | {
"lang": "rust",
"repo": "SPERAXIO/ckb",
"path": "/util/jsonrpc-types/src/indexer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
let nums = vec![1, 2, 3, 4, 5];
for j in nums.into_iter() { // IntoIterator trait
move_out(j);
}
}
fn with_enumerate()
{
let nums = vec![6, 5, 4, 3, 2, 1, 2, 3, 4, 5];
for (idx, j) in nums.into_iter().enumerate().fuse() { // IntoIterator trait
println!("idx {}, v... | code_fim | medium | {
"lang": "rust",
"repo": "Patrik-Stas/play_with_rust",
"path": "/old_futures/src/snoyman_3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patrik-Stas/play_with_rust path: /old_futures/src/snoyman_3.rs
fn double(x: &mut u32) {
*x *= 2;
}
fn exercise1() {
let mut x = 5;
double(&mut x);
println!("{}", x);
}
fn iterators_1()
{
for i in 1..3 {
let nums = vec![1, 2, 3, 4, 5]; // we are reconstructin this on... | code_fim | hard | {
"lang": "rust",
"repo": "Patrik-Stas/play_with_rust",
"path": "/old_futures/src/snoyman_3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn with_into_iter_to_get_ownership()
{
let nums = vec![1, 2, 3, 4, 5];
for j in nums.into_iter() { // IntoIterator trait
move_out(j);
}
}
fn with_enumerate()
{
let nums = vec![6, 5, 4, 3, 2, 1, 2, 3, 4, 5];
for (idx, j) in nums.into_iter().enumerate().fuse() { // IntoItera... | code_fim | hard | {
"lang": "rust",
"repo": "Patrik-Stas/play_with_rust",
"path": "/old_futures/src/snoyman_3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>token::tokenstats);
cfg.service(operator::operatorstats);
}<|fim_prefix|>// repo: biluohc/KeepStats path: /src/handlers/mod.rs
pub mod operator;
pub mod peers;
pub mod token;
pub fn init(c<|fim_middle|>fg: &mut actix_web::web::ServiceConfig) {
cfg.service(peers::peers);
cfg.service(peers::pe... | code_fim | medium | {
"lang": "rust",
"repo": "biluohc/KeepStats",
"path": "/src/handlers/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biluohc/KeepStats path: /src/handlers/mod.rs
pub mod operator;
pub mod peers;
pub mod token;
pub fn init(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(peer<|fim_suffix|>token::tokenstats);
cfg.service(operator::operatorstats);
}<|fim_middle|>s::peers);
cfg.service(peers::pe... | code_fim | medium | {
"lang": "rust",
"repo": "biluohc/KeepStats",
"path": "/src/handlers/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: james-lomax/AdventofCode2019 path: /day_18/src/main.rs
mod maze;
use std::collections::{BTreeSet, HashMap};
use common::array2d::Array2D;
use common::vec2::Vec2i;
use maze::{Maze, Block};
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
struct Robot {
pos: Vec2i,
cur_key: char
}
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "james-lomax/AdventofCode2019",
"path": "/day_18/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test1() {
let map = "########################
#f.D.E.e.C.b.A.@.a.B.c.#
######################.#
#d.....................#
########################";
let map = maze::read_map(map.to_string());... | code_fim | hard | {
"lang": "rust",
"repo": "james-lomax/AdventofCode2019",
"path": "/day_18/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test4() {
let map = "########################
#@..............ac.GI.b#
###d#e#f################
###A#B#C################
###g#h#i################
########################";
... | code_fim | hard | {
"lang": "rust",
"repo": "james-lomax/AdventofCode2019",
"path": "/day_18/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if computation.index() == 0 {
println!("Evaluation time: {:?}\n\n", timer3.elapsed());
println!("Total Execution: {:?}\n\n", timer.elapsed());
}
}).unwrap();
}
}
fn evaluate<G: Scope>(edges: &Collection<G, DiffEdge>, query_string: &S... | code_fim | hard | {
"lang": "rust",
"repo": "lukasstriebel/differential-dataflow",
"path": "/examples/pgql.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukasstriebel/differential-dataflow path: /examples/pgql.rs
output.push(((),sum as i32 /count ));
}).inspect(|&(_, ref x)| println!("{:?}", x));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "lukasstriebel/differential-dataflow",
"path": "/examples/pgql.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukasstriebel/differential-dataflow path: /examples/pgql.rs
(value) => value,
_ => panic!("No Float value found")
}
}
}
//////////////////////////////
// //
// TYPES QUERY //
// //
////////////////////////////... | code_fim | hard | {
"lang": "rust",
"repo": "lukasstriebel/differential-dataflow",
"path": "/examples/pgql.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = tremor_pipeline::influx_value(Cow::from("ramp_events"), tags, count, timestamp);
// full metrics payload
// TODO update origin url
Event {
data: value.into(),
ingest_ns: timestamp,
..Event::default()
}
}
// th... | code_fim | hard | {
"lang": "rust",
"repo": "rawkode/tremor-runtime",
"path": "/src/metrics.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn set_metrics_pipeline(&mut self, pipeline_tuple: (TremorUrl, pipeline::Addr)) {
self.metrics_pipeline = Some(pipeline_tuple);
}
pub(crate) fn increment_in(&mut self) {
self.metrics.r#in += 1;
}
pub(crate) fn increment_out(&mut self) {
self.metrics... | code_fim | hard | {
"lang": "rust",
"repo": "rawkode/tremor-runtime",
"path": "/src/metrics.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rawkode/tremor-runtime path: /src/metrics.rs
// Copyright 2020-2021, The Tremor Team
//
// 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.or... | code_fim | hard | {
"lang": "rust",
"repo": "rawkode/tremor-runtime",
"path": "/src/metrics.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = Vec::new();
let bytes = [
0xFF_u8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x31, 0x32,
];
let test_uuid = uuid::Uuid::from_slice(&bytes).unwrap();
let mut bytes = Output::test(ByteWrapper(&mut buffer));
ToSql::... | code_fim | hard | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/diesel/src/pg/types/uuid.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: diesel-rs/diesel path: /diesel/src/pg/types/uuid.rs
use std::io::prelude::*;
use crate::deserialize::{self, FromSql, FromSqlRow};
use crate::expression::AsExpression;
use crate::pg::{Pg, PgValue};
use crate::serialize::{self, IsNull, Output, ToSql};
use crate::sql_types::Uuid;
#[derive(AsExpre... | code_fim | hard | {
"lang": "rust",
"repo": "diesel-rs/diesel",
"path": "/diesel/src/pg/types/uuid.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfredett/advent_2017 path: /src/bin/day15.rs
fn main() {
println!("Advent of Code Day 15");
println!("");
println!("http://adventofcode.com/2017/day/15");
println!("");
let mut judge = Judge::new(vec![
Generator::new(722, 16807), //generator A... | code_fim | hard | {
"lang": "rust",
"repo": "jfredett/advent_2017",
"path": "/src/bin/day15.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(judge.score, 1);
}
#[test]
fn example_part2() {
let mut judge = Judge::new(vec![
Generator::new(65, 16807), //generator A
Generator::new(8921, 48271), //generator B
]);
for _ in 0..5000000 {
judge.judge_part2_round... | code_fim | hard | {
"lang": "rust",
"repo": "jfredett/advent_2017",
"path": "/src/bin/day15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Perform the following steps atomically with respect to any other atomic
/// accesses within `SCOPE` to the same location:
///
/// 1) load through `ptr` to get an original value,
/// 2) get a new value by integer addition of original value and `value`, and
/// 3) store the new value back through `ptr`.... | code_fim | hard | {
"lang": "rust",
"repo": "charles-r-earp/autograph",
"path": "/rust-shaders/shaders/src/atomic.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> old
}
/*
/// Perform the following steps atomically with respect to any other atomic
/// accesses within `SCOPE` to the same location:
///
/// 1. Load through `ptr` to get the original value
/// 2. Get a new value from `value` only if the original value equals
/// `comparator`, and
/// 3. Store th... | code_fim | hard | {
"lang": "rust",
"repo": "charles-r-earp/autograph",
"path": "/rust-shaders/shaders/src/atomic.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: charles-r-earp/autograph path: /rust-shaders/shaders/src/atomic.rs
//! Adapted from https://github.com/EmbarkStudios/rust-gpu/blob/atomics/crates/spirv-std/src/arch/atomics.rs
use crate::autobind;
use spirv_std::{
//scalar::Scalar,
memory::{Scope, Semantics},
integer::Integer,
g... | code_fim | hard | {
"lang": "rust",
"repo": "charles-r-earp/autograph",
"path": "/rust-shaders/shaders/src/atomic.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Matlor/ic-chatbot path: /agent/src/main.rs
use anyhow::{bail, Context, Result};
use candid::{
check_prog,
parser::value::IDLValue,
types::{Function, Type},
CandidType, Decode, Deserialize, IDLArgs, IDLProg, TypeEnv,
};
use clap::{crate_authors, crate_version, AppSettings, Clap};
... | code_fim | hard | {
"lang": "rust",
"repo": "Matlor/ic-chatbot",
"path": "/agent/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// fn print_result (result : Result<&[u8]>) {
// // let arg: ArgType = ArgType::Idl;
// let output: ArgType = ArgType::Idl;
// match result {
// Ok(blob) => {
// print_idl_blob(&blob, &output, &None)
// .context("Failed to print result blob")?;
// ... | code_fim | hard | {
"lang": "rust",
"repo": "Matlor/ic-chatbot",
"path": "/agent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Sending block information to ic_chatbot");
eprint!(".");
let result = builder
.with_arg(arg)
.with_effective_canister_id(canister_id)
.call_and_wait(
garcon::Delay::builder()
.exponential_backoff(std::time::Duration::from_secs(1), 1... | code_fim | hard | {
"lang": "rust",
"repo": "Matlor/ic-chatbot",
"path": "/agent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiji-flo/common-voice-wiki-scraper path: /src/extractor.rs
use regex::Regex;
use crate::character_map::CHARACTER_MAP;
static PUNCTUATIONS: [char; 3] = ['。', '?', '!'];
pub struct SentenceExtractor {
text: String,
}
impl SentenceExtractor {
pub fn new(text: &str) -> SentenceExtractor ... | code_fim | hard | {
"lang": "rust",
"repo": "fiji-flo/common-voice-wiki-scraper",
"path": "/src/extractor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let count = next_item.chars().count();
if count < 3 || count > 38 || is_invalid(&next_item) {
continue;
}
next_item = next_item
.chars()
.map(|c| CHARACTER_MAP.get(&c).unwrap_or(&c).clone())
.c... | code_fim | hard | {
"lang": "rust",
"repo": "fiji-flo/common-voice-wiki-scraper",
"path": "/src/extractor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_split_after() {
let value = "唐王國。鹰号称铜。高等";
let mut iter = SentenceExtractor::new(value);
assert_eq!(iter.next().unwrap(), "鹰号称铜。");
assert_eq!(iter.next().unwrap(), "高等");
assert!(iter.next().is_none());
}
}<|fim_prefix|>// repo: fiji-flo... | code_fim | hard | {
"lang": "rust",
"repo": "fiji-flo/common-voice-wiki-scraper",
"path": "/src/extractor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bruno319/jikan-rs path: /tests/anime.rs
extern crate jikan_rs;
#[macro_use]
extern crate lazy_static;
use jikan_rs::client::Jikan;
use std::thread;
use std::time::Duration;
lazy_static! {
static ref JIKAN: Jikan = Jikan::new();
}
#[tokio::test]
async fn should_get_anime_characters() {
... | code_fim | hard | {
"lang": "rust",
"repo": "bruno319/jikan-rs",
"path": "/tests/anime.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tokio::test]
async fn should_get_more_anime_info() {
thread::sleep(Duration::from_secs(3));
let more_info = JIKAN.find_anime(1)
.await.unwrap()
.get_more_info()
.await.unwrap().unwrap();
assert!(!more_info.is_empty());
}
#[tokio::test]
async fn should_get_anime_revie... | code_fim | hard | {
"lang": "rust",
"repo": "bruno319/jikan-rs",
"path": "/tests/anime.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_number(c: char) -> bool {
('0'..='9').contains(&c)
}
pub fn is_space(c: char) -> bool {
c > 0u8 as char && c <= 32u8 as char
}
pub fn is_symbol(c: char) -> bool {
c != '_'
&& (('!'..='/').contains(&c)
|| (':'..='?').contai... | code_fim | hard | {
"lang": "rust",
"repo": "CapsAdmin/nattlua-rust",
"path": "/src/lib/syntax.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CapsAdmin/nattlua-rust path: /src/lib/syntax.rs
use core::cmp::Reverse;
use regex::Regex;
use std::collections::{HashMap, HashSet};
use crate::token::{Token, TokenType};
pub struct BinaryOperatorInfo {
pub left_priority: u16,
pub right_priority: u16,
}
pub struct Syntax {
symbols:... | code_fim | hard | {
"lang": "rust",
"repo": "CapsAdmin/nattlua-rust",
"path": "/src/lib/syntax.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass.push_sql("SELECT *, COUNT(*) OVER () FROM (");
self.query.walk_ast(pass.reborrow())?;
pass.push_sql(") t LIMIT ");
pass.push_bind_param::<BigInt, _>(&self.per_page)?;
pass.push_sql(" OFFSET ");
let offset = (self.page - 1) * self.per_page;
pass.... | code_fim | hard | {
"lang": "rust",
"repo": "avalon1610/mirror-registry",
"path": "/src/database/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avalon1610/mirror-registry path: /src/database/mod.rs
pub mod schema;
use crate::{auth, config::Config};
use anyhow::{Context, Result};
use diesel::{
query_builder::{AstPass, Query, QueryFragment},
query_dsl::LoadQuery,
sql_types::BigInt,
sqlite::Sqlite,
Connection, QueryRes... | code_fim | hard | {
"lang": "rust",
"repo": "avalon1610/mirror-registry",
"path": "/src/database/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Copy, QueryId)]
pub struct Paginated<T> {
query: T,
page: i64,
per_page: i64,
}
impl<T> Paginated<T>
where
T: QueryFragment<Sqlite>,
{
pub fn per_page(self, per_page: i64) -> Self {
Paginated { per_page, ..self }
}
pub fn load_and_count<U>(self,... | code_fim | hard | {
"lang": "rust",
"repo": "avalon1610/mirror-registry",
"path": "/src/database/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexandreJubert/adventofcode2020 path: /src/main.rs
mod day_01;
mod day_02;
mod day_03;
mod day_04;
mod day_05;
mod day_06;
mod utils;
<|fim_suffix|> let input_file = utils::read_file_to_string("inputs/input_06.txt");
let groups = day_06::read_answers_from_string(&input_file);
let mu... | code_fim | easy | {
"lang": "rust",
"repo": "AlexandreJubert/adventofcode2020",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input_file = utils::read_file_to_string("inputs/input_06.txt");
let groups = day_06::read_answers_from_string(&input_file);
let mut sum = 0;
for group in groups {
sum += group.get_same_answers_count();
}
println!("{}", sum);
}<|fim_prefix|>// repo: AlexandreJubert/adven... | code_fim | easy | {
"lang": "rust",
"repo": "AlexandreJubert/adventofcode2020",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarcelRaschke/rust-book path: /smart_pointers/src/rc/mod.rs
// If Box is equinvalent to std::unique_ptr in C++, RC is equivalent to an std::shared_ptr.
// Rc <T> is only useful for single-threaded scenarios. For multi-threaded programs, Arc<T> will be
// required.
// A single threaded Rc type is... | code_fim | medium | {
"lang": "rust",
"repo": "MarcelRaschke/rust-book",
"path": "/smart_pointers/src/rc/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run() {
// We should see the destructor of "hello" being called only once.
let a = Rc::new(CustomSmartPointer { data: String::from("hello") });
let _b = a.clone();
// Listing 15-12.
let a = boxy::List::Cons(5, Box::new(boxy::List::Cons(10, Box::new(boxy::List::Nil))));
let _... | code_fim | medium | {
"lang": "rust",
"repo": "MarcelRaschke/rust-book",
"path": "/smart_pointers/src/rc/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> BitcoinD {
process,
client,
_work_dir,
cookie_file,
url,
}
}
pub fn wait(&mut self) -> Result<ExitStatus> {
Ok(self.process.wait()?)
}
}
impl Drop for BitcoinD {
fn drop(&mut self) {
let _ = self.... | code_fim | hard | {
"lang": "rust",
"repo": "lvaccaro/firma",
"path": "/cli/tests/bitcoind.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lvaccaro/firma path: /cli/tests/bitcoind.rs
use bitcoincore_rpc::{Auth, Client, RpcApi};
use firma::*;
use std::path::PathBuf;
use std::process::{Child, Command, ExitStatus};
use std::time::Duration;
use std::{env, thread};
use tempfile::TempDir;
pub struct BitcoinD {
process: Child,
pu... | code_fim | hard | {
"lang": "rust",
"repo": "lvaccaro/firma",
"path": "/cli/tests/bitcoind.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let node_url_default = format!("{}/wallet/default", url);
// wait bitcoind is ready, use default wallet
let client = loop {
thread::sleep(Duration::from_millis(500));
assert!(process.stderr.is_none());
let client_result = Client::new(url.clone(),... | code_fim | hard | {
"lang": "rust",
"repo": "lvaccaro/firma",
"path": "/cli/tests/bitcoind.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
// function declaration square
// function parameters input and result<|fim_prefix|>// repo: KKhan02/iot path: /w4_rs2/src/sub_function.rs
pub fn print_hello(){
println!("Hello World From another file")
}
<|fim_middle|>pub fn square (x:i32)->i32 {
let result = x*x;
result
| code_fim | medium | {
"lang": "rust",
"repo": "KKhan02/iot",
"path": "/w4_rs2/src/sub_function.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KKhan02/iot path: /w4_rs2/src/sub_function.rs
pub fn print_hello(){
println!("Hello World From another file")
}
<|fim_suffix|>// function declaration square
// function parameters input and result<|fim_middle|>pub fn square (x:i32)->i32 {
let result = x*x;
result
}
| code_fim | medium | {
"lang": "rust",
"repo": "KKhan02/iot",
"path": "/w4_rs2/src/sub_function.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: des256/e path: /src/base/vec4.rs
use {
crate::*,
std::{
cmp::PartialEq,
fmt::{
Display,
Formatter,
Result,
},
ops::{
Add,
Sub,
Mul,
Div,
AddAssign,
... | code_fim | hard | {
"lang": "rust",
"repo": "des256/e",
"path": "/src/base/vec4.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // vector -= vector
impl SubAssign<Vec4<$t>> for Vec4<$t> {
fn sub_assign(&mut self,other: Self) {
self.x -= other.x;
self.y -= other.y;
self.z -= other.z;
self.w -= other.w;
... | code_fim | hard | {
"lang": "rust",
"repo": "des256/e",
"path": "/src/base/vec4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.x *= other;
self.y *= other;
self.z *= other;
self.w *= other;
}
}
// vector / scalar
impl Div<$t> for Vec4<$t> {
type Output = Vec4<$t>;
... | code_fim | hard | {
"lang": "rust",
"repo": "des256/e",
"path": "/src/base/vec4.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ftilde/rust-x86asm path: /src/test/instruction_tests/instr_pclmulqdq.rs
use instruction_def::*;
use test::run_test;
use Operand::*;
use Reg::*;
use RegScale::*;
use RegType::*;
use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
#[test]
fn pclmulqdq_1... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_pclmulqdq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test(
&Instruction {
mnemonic: Mnemonic::PCLMULQDQ,
operand1: Some(Direct(XMM5)),
operand2: Some(IndirectScaledIndexedDisplaced(
RBX,
RDI,
Four,
486684225,
Some(OperandSize::... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_pclmulqdq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn pclmulqdq_4() {
run_test(
&Instruction {
mnemonic: Mnemonic::PCLMULQDQ,
operand1: Some(Direct(XMM5)),
operand2: Some(IndirectScaledIndexedDisplaced(
RBX,
RDI,
Four,
486684225,
... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_pclmulqdq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: victor-zed/tink-rust path: /tests/tests/signature/integration_test.rs
// Copyright 2020 The Tink-Rust Authors
//
// 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
//
//... | code_fim | hard | {
"lang": "rust",
"repo": "victor-zed/tink-rust",
"path": "/tests/tests/signature/integration_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let v = tink_signature::new_verifier(&pubkh).unwrap();
assert!(v.verify(&sig, msg).is_ok());
println!("Message: {}", std::str::from_utf8(msg).unwrap());
println!("Signature: {}", base64::encode(&sig));
}
#[test]
fn example_ed25519() {
tink_signature::init();
// Other key template... | code_fim | hard | {
"lang": "rust",
"repo": "victor-zed/tink-rust",
"path": "/tests/tests/signature/integration_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: extrawurst/azure-sdk-for-rust path: /sdk/cosmos/src/requests/create_database_builder.rs
use crate::prelude::*;
use crate::resources::ResourceType;
use crate::responses::CreateDatabaseResponse;
use azure_core::{No, ToAssign, Yes};
use http::StatusCode;
use std::convert::TryInto;
use std::marker::... | code_fim | hard | {
"lang": "rust",
"repo": "extrawurst/azure-sdk-for-rust",
"path": "/sdk/cosmos/src/requests/create_database_builder.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|> let request = request.body(req.as_bytes())?; // todo: set content-length here and elsewhere without builders
debug!("create database request prepared == {:?}", request);
Ok(self
.cosmos_client()
.http_client()
.execute_request_check_status(requ... | code_fim | hard | {
"lang": "rust",
"repo": "extrawurst/azure-sdk-for-rust",
"path": "/sdk/cosmos/src/requests/create_database_builder.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[connector_test]
async fn search_with_other_filters(runner: Runner) -> TestResult<()> {
super::search_with_other_filters(runner).await
}
#[connector_test]
async fn search_many_fields_not(runner: Runner) -> TestResult<()> {
super::search_many_fields_not(runner).await
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/filters/search_filter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let schema = indoc! {
r#"model TestModel {
#id(id, Int, @id)
fieldA String
fieldB String
fieldC String?
@@fulltext([fieldA])
@@fulltext([fieldB])
@@fulltext([fieldA, fieldB])
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/filters/search_filter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Blue-Pix/ezio path: /src/cookbook/date_and_time/parsing_and_displaying/mod.rs
use chrono::{Datelike, Timelike, Utc, NaiveDate, NaiveDateTime, NaiveTime, DateTime};
use chrono::format::ParseError;
pub fn examine_date_and_time() {
let now = Utc::now();
let (is_pm, hour) = now.hour12();
prin... | code_fim | hard | {
"lang": "rust",
"repo": "Blue-Pix/ezio",
"path": "/src/cookbook/date_and_time/parsing_and_displaying/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let date_time_after_a_billion_seconds = NaiveDateTime::from_timestamp(1_000_000_000, 0);
println!(
"Date after a billion seconds since 1970-01-01 00:00:00 was {}",
date_time_after_a_billion_seconds
);
}
pub fn format() {
let now = Utc::now();
println!("UTC now is {}", now);
println!("... | code_fim | hard | {
"lang": "rust",
"repo": "Blue-Pix/ezio",
"path": "/src/cookbook/date_and_time/parsing_and_displaying/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 1..prices.len() {
if prices[i - 1] < prices[i] {
profit += prices[i] - prices[i - 1];
}
}
profit
}
}
// @lc code=end<|fim_prefix|>// repo: itkrt2y/LeetCode path: /122.best-time-to-buy-and-sell-stock-ii.rs
/*
* @lc app=leetcode... | code_fim | medium | {
"lang": "rust",
"repo": "itkrt2y/LeetCode",
"path": "/122.best-time-to-buy-and-sell-stock-ii.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: itkrt2y/LeetCode path: /122.best-time-to-buy-and-sell-stock-ii.rs
/*
* @lc app=leetcode id=122 lang=rust
*
* [122] Best Time to Buy and Sell Stock II
*/
<|fim_suffix|> for i in 1..prices.len() {
if prices[i - 1] < prices[i] {
profit += prices[i] - prices[i... | code_fim | medium | {
"lang": "rust",
"repo": "itkrt2y/LeetCode",
"path": "/122.best-time-to-buy-and-sell-stock-ii.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brain0/systemd-daemon-rs path: /src/systemd_notifier.rs
use std::time::Duration;
use libsystemd::daemon::{notify, NotifyState, watchdog_enabled};
use futures::prelude::*;
#[cfg(feature = "tokio-core")]
use tokio_core::reactor::{PollEvented, Handle};
#[cfg(feature = "tokio")]
use tokio::reactor::... | code_fim | hard | {
"lang": "rust",
"repo": "brain0/systemd-daemon-rs",
"path": "/src/systemd_notifier.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Creates a new SystemdNotifier using the default reactor.
#[cfg(feature = "tokio")]
pub fn new() -> SystemdNotifier {
SystemdNotifier(SystemdNotifierInner::Starting {
reactor_data: ReactorData(None),
})
}
/// Creates a new SystemdNotifier.
#[cfg(feat... | code_fim | hard | {
"lang": "rust",
"repo": "brain0/systemd-daemon-rs",
"path": "/src/systemd_notifier.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let signature = vec![Type::Int32; 256];
let result = Type::from_signature_to_string(&signature[..]);
assert_eq!(result, Err(TypeError::ExceedMaximum(256)));
}<|fim_prefix|>// repo: LinkTed/dbus-message-parser path: /tests/value/type_enum.rs
use dbus_message_parser::value::{Type, TypeError};
u... | code_fim | hard | {
"lang": "rust",
"repo": "LinkTed/dbus-message-parser",
"path": "/tests/value/type_enum.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LinkTed/dbus-message-parser path: /tests/value/type_enum.rs
use dbus_message_parser::value::{Type, TypeError};
use std::convert::TryFrom;
#[test]
fn type_error_exceed_maximum_1() {
let result = Type::try_from(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_fim | medium | {
"lang": "rust",
"repo": "LinkTed/dbus-message-parser",
"path": "/tests/value/type_enum.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn type_error_exceed_maximum_2() {
let signature = vec![Type::Int32; 256];
let result = Type::from_signature_to_string(&signature[..]);
assert_eq!(result, Err(TypeError::ExceedMaximum(256)));
}<|fim_prefix|>// repo: LinkTed/dbus-message-parser path: /tests/value/type_enum.rs
use dbus_... | code_fim | hard | {
"lang": "rust",
"repo": "LinkTed/dbus-message-parser",
"path": "/tests/value/type_enum.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MatthieuBizien/Rboost path: /rboost/src/error.rs
use std::{error, fmt};
#[derive(Debug, Clone, Serialize, Deserialize)]
/// Generic error type on fitting error.
///
/// We have to define a specific type because the generic dyn Error is not Sync, so it can't be used
/// with Rayon.
pub struct Fi... | code_fim | medium | {
"lang": "rust",
"repo": "MatthieuBizien/Rboost",
"path": "/rboost/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> FitError::new(msg)
}
}
pub type FitResult<T> = Result<T, FitError>;
pub(crate) static SHOULD_NOT_HAPPEN: &str =
"There is an unexpected error in Rboost. Please raise a bug.";<|fim_prefix|>// repo: MatthieuBizien/Rboost path: /rboost/src/error.rs
use std::{error, fmt};
#[derive(Debug, C... | code_fim | hard | {
"lang": "rust",
"repo": "MatthieuBizien/Rboost",
"path": "/rboost/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: insou22/refunct-tas path: /lib/src/native/mod.rs
use std::sync::mpsc::TryRecvError;
#[cfg(unix)]
mod linux;
#[cfg(windows)]
mod windows;
#[cfg(unix)]
use self::linux::*;
#[cfg(windows)]
use self::windows::*;
use error::*;
#[cfg(unix)]
use consts;
use loops::{Event, Response};
use statics::{Sta... | code_fim | hard | {
"lang": "rust",
"repo": "insou22/refunct-tas",
"path": "/lib/src/native/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn init() {
#[cfg(windows)] windows::init();
hook_slateapp();
hook_newgame();
hook_tick();
hook_controller();
}
unsafe fn set_delta(d: f64) {
#[cfg(unix)]
let mut delta = consts::APP_DELTATIME as *mut u8 as *mut f64;
#[cfg(windows)]
let mut delta = windows::APP_DE... | code_fim | hard | {
"lang": "rust",
"repo": "insou22/refunct-tas",
"path": "/lib/src/native/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moismailzai/cfs_openpgp path: /src/generate.rs
use std::time::SystemTime;
use nettle::curve25519::private_key as cv25519_private_key;
use nettle::ed25519::private_key as ed25519_private_key;
use nettle::random::Yarrow;
use nettle::rsa::generate_keypair as rsa_generate_keypair;
use sequoia_openp... | code_fim | hard | {
"lang": "rust",
"repo": "moismailzai/cfs_openpgp",
"path": "/src/generate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Given a `Cert` and its corresponding `SignatureBuilder`, signs the `UserID` associated with it.
///
/// # Arguments
///
/// * `cert` - The `Cert` whose `UserID` you wish to sign.
/// * `cert_sb` - The `SignatureBuilder` associated with the `Cert`.
pub fn sign_cert_uid(cert: Cert, cert_sb: SignatureBui... | code_fim | hard | {
"lang": "rust",
"repo": "moismailzai/cfs_openpgp",
"path": "/src/generate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>7, -38083, 43508, 88045, 30724, -23946, 61220,
71880, 41138, -92922, -29715, 161, 33410, 26237, -7690, 91270, 813, -32732, 14524,
1252, 94186, -75790, -57940, 39870, -59283, -74709, 92212, -52992, 49494, -33849,
64581, -73016, 9605, -89990, 33049, 76940, 860... | code_fim | hard | {
"lang": "rust",
"repo": "mapx/leetcode-rust",
"path": "/src/n1330_reverse_subarray_to_maximize_array_value.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.