text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let mut running = true;
while running {
events_loop.poll_events(|event| if let Event::WindowEvent {event, ..} = event {
match event {
WindowEvent::CloseRequested => running = false,
// Push characters to the text
WindowEvent::Rece... | code_fim | hard | {
"lang": "rust",
"repo": "expenses/runic",
"path": "/examples/simple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: expenses/runic path: /examples/simple.rs
extern crate glium;
extern crate runic;
use glium::*;
use glutin::*;
fn main() {
// Create the events loop and display as per normal
let mut events_loop = EventsLoop::new();
let window = glutin::WindowBuilder::new()
.with_dimensions... | code_fim | hard | {
"lang": "rust",
"repo": "expenses/runic",
"path": "/examples/simple.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pool = Arc::new(pool);
Ok(DbContext {
roles: RoleDao::new(pool.clone()),
users: UserDao::new(pool.clone()),
})
}
}<|fim_prefix|>// repo: crallen/rust-learning-demo-app path: /src/db/context.rs
use sqlx::postgres::PgPoolOptions;
use std::sync::Arc;
... | code_fim | hard | {
"lang": "rust",
"repo": "crallen/rust-learning-demo-app",
"path": "/src/db/context.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(DbContext {
roles: RoleDao::new(pool.clone()),
users: UserDao::new(pool.clone()),
})
}
}<|fim_prefix|>// repo: crallen/rust-learning-demo-app path: /src/db/context.rs
use sqlx::postgres::PgPoolOptions;
use std::sync::Arc;
use crate::config::Config;
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "crallen/rust-learning-demo-app",
"path": "/src/db/context.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crallen/rust-learning-demo-app path: /src/db/context.rs
use sqlx::postgres::PgPoolOptions;
use std::sync::Arc;
use crate::config::Config;
use crate::db::dao::{RoleDao, UserDao};
<|fim_suffix|>impl DbContext {
pub async fn new(cfg: Config) -> Result<Self, sqlx::Error> {
let pool = P... | code_fim | medium | {
"lang": "rust",
"repo": "crallen/rust-learning-demo-app",
"path": "/src/db/context.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SoundRabbit/soldoresol path: /src/table/renderer/libs/webgl/mod.rs
use std::collections::HashMap;
use std::ops::Deref;
use std::rc::Rc;
pub mod program;
use program::Program;
#[derive(Hash, PartialEq, Eq, Clone)]
pub enum ProgramType {
ShapedProgram,
UnshapedProgram,
ScreenProgram... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/table/renderer/libs/webgl/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(using_program) = &self.using_program {
self.program_table.get(using_program)
} else {
None
}
}
pub fn new(gl: web_sys::WebGlRenderingContext) -> Self {
gl.depth_func(web_sys::WebGlRenderingContext::ALWAYS);
Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/table/renderer/libs/webgl/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jhungerford/adventofcode-2020 path: /day17/src/main.rs
use day17::Grid;
fn main() {
<|fim_suffix|> grid = Grid::load("input.txt", 4);
grid.step_times(6);
println!("Part 2: {}", grid.active());
}<|fim_middle|> let mut grid = Grid::load("input.txt", 3);
grid.step_times(6);
p... | code_fim | medium | {
"lang": "rust",
"repo": "jhungerford/adventofcode-2020",
"path": "/day17/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> grid = Grid::load("input.txt", 4);
grid.step_times(6);
println!("Part 2: {}", grid.active());
}<|fim_prefix|>// repo: jhungerford/adventofcode-2020 path: /day17/src/main.rs
use day17::Grid;
fn main() {
<|fim_middle|> let mut grid = Grid::load("input.txt", 3);
grid.step_times(6);
p... | code_fim | medium | {
"lang": "rust",
"repo": "jhungerford/adventofcode-2020",
"path": "/day17/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Librechain/nakamoto path: /p2p/src/protocol/tests/simulator.rs
ashMap;
use std::collections::BTreeMap;
use std::fmt;
/// Minimum latency between peers.
pub const MIN_LATENCY: LocalDuration = LocalDuration::from_millis(1);
/// Identifier for a simulated node/peer.
/// The simulator requires ea... | code_fim | hard | {
"lang": "rust",
"repo": "Librechain/nakamoto",
"path": "/p2p/src/protocol/tests/simulator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Process a protocol output event from a node.
pub fn schedule(&mut self, node: &NodeId, out: Out) {
let node = *node;
match out {
Out::Message(receiver, msg) => {
// If the other end has disconnected the sender with some latency, there may not be
... | code_fim | hard | {
"lang": "rust",
"repo": "Librechain/nakamoto",
"path": "/p2p/src/protocol/tests/simulator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.inbox.insert(
time,
Scheduled {
remote: *sender_addr,
node: receiver.ip(),
input: Input::Received(*sender_addr, msg),
},
... | code_fim | hard | {
"lang": "rust",
"repo": "Librechain/nakamoto",
"path": "/p2p/src/protocol/tests/simulator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.len == other.len
}
}
tree.add_key_word_ext("abc".as_bytes().to_vec(), Ext{cate:1, len: 3, weight: 1});
tree.add_key_word_ext("bc".as_bytes().to_vec(), Ext{cate:2, len: 2, weight: 10});
tree.build();
let r = tree.query_cate_weight("abc".as_bytes().as_ref());
... | code_fim | hard | {
"lang": "rust",
"repo": "yangcancai/word_sensitive",
"path": "/examples/leak/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yangcancai/word_sensitive path: /examples/leak/src/main.rs
use word_sensitive::Trie;
use word_sensitive::trie::NodeExt;
fn main() {
let mut tree = Trie::<usize>::default();
tree.add_key_word("aaa".as_bytes().to_vec());
tree.add_key_word("aab".as_bytes().to_vec());
tree.add_key_wo... | code_fim | hard | {
"lang": "rust",
"repo": "yangcancai/word_sensitive",
"path": "/examples/leak/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tree.build();
tree.add_key_word("cca".as_bytes().to_vec());
tree.add_key_word("ccb".as_bytes().to_vec());
tree.add_key_word("ccc".as_bytes().to_vec());
tree.build();
let mut tree = Trie::default();
#[derive(Clone)]
struct Ext{
cate: usize,
len: usize,
... | code_fim | medium | {
"lang": "rust",
"repo": "yangcancai/word_sensitive",
"path": "/examples/leak/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rbudnar/rust-mazes path: /crate/src/grid/polar_grid.rs
use std::rc::Rc;
use std::f64::consts::PI;
use wasm_bindgen::prelude::JsValue;
use math::round;
use crate::grid::{Grid, CellFormatter, canvas::{setup_grid_canvas, remove_old_canvas, draw_line, DrawMode, set_canvas_size}};
use crate::cells::{... | code_fim | hard | {
"lang": "rust",
"repo": "rbudnar/rust-mazes",
"path": "/crate/src/grid/polar_grid.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let size = 20;
let img_size = 2 * self.rows * size;
remove_old_canvas(POLAR_GRID);
let context = setup_grid_canvas(POLAR_GRID).unwrap();
set_canvas_size(POLAR_GRID, img_size, img_size);
context.set_fill_style(&JsValue::from_str("black"));
c... | code_fim | hard | {
"lang": "rust",
"repo": "rbudnar/rust-mazes",
"path": "/crate/src/grid/polar_grid.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sile/scalable_bloom_filter path: /src/hash.rs
//! `NthHash` trait and its default implementation.
use std::hash::{Hash, Hasher};
use siphasher::sip::SipHasher13;
<|fim_suffix|>}
/// The default implementation of `NthHash` trait.
#[derive(Debug)]
pub struct DefaultHasher;
impl NthHash for Defau... | code_fim | medium | {
"lang": "rust",
"repo": "sile/scalable_bloom_filter",
"path": "/src/hash.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// The default implementation of `NthHash` trait.
#[derive(Debug)]
pub struct DefaultHasher;
impl NthHash for DefaultHasher {
fn nth_hash<T: Hash + ?Sized>(&self, data: &T, nth: usize) -> u64 {
let mut hasher = SipHasher13::new();
(nth, data).hash(&mut hasher);
hasher.finis... | code_fim | medium | {
"lang": "rust",
"repo": "sile/scalable_bloom_filter",
"path": "/src/hash.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ways = c[i * j][b];
for p in 1..=i {
for q in 1..=j {
if p == i && q == j {
continue;
}
let to_del = c[i][p] * c[j][q] % MOD * f[p][q] % MOD;
ways += MO... | code_fim | hard | {
"lang": "rust",
"repo": "lucifer1004/AtCoder",
"path": "/abc242/src/bin/f.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lucifer1004/AtCoder path: /abc242/src/bin/f.rs
use proconio::input;
const MOD: usize = 998_244_353;
fn main() {
input! {
n: usize,
m: usize,
b: usize,
w: usize,
}
let mut c = vec![vec![0usize; n * m + 1]; n * m + 1];
for i in 1..=n * m {
... | code_fim | hard | {
"lang": "rust",
"repo": "lucifer1004/AtCoder",
"path": "/abc242/src/bin/f.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ans += c[n][i] * c[m][j] % MOD * f[i][j] % MOD * c[(n - i) * (m - j)][w] % MOD;
ans %= MOD;
}
}
println!("{}", ans);
}<|fim_prefix|>// repo: lucifer1004/AtCoder path: /abc242/src/bin/f.rs
use proconio::input;
const MOD: usize = 998_244_353;
fn main() {
input... | code_fim | hard | {
"lang": "rust",
"repo": "lucifer1004/AtCoder",
"path": "/abc242/src/bin/f.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.eq(other.0.as_any())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_vec() {
let form = vec![1, 2, 3];
test_round_trip(form);
}
// #[test]
// #[should_panic]
// fn test_bogus() {
// let form = (Data::new(vec![1, 2, 3]),... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp/src/data.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[derive(Debug)]
pub struct Column(Box<dyn IsVec>);
impl CheckNull for Column {
fn is_null(&self) -> bool { false }
}
impl Column {
pub fn new<T: 'static + Debug>(form: Vec<T>) -> Self where Vec<T>: IsVec {
Column(Box::new(form))
}
pub fn as_form<T: 'static + IsVec>(&self) -> Fal... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp/src/data.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RoyRin/opendp path: /rust/opendp/src/data.rs
//! Framework for flexible abstract data type model for DataFrames.
use std::any::Any;
use std::fmt::Debug;
use crate::error::*;
use crate::traits::CheckNull;
pub trait IsVec: Debug {
// Not sure if we need into_any() (which consumes the Form), ... | code_fim | hard | {
"lang": "rust",
"repo": "RoyRin/opendp",
"path": "/rust/opendp/src/data.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: return/garnet path: /bin/wlancfg/src/device.rs
// Copyright 2018 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 async;
use config::{self, Config};
use client;
use ess_store::EssStore;
use fidl... | code_fim | hard | {
"lang": "rust",
"repo": "return/garnet",
"path": "/bin/wlancfg/src/device.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> -> impl Future<Item = (), Error = Never>
{
println!("wlancfg: phy {} added", id);
let listener_ref = listener.clone();
listener
.proxy
.query_phy(&mut wlan_service::QueryPhyRequest { phy_id: id })
.and_then(move |resp| {
let (status, query_resp) = resp;... | code_fim | hard | {
"lang": "rust",
"repo": "return/garnet",
"path": "/bin/wlancfg/src/device.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let info = match query_resp {
Some(r) => r.info,
None => {
println!("wlancfg: query_phy failed to return a PhyInfo in the QueryPhyResponse");
return future::ok(()).left_future();
}
};
... | code_fim | hard | {
"lang": "rust",
"repo": "return/garnet",
"path": "/bin/wlancfg/src/device.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>ess group ID of a
/// process in the same session as the calling process.
pub fn sys_tcgetpgrp(fildes: Fd) -> SysResult<u32> {
unpreemptible_context!({
let scheduler = SCHEDULER.lock();
let fd_interface = &scheduler
.current_thread_group_running()
.file_desc... | code_fim | hard | {
"lang": "rust",
"repo": "sclolus/Turbofish",
"path": "/rust_kernel/src/taskmaster/syscall/tcgetpgrp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> calling thread is not blocking SIGTTOU, and the process is not
/// ignoring SIGTTOU.
/// [ENOTTY]
/// The calling process does not have a controlling terminal, or
/// the file is not the controlling terminal, or the controlling
/// terminal is no longer associated with the session of the... | code_fim | hard | {
"lang": "rust",
"repo": "sclolus/Turbofish",
"path": "/rust_kernel/src/taskmaster/syscall/tcgetpgrp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sclolus/Turbofish path: /rust_kernel/src/taskmaster/syscall/tcgetpgrp.rs
//! tcgetpgrp syscall
use super::scheduler::SCHEDULER;
use super::Fd;
use super::SysResult;
/// The tcgetpgrp() function shall return the value of the process
/// group ID of the foreground process group associated with th... | code_fim | hard | {
"lang": "rust",
"repo": "sclolus/Turbofish",
"path": "/rust_kernel/src/taskmaster/syscall/tcgetpgrp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danhhz/rast path: /capnp/codegen/src/golden_test.rs
// Copyright 2020 Daniel Harrison. All Rights Reserved.
use std::error::Error;
use std::fs::File;
use std::io::{self, Read, Write};
use std::path::Path;
use crate::generate::Generator;
fn read_file<P: AsRef<Path>>(path: P) -> Result<Vec<u8>,... | code_fim | medium | {
"lang": "rust",
"repo": "danhhz/rast",
"path": "/capnp/codegen/src/golden_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn golden_carsales_capnp() -> Result<(), Box<dyn Error>> {
golden_capnp("carsales")
}
#[test]
fn golden_catrank_capnp() -> Result<(), Box<dyn Error>> {
golden_capnp("catrank")
}
#[test]
fn golden_eval_capnp() -> Result<(), Box<dyn Error>> {
golden_capnp("eval")
}
#[test]
fn golden_rast_ca... | code_fim | hard | {
"lang": "rust",
"repo": "danhhz/rast",
"path": "/capnp/codegen/src/golden_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cGuille/adventofcode path: /src/bin/2020-day9-part2.rs
fn main() -> Result<(), &'static str> {
let target = 14144619; // result of part 1
let input: Vec<i64> = include_str!("../../input/2020-day9.txt")
.lines()
.map(|number| number.parse().unwrap())
.collect();
... | code_fim | hard | {
"lang": "rust",
"repo": "cGuille/adventofcode",
"path": "/src/bin/2020-day9-part2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sum == target {
let terms = &input[i..(i + j)];
println!("{}", terms.iter().min().unwrap() + terms.iter().max().unwrap());
return Ok(())
}
if sum > target {
break;
}
}
}
Err... | code_fim | hard | {
"lang": "rust",
"repo": "cGuille/adventofcode",
"path": "/src/bin/2020-day9-part2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut agent_list = HashMap::new();
for i in 0..recipe_list.len() {
agent_list.insert(recipe_list[i].output.name.name.clone(), 0);
}
agent_list.insert("ORE".to_string(), 0);
let mut fuel_count = 0;
let mut ore_count;
let mut last_list = agent_list.clone();
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "borgmanJeremy/advent_of_code_2019",
"path": "/day_14/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fuel_quantity: i64,
agent_list: &mut HashMap<String, i64>,
recipe_list: &Vec<Reaction>,
) {
*agent_list.get_mut("FUEL").unwrap() = -1 * fuel_quantity;
loop {
let mut output: &str = "";
let mut reaction_done = true;
for (key, elem) in &*agent_list {
i... | code_fim | hard | {
"lang": "rust",
"repo": "borgmanJeremy/advent_of_code_2019",
"path": "/day_14/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: borgmanJeremy/advent_of_code_2019 path: /day_14/src/main.rs
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
struct Chemical {
name: String,
}
impl Chemical {
fn new(na... | code_fim | hard | {
"lang": "rust",
"repo": "borgmanJeremy/advent_of_code_2019",
"path": "/day_14/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ce;
mod namespace_id;
mod namespace_name;
mod project;
mod project_id;
mod project_name;
mod user;
mod user_id;
mod webhook;<|fim_prefix|>// repo: Patryk27/janet path: /libs/gitlab/src/models.rs
pub use self::{
discussion_id::*,
merge_request::*,
merge_request_id::*,
merge_request_iid::*,... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/janet",
"path": "/libs/gitlab/src/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patryk27/janet path: /libs/gitlab/src/models.rs
pub use self::{
discussion_id::*,
merge_request::*,
merge_request_id::*,
merge_request_iid::*,
namespace<|fim_suffix|>ce;
mod namespace_id;
mod namespace_name;
mod project;
mod project_id;
mod project_name;
mod user;
mod user_id... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/janet",
"path": "/libs/gitlab/src/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut item_generics = self.item.generics.clone();
let mut m_generics = self.m.sig.generics.clone();
let item_where_clause = item_generics.make_where_clause();
let m_where_clause = m_generics.make_where_clause();
m_where_clause
.predicates
... | code_fim | hard | {
"lang": "rust",
"repo": "srikwit/async-trait-ext",
"path": "/src/method.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: srikwit/async-trait-ext path: /src/method.rs
use crate::method_struct_name;
use proc_macro2::Ident;
use proc_macro2::Span;
use quote::format_ident;
use std::iter::FromIterator;
use syn::punctuated::Punctuated;
use syn::token::Paren;
use syn::visit_mut::{self, VisitMut};
use syn::{
parse_quot... | code_fim | hard | {
"lang": "rust",
"repo": "srikwit/async-trait-ext",
"path": "/src/method.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Pos for (usize, usize) {
fn neighbors(&self, limit: usize) -> Vec<Self> {
let l = limit - 1;
let mut rv = Vec::with_capacity(4);
if self.0 > 0 {
rv.push((self.0 - 1, self.1));
}
if self.0 < l {
rv.push((self.0 + 1, self.1));
... | code_fim | hard | {
"lang": "rust",
"repo": "mythmon/advent-of-code",
"path": "/year2017/src/day14/part2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mythmon/advent-of-code path: /year2017/src/day14/part2.rs
use crate::day10::KnotHash;
use advent_lib::cases::{GenericPuzzleCase, PuzzleCase, PuzzleRunner};
use std::{collections::HashSet, fmt};
#[derive(Debug)]
pub struct Part2;
impl PuzzleRunner for Part2 {
type Input = &'static str;
... | code_fim | hard | {
"lang": "rust",
"repo": "mythmon/advent-of-code",
"path": "/year2017/src/day14/part2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sahwar/opal path: /crates/viewport/src/lib.rs
mod core;
mod space;
pub use crate::core::{
Buffer,
Cell
};
pub use space::{
Position,
Region,
Size
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn region_contains() {
let reg = Region::new(Size::of(5,... | code_fim | hard | {
"lang": "rust",
"repo": "sahwar/opal",
"path": "/crates/viewport/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> writer.queue(Print(cell)).unwrap();
}
writer.flush().unwrap();
std::thread::sleep(std::time::Duration::from_millis(3000));
writer.queue(crossterm::cursor::Show).unwrap();
writer.queue(LeaveAlternateScreen).unwrap();
writer.flush().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "sahwar/opal",
"path": "/crates/viewport/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::io::{
stderr,
BufWriter,
Write
};
use crossterm::{
style::Print,
terminal::{
disable_raw_mode,
enable_raw_mode,
Clear,
ClearType,
En... | code_fim | hard | {
"lang": "rust",
"repo": "sahwar/opal",
"path": "/crates/viewport/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andyyu2004/l-lang path: /tests/runner/src/main.rs
#![feature(crate_visibility_modifier)]
#![feature(once_cell)]
mod errors;
use lc_error::ErrorFormat;
use std::cell::Cell;
use std::env;
use std::error::Error;
use std::fmt::{self, Debug, Display, Formatter};
use std::fs;
use std::io;
use std::p... | code_fim | hard | {
"lang": "rust",
"repo": "andyyu2004/l-lang",
"path": "/tests/runner/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn check_test(&mut self, path: &Path, kind: TestKind) -> io::Result<()> {
match path.extension() {
Some(ext) if ext.to_str() == Some("l") => {
let errc = self.with_err_count(|this| this.run_test(&path, kind))?;
if errc > 0 {
eprin... | code_fim | hard | {
"lang": "rust",
"repo": "andyyu2004/l-lang",
"path": "/tests/runner/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// runs a function `f` and returns how many errors occured during `f`
fn with_err_count(&mut self, f: impl FnOnce(&mut Self) -> io::Result<()>) -> io::Result<usize> {
let old_errc = self.errc.get();
f(self)?;
Ok(self.errc.get() - old_errc)
}
fn run(&self, path: &P... | code_fim | hard | {
"lang": "rust",
"repo": "andyyu2004/l-lang",
"path": "/tests/runner/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let detail = detail.await?;
let history = history.await?;
let dto = InspectImageDto {
id: detail.id,
os: detail.os,
architecture: detail.architecture,
entrypoint: detail.entrypoint,
cmd: detail.cmd,
environment... | code_fim | hard | {
"lang": "rust",
"repo": "44smkn/harpoon",
"path": "/src/usecase/src/inspect_image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 44smkn/harpoon path: /src/usecase/src/inspect_image.rs
use domain::image::ImageRepository;
use std::collections::HashMap;
use std::error::Error;
pub struct InspectImageUsecase<'a> {
repository: &'a dyn ImageRepository,
}
<|fim_suffix|> pub async fn inspect_image(&self, id: impl Into<Str... | code_fim | medium | {
"lang": "rust",
"repo": "44smkn/harpoon",
"path": "/src/usecase/src/inspect_image.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct InspectImageDto {
pub id: String,
pub os: String,
pub architecture: String,
pub entrypoint: Vec<String>,
pub cmd: Vec<String>,
pub environment_variables: Vec<String>,
pub labels: HashMap<String, String>,
pub history: Vec<HistoryRecord>,
}
pub struct HistoryRecor... | code_fim | hard | {
"lang": "rust",
"repo": "44smkn/harpoon",
"path": "/src/usecase/src/inspect_image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: should complain on unknown keys
Ok(Host {
name: name.into(),
user: try!(get_str(&hash, &name, "user")),
build_dir: try!(get_str(&hash, &name, "build_dir")),
host: try!(get_optional_str(&hash, &name, "host")),
identity_file: try!(get_optional_str(&h... | code_fim | hard | {
"lang": "rust",
"repo": "briangreenery/bran-rs",
"path": "/src/lib/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let host = super::Host {
name: "hodor".into(),
user: "user".into(),
build_dir: "build_dir".into(),
host: None,
identity_file: None,
};
assert_eq!(host.git_ssh_command(), None);
}
#[test]
fn git_ssh_url() {
... | code_fim | hard | {
"lang": "rust",
"repo": "briangreenery/bran-rs",
"path": "/src/lib/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: briangreenery/bran-rs path: /src/lib/config.rs
use std::error::Error;
use std::collections::HashMap;
use std::io::Read;
use std::fs::File;
use yaml_rust::{Yaml, YamlLoader};
use yaml_rust::yaml::Hash;
#[derive(Clone, Debug)]
pub struct Host {
pub name: String,
pub user: String,
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "briangreenery/bran-rs",
"path": "/src/lib/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl System {
pub fn start(miners: i32, zones: i32, logger_level: LoggerLevel) {
println!();
let (logger_in, logger_out): (Sender<String>, Receiver<String>) = channel();
let logger_handler: JoinHandle<()> = thread::spawn(move || {
LoggerWriter::run(logger_out);
... | code_fim | medium | {
"lang": "rust",
"repo": "LaCumbancha/gold-miner",
"path": "/src/model/system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LaCumbancha/gold-miner path: /src/model/system.rs
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread::JoinHandle;
use std::thread;
<|fim_suffix|> let mut foreman: Foreman = Foreman::new(zones, Logger::new(logger_in, logger_level));
foreman.work(miners);
dr... | code_fim | hard | {
"lang": "rust",
"repo": "LaCumbancha/gold-miner",
"path": "/src/model/system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mut bip) };
if err == -1 {
eprintln!("cephes.airy: value of x too large");
}
(ai, bi, aip, bip)
}<|fim_prefix|>// repo: hfcredidio/tins path: /src/cephes.rs
mod _cephes {
extern "C" {
pub fn airy(x: f64, ai: &mut f64, aip: &mut f64, bi: &mut f64, bip: &mut f64) <|fim_middl... | code_fim | hard | {
"lang": "rust",
"repo": "hfcredidio/tins",
"path": "/src/cephes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>let mut aip = 0.0f64;
let mut bip = 0.0f64;
let err = unsafe { _cephes::airy(x, &mut ai, &mut bi, &mut aip, &mut bip) };
if err == -1 {
eprintln!("cephes.airy: value of x too large");
}
(ai, bi, aip, bip)
}<|fim_prefix|>// repo: hfcredidio/tins path: /src/cephes.rs
mod _cephes... | code_fim | medium | {
"lang": "rust",
"repo": "hfcredidio/tins",
"path": "/src/cephes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hfcredidio/tins path: /src/cephes.rs
mod _cephes {
extern "C" {
pub fn airy(x: f64, ai: &mut f64, aip: &mut f64, bi: &mut f64, bip: &mut f64) <|fim_suffix|>let mut aip = 0.0f64;
let mut bip = 0.0f64;
let err = unsafe { _cephes::airy(x, &mut ai, &mut bi, &mut aip, &mut bip) };... | code_fim | medium | {
"lang": "rust",
"repo": "hfcredidio/tins",
"path": "/src/cephes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x0f << 2)) | (((value as u32) & 0x0f) << 2);
self.w
}
}
#[doc = "Reader of field `COREBUCKHYSTTRIM`"]
pub type COREBUCKHYSTTRIM_R = crate::R<u8, u8>;
#... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo2-pac",
"path": "/src/mcuctrl/buck3.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trembel/ambiq-apollo2-pac path: /src/mcuctrl/buck3.rs
#[doc = "Reader of register BUCK3"]
pub type R = crate::R<u32, super::BUCK3>;
#[doc = "Writer for register BUCK3"]
pub type W = crate::W<u32, super::BUCK3>;
#[doc = "Register BUCK3 `reset()`'s with value 0"]
impl crate::ResetValue for super::... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo2-pac",
"path": "/src/mcuctrl/buck3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nrf-rs/nrf5340-pac path: /nrf5340-app-pac/src/pdm0_ns.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Starts continuous PDM transfer"]
pub tasks_start: crate::Reg<tasks_start::TASKS_START_SPEC>,
#[doc = "0x04 - Stops PDM transfer"]
pub tasks_st... | code_fim | hard | {
"lang": "rust",
"repo": "nrf-rs/nrf5340-pac",
"path": "/nrf5340-app-pac/src/pdm0_ns.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>ish_end::PUBLISH_END_SPEC>;
#[doc = "Publish configuration for event END"]
pub mod publish_end;
#[doc = "INTEN register accessor: an alias for `Reg<INTEN_SPEC>`"]
pub type INTEN = crate::Reg<inten::INTEN_SPEC>;
#[doc = "Enable or disable interrupt"]
pub mod inten;
#[doc = "INTENSET register accessor: an a... | code_fim | hard | {
"lang": "rust",
"repo": "nrf-rs/nrf5340-pac",
"path": "/nrf5340-app-pac/src/pdm0_ns.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>lias for `Reg<TASKS_STOP_SPEC>`"]
pub type TASKS_STOP = crate::Reg<tasks_stop::TASKS_STOP_SPEC>;
#[doc = "Stops PDM transfer"]
pub mod tasks_stop;
#[doc = "SUBSCRIBE_START register accessor: an alias for `Reg<SUBSCRIBE_START_SPEC>`"]
pub type SUBSCRIBE_START = crate::Reg<subscribe_start::SUBSCRIBE_START_S... | code_fim | hard | {
"lang": "rust",
"repo": "nrf-rs/nrf5340-pac",
"path": "/nrf5340-app-pac/src/pdm0_ns.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.last_tap_position = t1.position;
self.last_tap_time = ts;
GestureTap::None
}
TouchState::End => {
let max_distance = self.setup.max_touch_distance * self.hidpi;
let timeout = self.setup.touch_time... | code_fim | hard | {
"lang": "rust",
"repo": "KKHarmless/crayon",
"path": "/src/input/touchpad.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> last_tap_position: math::Vector2<f32>,
last_tap_time: Instant,
count: u32,
required: u32,
hidpi: f32,
setup: TouchPadSetup,
}
impl GestureTapDetector {
pub fn new(required: u32, setup: TouchPadSetup) -> Self {
GestureTapDetector {
record: TouchesRecord::de... | code_fim | hard | {
"lang": "rust",
"repo": "KKHarmless/crayon",
"path": "/src/input/touchpad.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KKHarmless/crayon path: /src/input/touchpad.rs
use std::time::{Duration, Instant};
use std::cmp::Ordering;
use application::event::{TouchEvent, TouchState};
use math;
use math::MetricSpace;
use super::MAX_TOUCHES;
/// The setup parameters of touch pad device.
///
/// Notes that the `distance`... | code_fim | hard | {
"lang": "rust",
"repo": "KKHarmless/crayon",
"path": "/src/input/touchpad.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:
:
GenericArgument
:
:
AssocType
(
ref
v
)
=
>
v
.
uses_lifetimes
(
options
lifetimes
)
syn
:
:
GenericArgument
:
:
Lifetime
(
ref
v
)
=
>
v
.
uses_lifetimes
(
options
lifetimes
)
syn
:
:
GenericArgument
:
:
Constraint
(
ref
v
)
=
>
v
.
uses_lifetimes
(
options
lifetimes
)
syn
:
:
GenericArgument
:
:
Ass... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/darling_core/src/usage/lifetimes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
(
options
lifetimes
)
Type
:
:
Paren
(
ref
v
)
=
>
v
.
uses_lifetimes
(
options
lifetimes
)
Type
:
:
Group
(
ref
v
)
=
>
v
.
uses_lifetimes
(
options
lifetimes
)
Type
:
:
TraitObject
(
ref
v
)
=
>
v
.
uses_lifetimes
(
options
lifetimes
)
Type
:
:
ImplTrait
(
ref
v
)
=
>
v
.
uses_lifetimes
(
options
lifet... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/darling_core/src/usage/lifetimes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/darling_core/src/usage/lifetimes.rs
use
fnv
:
:
FnvHashSet
;
use
syn
:
:
punctuated
:
:
Punctuated
;
use
syn
:
:
{
Lifetime
Type
}
;
use
crate
:
:
usage
:
:
Options
;
pub
type
LifetimeSet
=
FnvHashSet
<
Lifetime
>
;
pub
typ... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/darling_core/src/usage/lifetimes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_multiple_onchain_storages<H: Header<Hash = H256>, V: Decode>(
&self,
storage_hashes: Vec<Vec<u8>>,
header: &H,
) -> Result<Vec<StorageEntryVerified<V>>> {
let requests = storage_hashes
.into_iter()
.map(|key| WorkerRequest::ChainStorage(key, Some(header.hash())))
.collect();
l... | code_fim | hard | {
"lang": "rust",
"repo": "geminiest/worker",
"path": "/enclave/src/onchain/storage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geminiest/worker path: /enclave/src/onchain/storage.rs
use crate::Result;
use codec::Decode;
use sp_core::H256;
use sp_runtime::traits::Header;
use sp_std::prelude::Vec;
use substratee_ocall_api::EnclaveOnChainOCallApi;
use substratee_storage::{verify_storage_entries, Error as StorageError, Stor... | code_fim | medium | {
"lang": "rust",
"repo": "geminiest/worker",
"path": "/enclave/src/onchain/storage.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
storage_hashes: Vec<Vec<u8>>,
header: &H,
) -> Result<Vec<StorageEntryVerified<V>>>;
}
impl<O: EnclaveOnChainOCallApi> GetOnchainStorage for O {
fn get_onchain_storage<H: Header<Hash = H256>, V: Decode>(
&self,
storage_hash: Vec<u8>,
header: &H,
) -> Result<StorageEntryVerified<V>> ... | code_fim | medium | {
"lang": "rust",
"repo": "geminiest/worker",
"path": "/enclave/src/onchain/storage.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DirtGrubDylan/advent_of_code_2106 path: /rust/day_10/src/bot.rs
use std::collections::VecDeque;
use instructions::Instruction;
#[derive(Debug)]
pub struct Bot {
id: i32,
low_value: Option<i32>,
high_value: Option<i32>,
bot_instructions: VecDeque<Instruction>,
}
impl Bot {
... | code_fim | medium | {
"lang": "rust",
"repo": "DirtGrubDylan/advent_of_code_2106",
"path": "/rust/day_10/src/bot.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_high_val(&mut self) -> Option<i32> {
let high_val = self.high_value;
self.high_value = None;
high_val
}
pub fn new(id: i32) -> Bot {
Bot {
id: id,
low_value: None,
high_value: None,
bot_instructions: ... | code_fim | hard | {
"lang": "rust",
"repo": "DirtGrubDylan/advent_of_code_2106",
"path": "/rust/day_10/src/bot.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self.owned
}
}
fn main() {
assert!(impls!(Owner<String>: AsRef2<String>));
assert!(impls!(&mut Owner<String>: AsRef2<String>));
assert!(impls!(Owner<bool>: AsRef2<bool>));
assert!(impls!(&mut Owner<bool>: AsRef2<bool>));
}<|fim_prefix|>// repo: althonos/blan... | code_fim | medium | {
"lang": "rust",
"repo": "althonos/blanket",
"path": "/tests/derive_mut/successes/trait_generics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: althonos/blanket path: /tests/derive_mut/successes/trait_generics.rs
extern crate blanket;
extern crate impls;
use blanket::blanket;
use impls::impls;
<|fim_suffix|> &mut self.owned
}
}
fn main() {
assert!(impls!(Owner<String>: AsRef2<String>));
assert!(impls!(&mut Own... | code_fim | hard | {
"lang": "rust",
"repo": "althonos/blanket",
"path": "/tests/derive_mut/successes/trait_generics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(impls!(Owner<String>: AsRef2<String>));
assert!(impls!(&mut Owner<String>: AsRef2<String>));
assert!(impls!(Owner<bool>: AsRef2<bool>));
assert!(impls!(&mut Owner<bool>: AsRef2<bool>));
}<|fim_prefix|>// repo: althonos/blanket path: /tests/derive_mut/successes/trait_... | code_fim | medium | {
"lang": "rust",
"repo": "althonos/blanket",
"path": "/tests/derive_mut/successes/trait_generics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for number in (1..4).rev() {
println!("{}!", number);
}
println!("LIFTOFF!!!");
}<|fim_prefix|>// repo: jetbrains-academy/rustlings-course path: /Common Programming Concepts/Repetitions/Looping through Ranges/src/main.rs
fn main() {
for number in 1..5 { // 5 is excluded
pr... | code_fim | medium | {
"lang": "rust",
"repo": "jetbrains-academy/rustlings-course",
"path": "/Common Programming Concepts/Repetitions/Looping through Ranges/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jetbrains-academy/rustlings-course path: /Common Programming Concepts/Repetitions/Looping through Ranges/src/main.rs
fn main() {
for number in 1..5 { // 5 is excluded
println!("{}", number);
}
<|fim_suffix|> for number in (1..4).rev() {
println!("{}!", number);
}
... | code_fim | medium | {
"lang": "rust",
"repo": "jetbrains-academy/rustlings-course",
"path": "/Common Programming Concepts/Repetitions/Looping through Ranges/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut words: Vec<String> = text_to_decode.split_whitespace().map(|s| s.to_string()).collect();
let mut result: String = "WRONG MESSAGE".to_string();
for _ in 0..alphabets.len() {
if words.contains(&"CHIEF".to_string()) {
result = words.join(" ");
break;
... | code_fim | medium | {
"lang": "rust",
"repo": "jz4o/codingames",
"path": "/rust/practice/classic_puzzle/easy/caesar-is-the-chief.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jz4o/codingames path: /rust/practice/classic_puzzle/easy/caesar-is-the-chief.rs
use std::io;
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem stat... | code_fim | hard | {
"lang": "rust",
"repo": "jz4o/codingames",
"path": "/rust/practice/classic_puzzle/easy/caesar-is-the-chief.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> publish_module(origin, &modules::user::STORE, None).unwrap();
const EXPECTED: u64 = 3;
for _ in 0..EXPECTED {
roll_next_block();
}
execute_tx(origin, &transactions::STORE_SYSTEM_TIMESTAMP, None).unwrap();
check_stored_value(EXPECTED * TIME_BLOCK... | code_fim | hard | {
"lang": "rust",
"repo": "borispovod/pontem",
"path": "/pallets/sp-mvm/tests/tx-ctx.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: borispovod/pontem path: /pallets/sp-mvm/tests/tx-ctx.rs
use serde::Deserialize;
use move_core_types::identifier::Identifier;
use move_core_types::language_storage::StructTag;
mod common;
use common::assets::{modules, transactions};
use common::mock::*;
use common::addr::*;
use common::utils::*;... | code_fim | hard | {
"lang": "rust",
"repo": "borispovod/pontem",
"path": "/pallets/sp-mvm/tests/tx-ctx.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> const EXPECTED: u64 = 3;
for _ in 0..EXPECTED {
roll_next_block();
}
execute_tx(origin, &transactions::STORE_SYSTEM_BLOCK, None).unwrap();
check_stored_value(EXPECTED);
});
}
#[test]
fn execute_store_time() {
new_test_ext().execute_with(|| {
... | code_fim | medium | {
"lang": "rust",
"repo": "borispovod/pontem",
"path": "/pallets/sp-mvm/tests/tx-ctx.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn handle(&mut self, event: PublishMessage, _ctx: &mut Self::Context) {
if let Some(endpoint_sockets) = self.clients.get(&event.endpoint) {
for (_, addr) in endpoint_sockets {
addr.do_send(WebsockeMessageEvent {
message: event.message.clone(),
});
}
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "perfectmak/sockethook-rust",
"path": "/src/app_data.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: perfectmak/sockethook-rust path: /src/app_data.rs
use uuid::Uuid;
use std::collections::HashMap;
use actix::prelude::*;
use crate::websocket::{WebsocketConnection, WebsockeMessageEvent, WebsocketState};
#[derive(Message)]
pub struct RegisterConnection {
pub id: Uuid,
pub endpoint: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "perfectmak/sockethook-rust",
"path": "/src/app_data.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ewohltman/wordcount path: /wordcount-core/src/lib.rs
pub mod args;
pub mod config;
pub use crate::args::*;
pub use crate::config::Config;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt;
#[derive(Debug)]
pub struct WordCount {
pub total: usize,
pub lines: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "ewohltman/wordcount",
"path": "/wordcount-core/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const EXPECTED_FORMAT: &str = "\ttest3: 3\n\ttest2: 2\n\ttest1: 1\n";
let word_count = WordCount {
total: 0,
lines: 0,
unique_words: vec![
(String::from("test3"), 3),
(String::from("test2"), 2),
(String::f... | code_fim | hard | {
"lang": "rust",
"repo": "ewohltman/wordcount",
"path": "/wordcount-core/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut vec: Vec<(String, u32)> = hash_map
.iter()
.map(|x| (String::from(*x.0), *x.1))
.collect();
vec.sort_by(|a, b| compare(a.1, b.1));
vec
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_wordcount_format_unique_words() {
const EXPECT... | code_fim | hard | {
"lang": "rust",
"repo": "ewohltman/wordcount",
"path": "/wordcount-core/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn map_request_unary<B>(
&mut self,
request: http::Request<B>,
) -> Result<Request<T::Decode>, Status>
where
B: Body + Send + 'static,
B::Error: Into<crate::Error> + Send,
{
#[cfg(feature = "compression")]
let request_compression_encodi... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tonic/src/server/grpc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set the content type
parts.headers.insert(
http::header::CONTENT_TYPE,
http::header::HeaderValue::from_static("application/grpc"),
);
#[cfg(feature = "compression")]
if let Some(encoding) = accept_encoding {
// Set the content... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tonic/src/server/grpc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bmwill/tonic path: /tonic/src/server/grpc.rs
#[cfg(feature = "compression")]
use crate::codec::compression::{
CompressionEncoding, EnabledCompressionEncodings, SingleMessageCompressionOverride,
};
use crate::{
body::BoxBody,
codec::{encode_server, Codec, Streaming},
server::{Clie... | code_fim | hard | {
"lang": "rust",
"repo": "bmwill/tonic",
"path": "/tonic/src/server/grpc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mr = K::mr();
(self.co + mr - 1) / mr * mr * self.k
}
fn pack_a(&self, pa: *mut T, a: *const T, rsa: isize, csa: isize) {
let mr = K::mr();
assert!(pa as usize % K::alignment_bytes_a() == 0);
unsafe {
for p in 0..(self.co / mr) {
... | code_fim | hard | {
"lang": "rust",
"repo": "dmaniry/tract",
"path": "/linalg/src/frame/conv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.k
}
}
#[cfg(test)]
pub mod test {
use super::*;
use crate::align;
use proptest::prelude::*;
#[derive(Clone, Debug)]
pub struct ConvProblem {
pub ci: usize,
pub co: usize,
pub kt: usize,
pub stride: usize,
pub dilation: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "dmaniry/tract",
"path": "/linalg/src/frame/conv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmaniry/tract path: /linalg/src/frame/conv.rs
use num_traits::Zero;
use std::fmt::Debug;
use std::ops::{Add, Mul};
use std::marker::PhantomData;
pub trait Conv<T: Copy + Add + Mul + Zero + Debug>: Send + Sync + Debug + objekt::Clone {
fn packed_a_len(&self) -> usize;
fn packed_a_alignm... | code_fim | hard | {
"lang": "rust",
"repo": "dmaniry/tract",
"path": "/linalg/src/frame/conv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn dot() {
assert_eq!(
sparse(&extract(".")),
vec![
b'\n', 192, 193, 245, 246, 247, 248, 249, 250, 251, 252, 253,
254, 255,
]
);
assert_eq!(
sparse(&extract("(?s).")),
vec![
... | code_fim | hard | {
"lang": "rust",
"repo": "codeslangers/ripgrep",
"path": "/crates/regex/src/non_matching.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: codeslangers/ripgrep path: /crates/regex/src/non_matching.rs
use grep_matcher::ByteSet;
use regex_syntax::hir::{self, Hir, HirKind};
use regex_syntax::utf8::Utf8Sequences;
/// Return a confirmed set of non-matching bytes from the given expression.
pub fn non_matching_bytes(expr: &Hir) -> ByteSe... | code_fim | hard | {
"lang": "rust",
"repo": "codeslangers/ripgrep",
"path": "/crates/regex/src/non_matching.rs",
"mode": "psm",
"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.