text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconstwotone/social/icon_catching_pokemon.rs
pub struct IconCatchingPokemon {
props: crate::Props,
}
impl yew::Component for IconCatchingPokemon {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properti... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconstwotone/social/icon_catching_pokemon.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lquerel/gcp-ml-client path: /src/model/google_cloud_ml_v1_prediction_output.rs
//! Represents results of a prediction job.
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GoogleCloudMlV1__PredictionOutput {
/// Node hours used by the batch prediction job.... | code_fim | medium | {
"lang": "rust",
"repo": "lquerel/gcp-ml-client",
"path": "/src/model/google_cloud_ml_v1_prediction_output.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ions.
pub prediction_count: Option<i64>,
/// The number of data instances which resulted in errors.
pub error_count: Option<i64>,
}<|fim_prefix|>// repo: lquerel/gcp-ml-client path: /src/model/google_cloud_ml_v1_prediction_output.rs
//! Represents results of a prediction job.
#[derive(Debug, Serializ... | code_fim | medium | {
"lang": "rust",
"repo": "lquerel/gcp-ml-client",
"path": "/src/model/google_cloud_ml_v1_prediction_output.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tg-rs/tgbot path: /src/methods/webhook/delete.rs
use crate::{methods::Method, request::Request};
use serde::Serialize;
/// Remove webhook integration if you decide to switch back to getUpdates
///
/// Returns True on success
#[derive(Clone, Copy, Debug, Default, Serialize)]
pub struct DeleteWeb... | code_fim | hard | {
"lang": "rust",
"repo": "tg-rs/tgbot",
"path": "/src/methods/webhook/delete.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let request = DeleteWebhook::default().into_request();
assert_eq!(request.get_method(), RequestMethod::Get);
assert_eq!(
request.build_url("base-url", "token"),
"base-url/bottoken/deleteWebhook"
);
match request.into_body() {
Requ... | code_fim | hard | {
"lang": "rust",
"repo": "tg-rs/tgbot",
"path": "/src/methods/webhook/delete.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Translation::Expand(&self.systems)
}
/// Copy one directory to another.
pub fn apply<E>(&self, _: SystemInput<E>) -> Result<Vec<SystemUnit>, Error>
where
E: Copy + e::Environment,
{
bail!("Cannot apply only-for systems");
}
}
impl fmt::Display for OnlyFor ... | code_fim | hard | {
"lang": "rust",
"repo": "udoprog/quickcfg",
"path": "/src/system/only_for.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for OnlyFor {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "conditionally run for (os: {:?})", self.os)
}
}<|fim_prefix|>// repo: udoprog/quickcfg path: /src/system/only_for.rs
use crate::{
environment as e,
system::{System, SystemInput, S... | code_fim | hard | {
"lang": "rust",
"repo": "udoprog/quickcfg",
"path": "/src/system/only_for.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: udoprog/quickcfg path: /src/system/only_for.rs
use crate::{
environment as e,
system::{System, SystemInput, SystemUnit, Translation},
};
use anyhow::{bail, Error};
use std::fmt;
<|fim_suffix|> Translation::Expand(&self.systems)
}
/// Copy one directory to another.
pu... | code_fim | hard | {
"lang": "rust",
"repo": "udoprog/quickcfg",
"path": "/src/system/only_for.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Noah2610/LD43-NihilisticNurtureNavigation path: /src/interactables/one_way.rs
use ggez::{
Context,
GameResult
};
use noframe::geo::prelude::*;
use noframe::entity::prelude::*;
use animation::Animation;
use animation::Facing;
use super::Interactable;
use super::animations::one_way;
use pers... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/LD43-NihilisticNurtureNavigation",
"path": "/src/interactables/one_way.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.state {
State::Main => &self.animations.main
}
}
fn animation_mut(&mut self) -> &mut Animation {
match self.state {
State::Main => &mut self.animations.main,
}
}
}
impl Mask for OneWay {
fn point(&self) -> &Point { &self.point }
fn point_mut(&mut ... | code_fim | hard | {
"lang": "rust",
"repo": "Noah2610/LD43-NihilisticNurtureNavigation",
"path": "/src/interactables/one_way.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Agents {
num_agents,
household_container,
occupational_container: workplace_container,
disease_statuses: disease::construct_disease_status_array(num_agents, &mut rng),
}
}
}<|fim_prefix|>// repo: Alfred-Mountfield/outbreak-sim path: /src... | code_fim | hard | {
"lang": "rust",
"repo": "Alfred-Mountfield/outbreak-sim",
"path": "/src/agents/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alfred-Mountfield/outbreak-sim path: /src/agents/mod.rs
use nonmax::NonMaxU64;
use rand::thread_rng;
use crate::containers::Containers;
use crate::disease;
use crate::disease::{DiseaseStatus, MixingStrategy};
use crate::flatbuffer::Model;
#[derive(Clone)]
pub struct Agents {
pub num_agents... | code_fim | hard | {
"lang": "rust",
"repo": "Alfred-Mountfield/outbreak-sim",
"path": "/src/agents/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = thread_rng();
let num_agents = household_indices.len() as u32;
let (household_container, workplace_container) = household_indices.iter().zip(workplace_indices.iter())
.enumerate().map(|(agent_idx, (household_idx, workplace_idx))| {
let househo... | code_fim | hard | {
"lang": "rust",
"repo": "Alfred-Mountfield/outbreak-sim",
"path": "/src/agents/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl CommandExt for Command {
#[cfg(unix)]
fn map_user_group(&mut self) -> Result<&mut Self, Error> {
use std::os::unix::fs::MetadataExt;
let gid = std::fs::metadata(DOCKER_SOCKET)?.gid();
let uid = nix::unistd::Uid::effective();
self.arg("--user").arg(format!("... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/rustwide",
"path": "/tests/buildtest/inside_docker.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let out = self.output()?;
if !out.status.success() {
eprintln!("failed to execute command {:?}", self);
eprintln!("stdout:");
std::io::stderr().lock().write_all(&out.stdout)?;
eprintln!("stderr:");
std::io::stderr().lock().write_a... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/rustwide",
"path": "/tests/buildtest/inside_docker.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/rustwide path: /tests/buildtest/inside_docker.rs
#![cfg_attr(windows, allow(unused))]
use failure::{Error, ResultExt};
use std::io::Write;
use std::path::Path;
use std::process::Command;
static DOCKER_IMAGE_TAG: &str = "ghcr.io/rust-lang/crates-build-env/linux-micro";
static DOCK... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/rustwide",
"path": "/tests/buildtest/inside_docker.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
$( #[cfg(not(loom))] $item )*
}
}<|fim_prefix|>// repo: phlip9/queue_experiments path: /src/macros.rs
macro_rules! cfg_loom {
($($item:item)*) =><|fim_middle|> {
$( #[cfg(loom)] $item )*
}
}
macro_rules! cfg_not_loom {
($($item:item)*) => | code_fim | medium | {
"lang": "rust",
"repo": "phlip9/queue_experiments",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ro_rules! cfg_not_loom {
($($item:item)*) => {
$( #[cfg(not(loom))] $item )*
}
}<|fim_prefix|>// repo: phlip9/queue_experiments path: /src/macros.rs
macro_rules! cfg_loom {
($($item:item)*) =><|fim_middle|> {
$( #[cfg(loom)] $item )*
}
}
mac | code_fim | easy | {
"lang": "rust",
"repo": "phlip9/queue_experiments",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: phlip9/queue_experiments path: /src/macros.rs
macro_rules! cfg_loom {
($($item:item)*) => {
$( #[cfg(loom)] $item )*
}
}
mac<|fim_suffix|> {
$( #[cfg(not(loom))] $item )*
}
}<|fim_middle|>ro_rules! cfg_not_loom {
($($item:item)*) => | code_fim | easy | {
"lang": "rust",
"repo": "phlip9/queue_experiments",
"path": "/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[init()]
fn init() -> init::LateResources {
// Cortex-M peripherals
let _core: rtfm::Peripherals = core;
// Device specific peripherals
let _device: stm32f0::stm32f0x0::Peripherals = device;
// Start SysTick
// Initialise GPIO
let rcc = _d... | code_fim | hard | {
"lang": "rust",
"repo": "davidlenfesty/tetanus",
"path": "/testing/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidlenfesty/tetanus path: /testing/src/main.rs
//! examples/init.rs
// I just don't know how to modify the TIM1 ARR with this
//#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate panic_semihosting;
extern crate stm32f030_hal;
use cortex_m_semihosting::hprintln;
use... | code_fim | hard | {
"lang": "rust",
"repo": "davidlenfesty/tetanus",
"path": "/testing/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AliAryanTech/rust-tg-bot path: /src/types/order_info.rs
use crate::types::{ShippingAddress, User};
<|fim_suffix|>#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct OrderInfo {
/// Optional. User name
pub name: Option<String>,
/// Optional. User's phone number
pub phone_n... | code_fim | easy | {
"lang": "rust",
"repo": "AliAryanTech/rust-tg-bot",
"path": "/src/types/order_info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct OrderInfo {
/// Optional. User name
pub name: Option<String>,
/// Optional. User's phone number
pub phone_number: Option<String>,
/// Optional. User email
pub email: Option<String>,
/// Optional. User shipping address
... | code_fim | easy | {
"lang": "rust",
"repo": "AliAryanTech/rust-tg-bot",
"path": "/src/types/order_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnbcoughlin/galerkin-rs path: /galerkin/src/plot/glium.rs
extern crate glium;
extern crate rand;
use std::f32;
use std::sync::mpsc::{self, Sender};
use std::thread;
use glium::{glutin, Surface};
use crate::distmesh::mesh::{Mesh, Point2D};
pub struct OpenGLPlot {
mesh: Mesh,
display... | code_fim | hard | {
"lang": "rust",
"repo": "johnbcoughlin/galerkin-rs",
"path": "/galerkin/src/plot/glium.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (sender, receiver) = mpsc::channel();
thread::spawn(move || f(sender));
let mut closed = false;
while !closed {
// block on receiving values to plot
let values = receiver.recv().unwrap();
// plot the values
plot.plot(values);
// maybe close t... | code_fim | hard | {
"lang": "rust",
"repo": "johnbcoughlin/galerkin-rs",
"path": "/galerkin/src/plot/glium.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: broot5/representative_value path: /src/main.rs
use std::collections::HashMap;
fn main() {
let v = vec![30, 92, 100, 53, 42, 60, 49]; // just random number
let average = get_average(&v);
let median = get_median(&v);
let mode = get_mode(&v);
println!("{} {} {:?}", average, me... | code_fim | hard | {
"lang": "rust",
"repo": "broot5/representative_value",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut score: HashMap<i32, i32> = HashMap::new();
for numbers in vec {
let count = score.entry(*numbers).or_insert(0);
*count += 1;
}
let max_value = score.values().cloned().max().unwrap();
score
.into_iter()
.filter(|&(_, v)| v == max_value)
... | code_fim | medium | {
"lang": "rust",
"repo": "broot5/representative_value",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrey-yantsen/plex-api.rs path: /crates/plex-api/src/webhook/mod.rs
//! This module contains a few structs that should help you handle the webhooks
//! received from a Plex server.
//!
//! The structs are implemented according to the [documentation](https://support.plex.tv/articles/115002267687... | code_fim | hard | {
"lang": "rust",
"repo": "andrey-yantsen/plex-api.rs",
"path": "/crates/plex-api/src/webhook/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(not(feature = "tests_deny_unknown_fields"))]
#[serde(other)]
Unknown,
}
#[cfg(test)]
mod test {
#[plex_api_test_helper::offline_test]
fn check_parsing() {
serde_json::from_str::<super::Webhook>(WEBHOOK_JSON).expect("failed to parse webhook");
}
const WEBHOOK_JSO... | code_fim | hard | {
"lang": "rust",
"repo": "andrey-yantsen/plex-api.rs",
"path": "/crates/plex-api/src/webhook/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: h4sh3d/mdbook-api path: /src/api/mod.rs
//! HTML API renderer
//!
//! An HTML renderer is a basic, extensible Markdown to HTML renderer
//! engine for `mdbook`.
use crate::engine::Engine;
use crate::template::Template;
use crate::theme::Theme;
use std::fs;
use mdbook::errors::Result;
use mdbo... | code_fim | hard | {
"lang": "rust",
"repo": "h4sh3d/mdbook-api",
"path": "/src/api/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for item in book.iter() {
html_ctx.book_item = Some(item.clone());
let mut data = self.engine.process_chapter(&ctx, &mut html_ctx)?;
self.template
.render_chapter(&ctx, &self.theme, &mut html_ctx, &mut data)?;
html_ctx.is_index = f... | code_fim | hard | {
"lang": "rust",
"repo": "h4sh3d/mdbook-api",
"path": "/src/api/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_corrected(ops: &[Op]) -> Option<i32> {
let mut cur_op = 0;
let mut acc = 0;
let mut out = None;
while out.is_none() {
match ops[cur_op] {
Op::NOP(0) => cur_op = cur_op + 1,
Op::NOP(n) => {
if let ProgResult::TerminatedCorrectly(x) = r... | code_fim | hard | {
"lang": "rust",
"repo": "enetsee/advent_of_code_2020",
"path": "/day8/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let final_op = ops.len();
let mut cur_op = pos;
let mut acc = acc_in;
let mut seen: HashSet<usize> = HashSet::new();
while !seen.contains(&cur_op) && cur_op < final_op {
seen.insert(cur_op);
match ops[cur_op] {
Op::NOP(_) => cur_op = cur_op + 1,
... | code_fim | hard | {
"lang": "rust",
"repo": "enetsee/advent_of_code_2020",
"path": "/day8/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: enetsee/advent_of_code_2020 path: /day8/src/main.rs
use std::collections::HashSet;
use std::fs::File;
use std::io::{self, BufRead, BufReader, ErrorKind};
fn main() {
let f = File::open("input.txt").unwrap();
let ops = BufReader::new(f)
.lines()
.map(|res| res.and_then(|st... | code_fim | hard | {
"lang": "rust",
"repo": "enetsee/advent_of_code_2020",
"path": "/day8/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = "( \"Hello world1234 + \" + \"bye123\" )";
let mut lexer = Lexer::new();
assert_eq!(lexer.parse_string(s), Ok(()));
let variable_result: VecDeque<Exp> = vec![Exp::Lit(Lit::Str("Hello world1234 + "
.to_owned())),... | code_fim | hard | {
"lang": "rust",
"repo": "DarinM223/yamlate",
"path": "/src/lexer/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DarinM223/yamlate path: /src/lexer/mod.rs
mod token_builder;
use ast::{Exp, Lit};
use errors::{LexError, YamlError};
use lexer::token_builder::append_ch;
use std::collections::VecDeque;
#[derive(Clone, PartialEq)]
pub enum WordState {
Variable,
Number,
Decimal,
String,
Oper... | code_fim | hard | {
"lang": "rust",
"repo": "DarinM223/yamlate",
"path": "/src/lexer/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*Return the adler32 of the bytes data[0..len-1]*/
pub(super) fn adler32(data: &[u8]) -> u32 {
update_adler32(1, data)
}<|fim_prefix|>// repo: DougLau/png_pong path: /src/lodepng/rustimpl/adler32.rs
// PNG Pong
//
// Copyright © 2019-2020 Jeron Aldaron Lau
// Copyright © 2014-2017 Kornel Lesiński
// ... | code_fim | hard | {
"lang": "rust",
"repo": "DougLau/png_pong",
"path": "/src/lodepng/rustimpl/adler32.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DougLau/png_pong path: /src/lodepng/rustimpl/adler32.rs
// PNG Pong
//
// Copyright © 2019-2020 Jeron Aldaron Lau
// Copyright © 2014-2017 Kornel Lesiński
// Copyright © 2005-2016 Lode Vandevenne
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// https://apache.org/licen... | code_fim | medium | {
"lang": "rust",
"repo": "DougLau/png_pong",
"path": "/src/lodepng/rustimpl/adler32.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Catamondium/projects path: /Rust/mol/src/lib.rs
extern crate regex;
use regex::Regex;
use std::error;
use std::fmt;
#[macro_use]
extern crate lazy_static;
use std::collections::HashMap;
type TransTable = HashMap<char, char>;
type Ptable = HashMap<String, f32>;
#[cfg(test)]
mod tests {
us... | code_fim | hard | {
"lang": "rust",
"repo": "Catamondium/projects",
"path": "/Rust/mol/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn source(&self) -> Option<&(dyn error::Error + 'static)> {
None
}
}
fn make_coeff(src: std::option::Option<regex::Match<'_>>) -> f32 {
if let Some(coeff) = src {
return coeff.as_str().parse::<f32>().unwrap_or(1.0);
} else {
1.0
}
}
fn load_table() -> Ptable {... | code_fim | hard | {
"lang": "rust",
"repo": "Catamondium/projects",
"path": "/Rust/mol/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> out.insert(
fields[0].to_string(),
fields[1]
.parse::<f32>()
.expect(&format!("Table error: bad float at {}", fields[0])),
);
}
out.shrink_to_fit();
out
}
fn trans(from: &str, to: &str) -> TransTable {
from.chars().z... | code_fim | hard | {
"lang": "rust",
"repo": "Catamondium/projects",
"path": "/Rust/mol/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LeonLi000/force-bridge-eth path: /ckb-contracts/lib/eth-bridge-typescript-lib/src/test.rs
use crate::_verify;
use crate::adapter::*;
use ckb_std::ckb_constants::Source;
use ckb_std::ckb_types::prelude::Pack;
use ckb_std::ckb_types::{
bytes::Bytes,
packed::{self, Script, WitnessArgs},
};
... | code_fim | hard | {
"lang": "rust",
"repo": "LeonLi000/force-bridge-eth",
"path": "/ckb-contracts/lib/eth-bridge-typescript-lib/src/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let adapter = ChainAdapter { chain: mock };
_verify(adapter);
}
#[test]
#[should_panic(expected = "not authorized to unlock the cell")]
fn test_manage_mode_when_lock_script_not_exist_in_inputs() {
let mut mock = generate_manage_mode_correct_mock();
let invalid_owner_script = Script::new... | code_fim | hard | {
"lang": "rust",
"repo": "LeonLi000/force-bridge-eth",
"path": "/ckb-contracts/lib/eth-bridge-typescript-lib/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gdk4/src/cairo_interaction.rs
// Take a look at the license at the top of the repository in the LICENSE file.
use crate::{Rectangle, Surface, RGBA};
use cairo::{Context, Region};
use gdk_pixbuf::Pixbuf;
use glib::translate::*;
// rustdoc-stripper-ignore-next
/// Trait co... | code_fim | hard | {
"lang": "rust",
"repo": "zecakeh/gtk4-rs",
"path": "/gdk4/src/cairo_interaction.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl GdkCairoContextExt for Context {
unsafe fn draw_from_gl(
&self,
surface: &Surface,
source: i32,
source_type: i32,
buffer_scale: i32,
x: i32,
y: i32,
width: i32,
height: i32,
) {
skip_assert_initialized!();
... | code_fim | hard | {
"lang": "rust",
"repo": "zecakeh/gtk4-rs",
"path": "/gdk4/src/cairo_interaction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn validate_ecl(v: &String) -> bool {
match v.as_str() {
"amb" | "blu" | "brn" | "gry" | "grn" | "hzl" | "oth" => true,
_ => false,
}
}
fn validate_pid(v: &String) -> bool {
let v = v.as_bytes();
let range = b'0'..=b'9';
v.len() == 9 && v.iter().all(|b| range.contains(... | code_fim | hard | {
"lang": "rust",
"repo": "alanbriolat/AdventOfCode2020",
"path": "/src/solutions/day04.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_input(input_path: PathBuf) -> crate::Result<Vec<Passport>> {
let mut output: Vec<Passport> = Vec::new();
let mut current: Vec<(String, String)> = Vec::new();
fn finalise(current: &mut Vec<(String, String)>, output: &mut Vec<Passport>) {
if current.len() > 0 {
let p... | code_fim | hard | {
"lang": "rust",
"repo": "alanbriolat/AdventOfCode2020",
"path": "/src/solutions/day04.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alanbriolat/AdventOfCode2020 path: /src/solutions/day04.rs
use std::collections::HashMap;
use std::ops::RangeInclusive;
use std::str::FromStr;
use super::prelude::*;
use crate::util;
#[allow(dead_code)]
const EXPECTED_FIELDS: &'static [&'static str] =
&["byr", "iyr", "eyr", "hgt", "hcl", "... | code_fim | hard | {
"lang": "rust",
"repo": "alanbriolat/AdventOfCode2020",
"path": "/src/solutions/day04.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut fd = File::create(&out_path).unwrap();
fd.write_all(contents.as_bytes()).unwrap();
}<|fim_prefix|>// repo: AVakulchik/ascii-art-generator path: /config/build.rs
use std::env;
use std::fs::File;
use std::io::{Read, Write};
use std::path::Path;
fn main() {
let out_dir = env::var("OUT_D... | code_fim | hard | {
"lang": "rust",
"repo": "AVakulchik/ascii-art-generator",
"path": "/config/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AVakulchik/ascii-art-generator path: /config/build.rs
use std::env;
use std::fs::File;
use std::io::{Read, Write};
use std::path::Path;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let config_path = Path::new("config");
let builder = config_path.join("build.rs");
let ... | code_fim | hard | {
"lang": "rust",
"repo": "AVakulchik/ascii-art-generator",
"path": "/config/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self
}
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
}
/// # Button
///
/// A button component. It implements a label struct as a child.
/// All buttons run through the event handler (not the user defined one),
/// so inputs are registered.
///
/// The button also contai... | code_fim | hard | {
"lang": "rust",
"repo": "dimitri-br/rusty_gui",
"path": "/src/components/base_components.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimitri-br/rusty_gui path: /src/components/base_components.rs
//! This module defines base components provided for the user
//! It includes labels, images and buttons.
//! There is also a trait provided that will allow users to define custom components,
//! so that the crate remains as modular a... | code_fim | hard | {
"lang": "rust",
"repo": "dimitri-br/rusty_gui",
"path": "/src/components/base_components.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokio-rs/tracing path: /tracing-subscriber/benches/reload.rs
#![cfg(feature = "env-filter")]
use criterion::{criterion_group, criterion_main, Criterion};
use tracing_subscriber::{
filter::LevelFilter,
fmt::{
format::{DefaultFields, Format, Full},
Collector, CollectorBuild... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/tracing",
"path": "/tracing-subscriber/benches/reload.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Collector::builder()
.with_env_filter(filter)
.with_writer(NoWriter::new as _)
.with_ansi(true)
.with_target(true)
.with_level(true)
.with_thread_names(true)
}
fn bench_reload(c: &mut Criterion) {
let mut group = c.benchmark_group("reload");
gro... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/tracing",
"path": "/tracing-subscriber/benches/reload.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match coin {
Coin::Dollar => 6,
Coin::Penny => 1,
Coin::Nickel => 5,
Coin::Dime => 10,
Coin::Quarter => 25,
}
}<|fim_prefix|>// repo: Naruto-1996/rust_learnings path: /src/enum_learning.rs
enum IpAddrKind {
V4,
V6,
}
enum Coin {
Dollar,
Pen... | code_fim | easy | {
"lang": "rust",
"repo": "Naruto-1996/rust_learnings",
"path": "/src/enum_learning.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Naruto-1996/rust_learnings path: /src/enum_learning.rs
enum IpAddrKind {
V4,
V6,
}
enum Coin {
Dollar,
Penny,
Nickel,
Dime,
Quarter,
}
pub fn enum_learning_test() {
let dollar = Coin::Dollar;
let coin_value = value_in_cents(dollar);
println!("dollar is va... | code_fim | easy | {
"lang": "rust",
"repo": "Naruto-1996/rust_learnings",
"path": "/src/enum_learning.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snow2flying/ostrich path: /cli/src/main.rs
use async_std::future::timeout;
use async_std::net::UdpSocket;
use async_std::task;
use bytes::BytesMut;
use clap::{crate_version, FromArgMatches, IntoApp};
use std::time::Duration;
use command::{build_cmd,opt::Opt};
use service::register::handler::{Re... | code_fim | hard | {
"lang": "rust",
"repo": "snow2flying/ostrich",
"path": "/cli/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", table);
}
ResponseEntity::Server(_) => {}
ResponseEntity::Status => {}
}
}else{
table
.set_header(vec!["Status"... | code_fim | hard | {
"lang": "rust",
"repo": "snow2flying/ostrich",
"path": "/cli/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Debug, Serialize, Deserialize)]
struct Sample {
f: f64,
s: String,
dt: SystemTime,
arr: Vec<i64>,
}
#[test]
fn json_test() {
let raw_json = r#"{
"f": 12.2,
"s": "something",
"dt": "2002-10-02T10:00:00-... | code_fim | hard | {
"lang": "rust",
"repo": "tacogips/firestore-rs",
"path": "/firestore/src/firestore/value/fvalue/json_conv.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tacogips/firestore-rs path: /firestore/src/firestore/value/fvalue/json_conv.rs
use super::FValue;
use anyhow::Result;
use chrono::{offset::Utc, DateTime};
use serde_json::{Map as JMap, Number as JNumber, Value as JValue};
use std::collections::HashMap;
use std::iter::FromIterator;
use std::time:... | code_fim | hard | {
"lang": "rust",
"repo": "tacogips/firestore-rs",
"path": "/firestore/src/firestore/value/fvalue/json_conv.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::super::FValue;
use crate::firestore::value::fvalue::from_fvalue;
use serde::{Deserialize, Serialize};
use serde_json;
use serde_json::{Map as JMap, Number as JNumber, Value as JValue};
use std::time::SystemTime;
#[derive(Debug, Serialize, De... | code_fim | hard | {
"lang": "rust",
"repo": "tacogips/firestore-rs",
"path": "/firestore/src/firestore/value/fvalue/json_conv.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Predicate {
pub fn from_compare(compare: &BinaryCompare) -> Predicate {
Predicate {
left: box Expression::Compare(compare.clone()),
right: None,
operation: Operation::And,
}
}
pub fn one_variable_comparisons(&self) -> Vec<BinaryCompare>... | code_fim | hard | {
"lang": "rust",
"repo": "angelini/rocksql",
"path": "/src/predicate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: angelini/rocksql path: /src/predicate.rs
use base::*;
#[derive(Clone)]
pub enum Comparator {
Equal,
NotEqual,
GreaterThan,
GreaterThanOrEqual,
LessThan,
LessThanOrEqual,
}
#[derive(Clone)]
pub enum ExpressionValue {
Constant(Type, Vec<u8>),
Symbol(String),
}
#[... | code_fim | hard | {
"lang": "rust",
"repo": "angelini/rocksql",
"path": "/src/predicate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daniel-vainsencher/rust-ndarray path: /src/impl_linalg.rs
// Copyright 2014-2016 bluss and ndarray developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licens... | code_fim | hard | {
"lang": "rust",
"repo": "daniel-vainsencher/rust-ndarray",
"path": "/src/impl_linalg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature="blas")]
#[inline(always)]
/// Return `true` if `A` and `B` are the same type
fn same_type<A: Any, B: Any>() -> bool {
TypeId::of::<A>() == TypeId::of::<B>()
}
#[cfg(feature="blas")]
// Read pointer to type `A` as type `B`.
//
// **Panics** if `A` and `B` are not the same type
fn cast_a... | code_fim | hard | {
"lang": "rust",
"repo": "daniel-vainsencher/rust-ndarray",
"path": "/src/impl_linalg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> StdRng::seed_from_u64(seed_val);
let mut ok = 0;
for _ in 0..number {
if associativity_test(config) {
ok += 1;
}
}
ok * 100 / number
}
fn main() {
let opt = Opt::from_args();
let config = Config {
error_margin: opt.error_margin,
};
... | code_fim | hard | {
"lang": "rust",
"repo": "FAMILIAR-project/reproducibility-associativity",
"path": "/src_rst/testassoc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FAMILIAR-project/reproducibility-associativity path: /src_rst/testassoc.rs
use rand::prelude::*;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "ratio-checker")]
struct Opt {
#[structopt(short, long)]
error_margin: Option<f64>,
}
#[derive(Debug, Clone, Copy)]
... | code_fim | hard | {
"lang": "rust",
"repo": "FAMILIAR-project/reproducibility-associativity",
"path": "/src_rst/testassoc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = thread_rng();
// TODO: this variant for generating random
// let x = rng.gen::<f64>();
// let y = rng.gen::<f64>();
// let z = rng.gen::<f64>();
let x = rng.gen_range(0.000_000_000_000_001..100.0); // TODO: variation point for range min, max value
let y = rng.gen_... | code_fim | hard | {
"lang": "rust",
"repo": "FAMILIAR-project/reproducibility-associativity",
"path": "/src_rst/testassoc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> html! {
<li class=format!("list-item {} {}", classes, completed)>
<div class="view" id=id>
<Checkbox
class="toggle"
value=item.clone()
checked=self.props.complete
... | code_fim | hard | {
"lang": "rust",
"repo": "ericandre615/yew-rust-todomvc",
"path": "/src/components/todo/list_item.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ericandre615/yew-rust-todomvc path: /src/components/todo/list_item.rs
use yew::prelude::{
Component,
ComponentLink,
Html,
html,
ShouldRender,
Properties,
Callback,
};
use yew::services::ConsoleService;
use crate::components::Button;
use crate::components::form::Checkb... | code_fim | hard | {
"lang": "rust",
"repo": "ericandre615/yew-rust-todomvc",
"path": "/src/components/todo/list_item.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-stm32/stm32wb55xx/src/rng.rs
pub use ::stm32_common::rng::*;
::bobbin_mcu::periph!( RNG, Rng, RNG_PERIPH, RngPeriph, RNG_OWNED, RNG_REF_COUNT, 0x50060800, 0x00, 0x0b);
// Gate { name: None, gate_type: Some("RST"), periph: Some("RCC"), register: Some("AHB3... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32wb55xx/src/rng.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Now I have to calculate the input above to come up with a winner
//votes contains each persons vote so to calculate
//I need to tally [[x]voter] will be the vote
//for candidates_name[x]
let mut vote_tally = vec![0; candidates_num as usize];
let mut voter_count = 0;
fo... | code_fim | hard | {
"lang": "rust",
"repo": "armistace/fromAlgoDesManual",
"path": "/australian_voting/aus_vote.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: armistace/fromAlgoDesManual path: /australian_voting/aus_vote.rs
use std::io;
use std::mem;
//This code makes Strings to static str
//ripped from https://stackoverflow.com/questions/23975391/how-to-convert-string-into-static-str
fn string_to_static_str(s: String) -> &'static str {
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "armistace/fromAlgoDesManual",
"path": "/australian_voting/aus_vote.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andyyu2004/mp path: /mp-client/src/error/mod.rs
use mp_protocol::{impl_from, ProtocolError};
<|fim_suffix|>impl_from!(std::io::Error, ClientError, IO);
impl_from!(ProtocolError, ClientError, Protocol);
impl_from!(std::sync::mpsc::RecvError, ClientError, MpscRecv);
#[derive(Debug)]
pub enum Cli... | code_fim | easy | {
"lang": "rust",
"repo": "andyyu2004/mp",
"path": "/mp-client/src/error/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andyyu2004/mp path: /mp-client/src/error/mod.rs
use mp_protocol::{impl_from, ProtocolError};
pub(crate) type ClientResult<T> = Result<T, ClientError>;
<|fim_suffix|>#[derive(Debug)]
pub enum ClientError {
IO(std::io::Error),
Protocol(ProtocolError),
MpscRecv(std::sync::mpsc::RecvEr... | code_fim | medium | {
"lang": "rust",
"repo": "andyyu2004/mp",
"path": "/mp-client/src/error/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub enum ClientError {
IO(std::io::Error),
Protocol(ProtocolError),
MpscRecv(std::sync::mpsc::RecvError),
}<|fim_prefix|>// repo: andyyu2004/mp path: /mp-client/src/error/mod.rs
use mp_protocol::{impl_from, ProtocolError};
pub(crate) type ClientResult<T> = Result<T, ClientEr... | code_fim | medium | {
"lang": "rust",
"repo": "andyyu2004/mp",
"path": "/mp-client/src/error/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qiwei9743/leetcode_rs path: /src/orig/707.design-linked-list.rs
/*
* @lc app=leetcode id=707 lang=rust
*
* [707] Design Linked List
*
* https://leetcode.com/problems/design-linked-list/description/
*
* algorithms
* Easy (21.26%)
* Total Accepted: 31.4K
* Total Submissions: 148.8K
*... | code_fim | hard | {
"lang": "rust",
"repo": "qiwei9743/leetcode_rs",
"path": "/src/orig/707.design-linked-list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_add_head_delete0() {
let mut ll = MyLinkedList::new();
assert_eq!(ll.get(1), -1);
ll.add_at_head(12);
assert_eq!(ll.get(0), 12);
ll.add_at_head(11);
ll.add_at_head(10);
ll.delete_at_index(0);
ll.delete_at_index(0);
... | code_fim | hard | {
"lang": "rust",
"repo": "qiwei9743/leetcode_rs",
"path": "/src/orig/707.design-linked-list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> T::coerce_from(v)
}
}
#[repr(C)]
pub struct nsIIncrementalStreamLoaderVTable {
pub __base: nsIStreamListenerVTable,
/* void init (in nsIIncrementalStreamLoaderObserver aObserver); */
pub init: unsafe extern "C" fn (this: *const nsIIncrementalStreamLoader, aObserver: *const nsIInc... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIIncrementalStreamLoader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/* void onStreamComplete (in nsIIncrementalStreamLoader loader, in nsISupports ctxt, in nsresult status, in unsigned long resultLength, [array, size_is (resultLength), const] in octet result); */
}
#[repr(C)]
pub struct nsIIncrementalStreamLoader {
vtable: *const nsIIncrementalStreamLoaderVTa... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIIncrementalStreamLoader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIIncrementalStreamLoader.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIIncrementalStreamLoader.idl
//
#[repr(C)]
pub struct nsIIncrementalStreamLoaderObserver {
vtable: *const nsIIncrementalStreamLoaderObserverVTable,
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIIncrementalStreamLoader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Same as [`assert_lt!`] in builds with debug assertions enabled, and a no-op
/// otherwise.
///
/// # Example
///
/// ```rust
/// use more_asserts as ma;
///
/// // These are compiled to nothing if debug_assertions are off!
/// ma::debug_assert_lt!(3, 4);
/// ma::debug_assert_lt!(3, 4, "With a message"... | code_fim | hard | {
"lang": "rust",
"repo": "thomcc/rust-more-asserts",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomcc/rust-more-asserts path: /src/lib.rs
//! Small library providing some macros helpful for asserting. The API is very
//! similar to the API provided by the stdlib's own
//! [`assert_eq!`](core::assert_eq), [`assert_ne!`](core::assert_ne),
//! [`debug_assert_eq!`](core::debug_assert_eq), and... | code_fim | hard | {
"lang": "rust",
"repo": "thomcc/rust-more-asserts",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Same as [`assert_gt!`] in builds with debug assertions enabled, and a no-op
/// otherwise.
///
/// # Example
///
/// ```rust
/// use more_asserts as ma;
///
/// // These are compiled to nothing if debug_assertions are off!
/// ma::debug_assert_gt!(5, 3);
/// ma::debug_assert_gt!(5, 3, "With a message"... | code_fim | hard | {
"lang": "rust",
"repo": "thomcc/rust-more-asserts",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zandeck/simple_raytracer path: /src/main.rs
use cgmath::prelude::*;
use image::imageops;
mod camera;
mod hitable;
mod hitable_list;
mod material;
mod picture;
mod ray;
mod scene;
mod sphere;
use std::f64;
fn main() {
<|fim_suffix|> let p = picture::Picture::new(x_dim, y_dim, c, world.clon... | code_fim | hard | {
"lang": "rust",
"repo": "zandeck/simple_raytracer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut img = image::ImageBuffer::new(x_dim, y_dim);
let p = picture::Picture::new(x_dim, y_dim, c, world.clone(), ns);
let generated_picture = p.generate_picture();
generated_picture
.iter()
.map(|&(x, y, v)| {
(
x,
y,
... | code_fim | medium | {
"lang": "rust",
"repo": "zandeck/simple_raytracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mutestock/mini-proj2 path: /grpc/src/logic/person_handler.rs
#![allow(dead_code, unused_imports)]
use crate::entities::person;
use crate::{connection::sqlite_connection::get_db_pool, entities::person::PersonConverter};
use serde_derive::{Deserialize, Serialize};
pub async fn create(
reques... | code_fim | hard | {
"lang": "rust",
"repo": "Mutestock/mini-proj2",
"path": "/grpc/src/logic/person_handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn read_person_list_by_role(
request: person::ReadPersonListByRoleRequest,
) -> anyhow::Result<person::ReadPersonListByRoleResponse> {
let ppl = sqlx::query_as::<_, PersonConverter>(
r#"
SELECT * FROM people
WHERE role = $1
"#,
)
.bind(request.role... | code_fim | hard | {
"lang": "rust",
"repo": "Mutestock/mini-proj2",
"path": "/grpc/src/logic/person_handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = scanner.take_scanned_range();
assert_eq!(&r.lower_inclusive, b"");
assert_eq!(&r.upper_exclusive, b"");
// Empty interval range
let ranges = vec![IntervalRange::from(("x", "xb")).into()];
let mut scanner = RangesScanner::new(RangesScannerOptions {
... | code_fim | hard | {
"lang": "rust",
"repo": "TigerInYourDream/tikv",
"path": "/components/tidb_query_common/src/storage/scanner.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TigerInYourDream/tikv path: /components/tidb_query_common/src/storage/scanner.rs
ent_range: IntervalRange {
lower_inclusive: Vec::with_capacity(KEY_BUFFER_CAPACITY),
upper_exclusive: Vec::with_capacity(KEY_BUFFER_CAPACITY),
},
working_range... | code_fim | hard | {
"lang": "rust",
"repo": "TigerInYourDream/tikv",
"path": "/components/tidb_query_common/src/storage/scanner.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = scanner.take_scanned_range();
assert_eq!(&r.lower_inclusive, b"foo");
assert_eq!(&r.upper_exclusive, b"foo");
}
#[test]
fn test_scanned_range_forward2() {
let storage = create_storage();
// Filled interval range
let ranges = vec![Interva... | code_fim | hard | {
"lang": "rust",
"repo": "TigerInYourDream/tikv",
"path": "/components/tidb_query_common/src/storage/scanner.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:2.0,"position":3},{"timing_sec":55.14,"effect":4,"effect_value":0.698,"position":9},{"timing_sec":56.186,"effect":1,"effect_value":2.0,"position":7},{"timing_sec":56.535,"effect":1,"effect_value":2.0,"position":2},{"timing_sec":56.884,"effect":1,"effect_value":2.0,"position":4},{"timing_sec":57.233,"effe... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_018_easy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbz/beatmap-repo path: /datafiles/m_018_easy.rs
{"song_name":"告白日和、です。","difficulty":1,"rank_info":[{"rank":5,"rank_max":18719},{"rank":4,"rank_max":37439},{"rank":3,"rank_max":46799},{"rank":2,"rank_max":56159},{"rank":1,"rank_max":0}],"song_info":[{"notes_speed":1.3,"notes":[{"timing_sec":2.1... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_018_easy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OwenMcDonnell/sit path: /sit-web/src/webapp.rs
#[allow(dead_code)]
mod assets {
include!(concat!(env!("OUT_DIR"), "/assets.rs"));
use rouille::{Response, ResponseBody};
use mime_guess::get_mime_type_str;
use std::path::PathBuf;
use blake2::Blake2b;
use digest::{Input, Va... | code_fim | hard | {
"lang": "rust",
"repo": "OwenMcDonnell/sit",
"path": "/sit-web/src/webapp.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> } else {
fs::rename(record.actual_path(), record.path()).expect("can't rename record");
}
Response::json(&record.encoded_hash())
},
_ => {
// Serve repository content
if request.url().starts_with("/repo/") {
let fi... | code_fim | hard | {
"lang": "rust",
"repo": "OwenMcDonnell/sit",
"path": "/sit-web/src/webapp.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut moons = test_moons();
for _ in 0..10000000{
simulate_step(&mut moons);
}
}
#[test]
fn test_iterations() {
let mut moons = test_moons();
let testdata: &String = &std::fs::read_to_string("2019/12a.txt").unwrap();
let parser = Rege... | code_fim | hard | {
"lang": "rust",
"repo": "Zazcallabah/aoc",
"path": "/2019/12.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Zazcallabah/aoc path: /2019/12.rs
use regex::Regex;
use std::{collections::HashMap, fs, time::SystemTime};
use primal::Sieve;
#[cfg(test)]
mod tests {
use regex::Captures;
use super::*;
#[test]
fn test_move() {
let mut europa = Moon::new(MoonLabel::Europa, 1, 2, 3);
... | code_fim | hard | {
"lang": "rust",
"repo": "Zazcallabah/aoc",
"path": "/2019/12.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.pos.0.abs() + self.pos.1.abs() + self.pos.2.abs()
}
fn kinetic(&self) -> i32 {
self.vel.0.abs() + self.vel.1.abs() + self.vel.2.abs()
}
fn total_energy(&self) -> i32 {
self.potential() * self.kinetic()
}
fn get_1d(&self,d:i8) -> Moon1D {
match d... | code_fim | hard | {
"lang": "rust",
"repo": "Zazcallabah/aoc",
"path": "/2019/12.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HackGT/enzo path: /src/config/global.rs
use crate::{
utils::error::{EnzoError, EnzoErrorKind},
workspace::{project::Project, WorkspaceName},
};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, convert::TryFrom, fs::File, io::prelude::*, path::PathBuf};
#[derive(Defau... | code_fim | hard | {
"lang": "rust",
"repo": "HackGT/enzo",
"path": "/src/config/global.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut workspaces = HashMap::new();
let projects = HashMap::new();
for (key, value) in input {
workspaces.insert(WorkspaceName(String::from(key)), PathBuf::from(value));
}
let config = Config {
workspaces,
projects,
};
... | code_fim | hard | {
"lang": "rust",
"repo": "HackGT/enzo",
"path": "/src/config/global.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.