text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>//----------------------------------------------------
// データ参照のみのためビルダーパターン
#[cfg(feature = "builder")]
pub struct AnimationDataBuilder<T>
where
T: AnimationFile,
{
packs: BTreeMap<T::PackKey, Pack<T::UserData, T::PackKey, T::AnimationKey>>,
}
#[cfg(feature = "builder")]
impl<T> Anima... | code_fim | hard | {
"lang": "rust",
"repo": "kofmatsugen/sprite_studio",
"path": "/src/resource/data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: contacttapan/vrp path: /vrp-core/src/solver/evolution.rs
use crate::construction::heuristics::InsertionContext;
use crate::construction::Quota;
use crate::models::Problem;
use crate::solver::mutation::{Mutation, Recreate};
use crate::solver::population::DominancePopulation;
use crate::solver::te... | code_fim | hard | {
"lang": "rust",
"repo": "contacttapan/vrp",
"path": "/vrp-core/src/solver/evolution.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let insertion_ctx =
self.config.population.initial.methods[method_idx].0.run(&refinement_ctx, empty_ctx.deep_copy());
if should_add_solution(&refinement_ctx) {
refinement_ctx.population.add(insertion_ctx);
}
self.config.tele... | code_fim | hard | {
"lang": "rust",
"repo": "contacttapan/vrp",
"path": "/vrp-core/src/solver/evolution.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if config.population.initial.methods.is_empty() {
return Err("at least one initial method has to be specified".to_string());
}
if config.population.offspring.size < 1 {
return Err("offspring size should be greater than 0".to_string());
}
Ok... | code_fim | hard | {
"lang": "rust",
"repo": "contacttapan/vrp",
"path": "/vrp-core/src/solver/evolution.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kooparse/fuel path: /examples/light/main.rs
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate fuel;
use fuel::gl;
use fuel::na::{Isometry3, Vector3};
use fuel::utils;
use fuel::FirstPerson;
use fuel::Pipeline;
use fuel::Window;
use... | code_fim | medium | {
"lang": "rust",
"repo": "kooparse/fuel",
"path": "/examples/light/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Order is very important
let mvp = projection * view * model;
pipeline.shader.set_mvp(mvp);
pipeline.render();
}
win.clear_gl();
sleep(Duration::from_millis(16));
}
}<|fim_prefix|>// repo: kooparse/fuel path: /examples/light/m... | code_fim | hard | {
"lang": "rust",
"repo": "kooparse/fuel",
"path": "/examples/light/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/gamelift/src/operation.rs
crate::error::DescribeGameServerError,
>;
fn parse(&self, response: &http::Response<bytes::Bytes>) -> Self::Output {
if !response.status().is_success() && response.status().as_u16() != 200 {
crate::oper... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/gamelift/src/operation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rows = vec![];
for action in app.actions().actions().iter() {
let mut first = true;
for key in action.keys() {
let help = if first {
first = false;
action.to_string()
} else {
String::from("")
... | code_fim | hard | {
"lang": "rust",
"repo": "favetelinguis/bfg-rs",
"path": "/bfg-tui/src/app/ui/body/help.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: favetelinguis/bfg-rs path: /bfg-tui/src/app/ui/body/help.rs
use crate::App;
use tui::backend::Backend;
use tui::layout::{Constraint, Rect};
use tui::style::{Color, Style};
use tui::text::Span;
use tui::widgets::{Block, BorderType, Borders, Cell, Row, Table};
use tui::Frame;
<|fim_suffix|> le... | code_fim | hard | {
"lang": "rust",
"repo": "favetelinguis/bfg-rs",
"path": "/bfg-tui/src/app/ui/body/help.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return result;
}
pub fn gen_all_bmis() {
let mut cur_offset = 0;
for s in ALL_SQUARES.iter() {
cur_offset = generate_bmis(*s, Piece::Rook, cur_offset);
cur_offset = generate_bmis(*s, Piece::Bishop, cur_offset);
}
unsafe {
GENERATED_BMI_MOVES = cur_offset;
}... | code_fim | hard | {
"lang": "rust",
"repo": "jordanbray/chess",
"path": "/src/gen_tables/bmis.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jordanbray/chess path: /src/gen_tables/bmis.rs
use std::arch::x86_64::_pext_u64;
use std::fs::File;
use std::io::Write;
use crate::bitboard::{BitBoard, EMPTY};
use crate::gen_tables::magic_helpers::{magic_mask, questions_and_answers, NUM_MOVES};
use crate::gen_tables::rays::get_rays;
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "jordanbray/chess",
"path": "/src/gen_tables/bmis.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: renjithgr/rusted-lolcat path: /src/args.rs
const FREQUENCY_FLAG_SHORT: &str = "-f";
const FREQUENCY_FLAG_LONG: &str = "--freq";
const SPREAD_FLAG_SHORT: &str = "-s";
const SPREAD_FLAG_LONG: &str = "--spread";
const HELP_FLAG_SHORT: &str = "-h";
const HELP_FLAG_LONG: &str = "--help";
pub struct ... | code_fim | hard | {
"lang": "rust",
"repo": "renjithgr/rusted-lolcat",
"path": "/src/args.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input: Vec<String> = vec_of_strings!["", "--freq", "2.0", "filename-1.txt"];
let params = process_params(input);
assert_eq!(params.filenames.len(), 1);
assert_eq!(params.frequency, 2.0);
}
#[test]
fn test_should_parse_spread_parameter_short_param_name() {
... | code_fim | hard | {
"lang": "rust",
"repo": "renjithgr/rusted-lolcat",
"path": "/src/args.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GiantBlargg/Pluto path: /pluto/src/vm/func_execute.rs
use super::memory::MemoryAccessor;
struct StackAccess {
stack: Vec<u32>,
disallowed: usize,
retc: usize,
}
impl StackAccess {
fn decompose_sig(func_sig: u32) -> (u32, u32) {
(func_sig >> 12, func_sig & 0xfff)
}
fn new(stack: Vec<u32>... | code_fim | hard | {
"lang": "rust",
"repo": "GiantBlargg/Pluto",
"path": "/pluto/src/vm/func_execute.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct FuncExecutor {
memory: MemoryAccessor,
prg_ptr: u32,
stack_access: StackAccess,
func_stack: Option<Vec<u32>>,
}
impl FuncExecutor {
pub fn new<'b>(memory: MemoryAccessor, func_ptr: u32, value_stack: Vec<u32>) -> FuncExecutor {
let prg_ptr = func_ptr + 1;
let func_sig = memory.read(fun... | code_fim | hard | {
"lang": "rust",
"repo": "GiantBlargg/Pluto",
"path": "/pluto/src/vm/func_execute.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn on_command(&self, _args: Vec<String>) -> Result<(), Error> {
let mut handles = vec![];
// We're using the RHM supMCU module's connection to the Simplex (over I2C),
// rather than a direct UART connection
let sup_mcu = ServiceConfig::new("pumpkin-mcu-service");
... | code_fim | hard | {
"lang": "rust",
"repo": "kubos/apollo-fusion",
"path": "/apps/beacon-app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kubos/apollo-fusion path: /apps/beacon-app/src/main.rs
//
// Copyright (C) 2019 Kubos Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.a... | code_fim | hard | {
"lang": "rust",
"repo": "kubos/apollo-fusion",
"path": "/apps/beacon-app/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut l1_iter = l1.chars();
let mut l2_iter = l2.chars();
for i in 0..len {
if l1_iter.next() != l2_iter.next() {
diff_index = i;
break;
}
}
println!("{}", diff_index);
println!("{}", l1);
println!("{}", l2);
println!("{}{}", l1.g... | code_fim | hard | {
"lang": "rust",
"repo": "benjcal/AoC2018",
"path": "/d_2b/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benjcal/AoC2018 path: /d_2b/src/main.rs
fn solve(input: &str) {
let mut close_lines: Vec<&str> = Vec::new();
for a in input.lines() {
for b in input.lines() {
if char_diff_num(a, b) == 1 {
if !close_lines.contains(&a) || !close_lines.contains(&b){
... | code_fim | hard | {
"lang": "rust",
"repo": "benjcal/AoC2018",
"path": "/d_2b/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cmaves/btutils path: /examples/server_time.rs
use std::time::{Duration, Instant};
use async_std::task::sleep;
use rustable::gatt::server;
use rustable::Adapter;
use server::Application;
<|fim_suffix|> let start = Instant::now();
let mut target = start + Duration::from_secs(15);
loo... | code_fim | hard | {
"lang": "rust",
"repo": "cmaves/btutils",
"path": "/examples/server_time.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let service = TimeService::new(&mut app).await.unwrap();
let _worker = app.register().await.unwrap();
let start = Instant::now();
let mut target = start + Duration::from_secs(15);
loop {
sleep(target.saturating_duration_since(Instant::now())).await;
let ref_time = serv... | code_fim | hard | {
"lang": "rust",
"repo": "cmaves/btutils",
"path": "/examples/server_time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: team-worm/spice path: /server/debug/src/event.rs
use std::{io, mem, ptr};
use std::fs::File;
use std::os::windows::io::{RawHandle, FromRawHandle};
use winapi;
use kernel32;
/// An event received from a child process
pub struct Event {
pub process_id: u32,
pub thread_id: u32,
pub in... | code_fim | hard | {
"lang": "rust",
"repo": "team-worm/spice",
"path": "/server/debug/src/event.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let base = ld.lpBaseOfDll as usize;
LoadDll { file, base }
}
winapi::UNLOAD_DLL_DEBUG_EVENT => {
let ud = event.UnloadDll();
let base = ud.lpBaseOfDll as usize;
UnloadDll {... | code_fim | hard | {
"lang": "rust",
"repo": "team-worm/spice",
"path": "/server/debug/src/event.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// merge closest clusters
fn fit_step(&mut self) {
let mut tmp_i = 0;
let mut tmp_j = 0;
let mut current_dist = f64::MAX;
for i in 0..self.clusters.len() {
for j in (i + 1)..self.clusters.len() {
let d = self.get_cluster_dist(&self.clus... | code_fim | hard | {
"lang": "rust",
"repo": "antlearn/brasswheels",
"path": "/src/hclust.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// get distance between nodes using distance matrix
fn get_node_dist(&self, i: usize, j: usize) -> f64 {
match i > j {
true => *self.dist_mat.index((i - 1, j)),
false => *self.dist_mat.index((j - 1, i))
}
}
}
struct Cluster {
nodes: Vec<usize>,
... | code_fim | hard | {
"lang": "rust",
"repo": "antlearn/brasswheels",
"path": "/src/hclust.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antlearn/brasswheels path: /src/hclust.rs
extern crate csv;
extern crate nalgebra;
extern crate num;
extern crate rand;
use nalgebra::{DMat, RowSlice, Iterable};
use num::Float;
use std::f64;
use std::ops::Index;
use super::mathfunc::{euc_dist};
pub enum ClusterDistance {
Single, ... | code_fim | hard | {
"lang": "rust",
"repo": "antlearn/brasswheels",
"path": "/src/hclust.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mzabaluev/unwrap-infallible path: /src/lib.rs
//! Conversion method for infallible results
//!
//! This crate provides a convenience trait `UnwrapInfallible`,
//! adding method `unwrap_infallible` to `Result` types where an `Err` variant
//! is statically known to never occur.
//!
//! # Example
... | code_fim | hard | {
"lang": "rust",
"repo": "mzabaluev/unwrap-infallible",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Ok(v) => v,
Err(e) => e.into(),
}
}
}
#[cfg(all(feature = "never_type", not(feature = "blanket_impl")))]
impl<T> UnwrapInfallible for Result<T, !> {
type Ok = T;
fn unwrap_infallible(self) -> T {
self.unwrap_or_else(|never| never)
... | code_fim | hard | {
"lang": "rust",
"repo": "mzabaluev/unwrap-infallible",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.unwrap_or_else(|never| match never {})
}
}
#[cfg(test)]
mod tests {
use super::UnwrapInfallible;
// Hmm, Infallible is not Into<!> yet
#[cfg(not(feature = "blanket_impl"))]
#[test]
fn with_infallible() {
use core::convert::TryFrom;
let a = 42u8;
... | code_fim | hard | {
"lang": "rust",
"repo": "mzabaluev/unwrap-infallible",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RobJenks/simulated-annealing-optimisation path: /src/systems/salesman/solvable.rs
use rand::{Rng, self};
use crate::system::state::State;
use crate::system::solvable::Solvable;
use crate::systems::salesman::state::TravellingSalesmanState;
use crate::systems::salesman::city::TravellingSalesmanCit... | code_fim | hard | {
"lang": "rust",
"repo": "RobJenks/simulated-annealing-optimisation",
"path": "/src/systems/salesman/solvable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 1.0
}
fn get_optimising_iteration_count(&self) -> usize {
1
}
fn state_is_better_than(&self, state: &TravellingSalesmanState, other_state: &TravellingSalesmanState) -> bool {
self.calculate_total_distance(state) < self.calculate_total_distance(other_state)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "RobJenks/simulated-annealing-optimisation",
"path": "/src/systems/salesman/solvable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: angusturner/rustml path: /nn/src/main.rs
extern crate rulinalg as rl;
extern crate rand;
extern crate nn;
use rand::Rng;
use rl::matrix::{Matrix, MatrixSlice, BaseMatrix, BaseMatrixMut};
use nn::utils::*;
use nn::io::read_csv;
use nn::nn::NN;
#[allow(non_snake_case)]
fn main() {
// design ... | code_fim | hard | {
"lang": "rust",
"repo": "angusturner/rustml",
"path": "/nn/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // assert_eq!(&p2, &p);
// println!("{:?}", test_net.get_weights());
// debug output
println!("Loaded m={} training examples with n={} features.", m, n - 1);
println!("{} neurons in the hidden layer, and {} outputs", s2, s3);
println!("Training set accuracy: {:?}", accuracy);
... | code_fim | hard | {
"lang": "rust",
"repo": "angusturner/rustml",
"path": "/nn/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_precision(&self) -> ViewPrecision {
ViewPrecision::Float
}
}
#[derive(Clone, Copy)]
pub enum DataViewError {
FailedToCreateMemory,
}
impl DataViewError {
pub fn to_string(&self) -> String {
match self {
DataViewError::FailedToCreateMemory => "Failed to create memory".to_stri... | code_fim | hard | {
"lang": "rust",
"repo": "AKST/rs-ts-webgl-example",
"path": "/runtime/src/render/data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AKST/rs-ts-webgl-example path: /runtime/src/render/data.rs
use wasm_bindgen::{JsCast, JsValue};
use js_sys::{Object, Float32Array, WebAssembly};
use web_sys::console::log_1;
use super::constants::{HasBufferKind, ViewPrecision, HasViewPrecision};
#[derive(Clone, Copy, Debug)]
pub struct Data<V: ... | code_fim | medium | {
"lang": "rust",
"repo": "AKST/rs-ts-webgl-example",
"path": "/runtime/src/render/data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: breard-r/rust-opensmtpd path: /opensmtpd/examples/rm_x-originating-ip.rs
use opensmtpd::{return_data_line, run_filter, Filter, FilterEntry};
use opensmtpd_derive::register;
pub const HEADER_NAME: &str = "x-originating-ip:";
pub const HEADER_LEN: usize = 17;
struct RmXOriginatingIp {}
impl Fil... | code_fim | hard | {
"lang": "rust",
"repo": "breard-r/rust-opensmtpd",
"path": "/opensmtpd/examples/rm_x-originating-ip.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut my_filter = RmXOriginatingIp {};
run_filter(&mut my_filter);
}<|fim_prefix|>// repo: breard-r/rust-opensmtpd path: /opensmtpd/examples/rm_x-originating-ip.rs
use opensmtpd::{return_data_line, run_filter, Filter, FilterEntry};
use opensmtpd_derive::register;
pub const HEADER_NAME: &str = "x-ori... | code_fim | medium | {
"lang": "rust",
"repo": "breard-r/rust-opensmtpd",
"path": "/opensmtpd/examples/rm_x-originating-ip.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn get_ip() -> Result<Ip> {
let url = url::Url::parse("https://api.ipify.org?format=json")?;
let client = reqwest::Client::new();
let ip: Ip = client
.get(url)
.header("Content-Type", "application/json")
.send()
.await?
.json()
.await?;
... | code_fim | hard | {
"lang": "rust",
"repo": "tramulns/pub_ip",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tramulns/pub_ip path: /src/main.rs
use clap::App;
use error_chain::error_chain;
use serde::Deserialize;
error_chain! {
foreign_links {
ReqwestError(reqwest::Error);
ParseError(url::ParseError);
}
}
#[tokio::main]
async fn main() {
App::new("Get Public IP Address")
... | code_fim | medium | {
"lang": "rust",
"repo": "tramulns/pub_ip",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Debug)]
pub struct Ip {
pub ip: String,
}
async fn get_ip() -> Result<Ip> {
let url = url::Url::parse("https://api.ipify.org?format=json")?;
let client = reqwest::Client::new();
let ip: Ip = client
.get(url)
.header("Content-Type", "application/json")... | code_fim | hard | {
"lang": "rust",
"repo": "tramulns/pub_ip",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markrepedersen/compute_server path: /server/src/validate.rs
use std::{ffi::OsStr, path::Path};
pub fn is_valid(filename: &str) -> bool {
unimplemented!();
}
<|fim_suffix|> Path::new(filename).extension().and_then(OsStr::to_str)
}<|fim_middle|>fn get_file_extension(filename: &str) -> Opt... | code_fim | easy | {
"lang": "rust",
"repo": "markrepedersen/compute_server",
"path": "/server/src/validate.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_file_extension(filename: &str) -> Option<&str> {
Path::new(filename).extension().and_then(OsStr::to_str)
}<|fim_prefix|>// repo: markrepedersen/compute_server path: /server/src/validate.rs
use std::{ffi::OsStr, path::Path};
<|fim_middle|>pub fn is_valid(filename: &str) -> bool {
unimpleme... | code_fim | medium | {
"lang": "rust",
"repo": "markrepedersen/compute_server",
"path": "/server/src/validate.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BenjaminHinchliff/yew-sudoku path: /src/digit.rs
use core::fmt;
use std::convert::TryFrom;
use enum_iterator::IntoEnumIterator;
#[derive(thiserror::Error, Debug, Clone, PartialEq)]
pub enum Error {
#[error("unable to convert {0} into digit")]
ConversionOutOfRange(u8),
}
<|fim_suffix|>... | code_fim | hard | {
"lang": "rust",
"repo": "BenjaminHinchliff/yew-sudoku",
"path": "/src/digit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(match value {
1 => Digit::One,
2 => Digit::Two,
3 => Digit::Three,
4 => Digit::Four,
5 => Digit::Five,
6 => Digit::Six,
7 => Digit::Seven,
8 => Digit::Eight,
9 => Digit::Nine,
... | code_fim | medium | {
"lang": "rust",
"repo": "BenjaminHinchliff/yew-sudoku",
"path": "/src/digit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn euclidean_gcd() {
assert_eq!(2, euclidean(2,4));
}
}<|fim_prefix|>// repo: toddWannaCode/algos-and-ds path: /src/gcd.rs
pub fn euclidean(p: isize, q: isize) -> isize {
if q == 0 {
return p;
}
return euclidean(q,p % q)
}
<|fim_middle|>
#[cfg(test)]
mod t... | code_fim | easy | {
"lang": "rust",
"repo": "toddWannaCode/algos-and-ds",
"path": "/src/gcd.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: toddWannaCode/algos-and-ds path: /src/gcd.rs
pub fn euclidean(p: isize, q: isize) -> isize {
if q == 0 {
return p;
}
return euclidean(q,p % q)
}
<|fim_suffix|> #[test]
fn euclidean_gcd() {
assert_eq!(2, euclidean(2,4));
}
}<|fim_middle|>#[cfg(test)]
mod t... | code_fim | easy | {
"lang": "rust",
"repo": "toddWannaCode/algos-and-ds",
"path": "/src/gcd.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2, euclidean(2,4));
}
}<|fim_prefix|>// repo: toddWannaCode/algos-and-ds path: /src/gcd.rs
pub fn euclidean(p: isize, q: isize) -> isize {
if q == 0 {
return p;
}
return euclidean(q,p % q)
}
<|fim_middle|>
#[cfg(test)]
mod tests{
use super::*;
#[test]
... | code_fim | medium | {
"lang": "rust",
"repo": "toddWannaCode/algos-and-ds",
"path": "/src/gcd.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_part1() {
assert_eq!(part1("R75,D30,R83,U83,L12,D49,R71,U7,L72\nU62,R66,U55,R34,D71,R55,D58,R83"), 159);
assert_eq!(part1("R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51\nU98,R91,D20,R16,D67,R40,U7,R15,U6,R7"), 135);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "wmvanvliet/advent_of_code_in_rust",
"path": "/2019/day3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wmvanvliet/advent_of_code_in_rust path: /2019/day3/src/main.rs
use std::io::{self, Read};
use std::collections::HashMap;
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
println!("Part 1 answer: {}", part1(strip_bom(&input)));
println!(... | code_fim | hard | {
"lang": "rust",
"repo": "wmvanvliet/advent_of_code_in_rust",
"path": "/2019/day3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcb2003/old-blockz path: /src/engine/direction.rs
// Copyright 2020, Michael Connor Buchan and the Blockz contributors
// SPDX-License-Identifier: MIT
//! Contains the Direction enum to represent North, South, East and West
<|fim_suffix|> /// Returns true if the Direction is North or South
... | code_fim | hard | {
"lang": "rust",
"repo": "mcb2003/old-blockz",
"path": "/src/engine/direction.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns true if the Direction is North or South
fn is_verticle(&self) -> bool {
(self.clone() as u8) % 2 == 0
}
}<|fim_prefix|>// repo: mcb2003/old-blockz path: /src/engine/direction.rs
// Copyright 2020, Michael Connor Buchan and the Blockz contributors
// SPDX-License-Identifier... | code_fim | medium | {
"lang": "rust",
"repo": "mcb2003/old-blockz",
"path": "/src/engine/direction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns true if the Direction is East or West
fn is_horizontal(&self) -> bool {
(self.clone() as u8) % 2 == 1
}
/// Returns true if the Direction is North or South
fn is_verticle(&self) -> bool {
(self.clone() as u8) % 2 == 0
}
}<|fim_prefix|>// repo: mcb2003/o... | code_fim | hard | {
"lang": "rust",
"repo": "mcb2003/old-blockz",
"path": "/src/engine/direction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kayleg/cloud-pubsub path: /examples/subscribe_to_topic.rs
use cloud_pubsub::error;
use cloud_pubsub::{Client, EncodedMessage, FromPubSubMessage};
use serde_derive::Deserialize;
#[derive(Deserialize)]
struct Config {
topic: String,
google_application_credentials: String,
}
#[derive(Debu... | code_fim | hard | {
"lang": "rust",
"repo": "kayleg/cloud-pubsub",
"path": "/examples/subscribe_to_topic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Subscribed to topic with: {}", sub.name);
let packets = sub
.clone()
.get_messages::<UpdatePacket>(100)
.await
.expect("Error Checking PubSub");
for packet in &packets {
println!("Received: {:?}", packet);
}
if !packets.is_empty() {
... | code_fim | hard | {
"lang": "rust",
"repo": "kayleg/cloud-pubsub",
"path": "/examples/subscribe_to_topic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // FIXME: try to implement an iterator over an array of &str to convert them to String
flags: Some(vec!["-Wall".into(), "-O2".into()]),
}),
};
let toml = toml::to_string(&info).expect("Cannot serialize given structure");
file = match File::create(PathBuf::from(... | code_fim | hard | {
"lang": "rust",
"repo": "vschwaberow/Plance",
"path": "/src/new/create.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> file = match File::create(PathBuf::from(format!("{}/info.toml", plance_dir))) {
Ok(f) => f,
Err(e) => {
eprintln!("ERROR! Couldn't create Plance Info file: {}", e);
return;
}
};
match file.write_all(toml.as_bytes()) {
Ok(()) => (),
... | code_fim | hard | {
"lang": "rust",
"repo": "vschwaberow/Plance",
"path": "/src/new/create.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vschwaberow/Plance path: /src/new/create.rs
use std::fs;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::process::Command;
use crate::cli;
use crate::files;
use crate::info;
pub fn create_project(
name: String,
dir_name: String,
project_type: cli::ProjectTyp... | code_fim | hard | {
"lang": "rust",
"repo": "vschwaberow/Plance",
"path": "/src/new/create.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn serialize(&self, obj: &dml::Field, _datamodel: &dml::Datamodel) -> Result<Vec<ast::Directive>, DatamodelError> {
if let Some(strategy) = &obj.scalar_list_strategy {
return Ok(vec![ast::Directive::new(
self.directive_name(),
v... | code_fim | hard | {
"lang": "rust",
"repo": "zoosky/prisma-engine",
"path": "/libs/datamodel/core/src/validator/directive/core/scalarlist.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zoosky/prisma-engine path: /libs/datamodel/core/src/validator/directive/core/scalarlist.rs
use crate::error::DatamodelError;
use crate::validator::directive::{Args, DirectiveValidator};
use crate::{ast, dml};
/// Prismas builtin `@scalarList` directive.
pub struct ScalarListDirectiveValidator {... | code_fim | medium | {
"lang": "rust",
"repo": "zoosky/prisma-engine",
"path": "/libs/datamodel/core/src/validator/directive/core/scalarlist.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &"scalarList"
}
fn validate_and_apply(&self, args: &mut Args, obj: &mut dml::Field) -> Result<(), DatamodelError> {
// TODO: Throw when field is not of type scalar and arity is list.
// TODO: We can probably lift this pattern to a macro.
match args.arg("strategy")... | code_fim | medium | {
"lang": "rust",
"repo": "zoosky/prisma-engine",
"path": "/libs/datamodel/core/src/validator/directive/core/scalarlist.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfoote/wasmtime path: /crates/wasi-c/src/instantiate.rs
use crate::host::{
argv_environ_init, argv_environ_values, fd_prestats, fd_prestats_init, fd_prestats_insert,
fd_table, fd_table_init, fd_table_insert_existing,
};
use crate::syscalls;
use cranelift_codegen::ir::types;
use cranelift... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wasi-c/src/instantiate.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut wasm_fd = 3;
for (dir, file) in preopened_dirs {
assert!(fd_table_insert_existing(curfds, wasm_fd, file.as_raw_fd()));
let dir_cstr = CString::new(dir.as_str()).unwrap();
assert!(fd_prestats_insert(prestats, dir_cstr.as_ptr(), wasm_fd));
... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wasi-c/src/instantiate.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn allocate_argv_environ(
argv: &[String],
environ: &[(String, String)],
) -> (Vec<usize>, Vec<libc::c_char>, Vec<usize>, Vec<libc::c_char>) {
let mut argv_offsets = Vec::new();
let mut argv_buf = Vec::new();
let mut environ_offsets = Vec::new();
let mut environ_buf = Vec::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wasi-c/src/instantiate.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn calc_probs_invalid_args() {
unsafe {
let rc = calc_probs(ptr::null(), ptr::null_mut());
assert_eq!(rc, bindings::RC_INVALID_ARG);
}
}
}<|fim_prefix|>// repo: LewisGaul/python-rust-example path: /src/logic.rs
use bindings;
use std::ptr;
// --... | code_fim | hard | {
"lang": "rust",
"repo": "LewisGaul/python-rust-example",
"path": "/src/logic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LewisGaul/python-rust-example path: /src/logic.rs
use bindings;
use std::ptr;
// ----------------
// Exposed C API
/// See api.h for the C API being implemented.
#[no_mangle]
pub unsafe extern "C" fn calc_pi(n: u8) -> f32 {
calc_pi_impl(n)
}
/// See solver.h for the C API being implemente... | code_fim | hard | {
"lang": "rust",
"repo": "LewisGaul/python-rust-example",
"path": "/src/logic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdnavarro/charlatan path: /src/podcast/entity.rs
use serde::{Deserialize, Serialize};
#[derive(sqlx::FromRow, Deserialize, Serialize, Clone)]
pub struct Podcast {
pub id: i32,
pub src: String,
pub url: String,
pub title: String,
pub image: String,
pub description: String... | code_fim | medium | {
"lang": "rust",
"repo": "jdnavarro/charlatan",
"path": "/src/podcast/entity.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl warp::Reply for Podcast {
fn into_response(self) -> warp::reply::Response {
warp::reply::json(&self).into_response()
}
}<|fim_prefix|>// repo: jdnavarro/charlatan path: /src/podcast/entity.rs
use serde::{Deserialize, Serialize};
#[derive(sqlx::FromRow, Deserialize, Serialize, Clone)... | code_fim | medium | {
"lang": "rust",
"repo": "jdnavarro/charlatan",
"path": "/src/podcast/entity.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awslabs/amazon-qldb-shell path: /src/tracing.rs
use anyhow::Result;
use tracing::subscriber;
use tracing_appender::{non_blocking::WorkerGuard, rolling};
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
use tracing_subscriber::{fmt, prelude::*, EnvFilter, Registry};
use c... | code_fim | hard | {
"lang": "rust",
"repo": "awslabs/amazon-qldb-shell",
"path": "/src/tracing.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filter = EnvFilter::from_default_env()
.add_directive("rustyline=off".parse()?)
.add_directive(level.parse()?);
let subscriber = fmt::Subscriber::builder().with_env_filter(filter).finish();
subscriber::set_global_default(subscriber)... | code_fim | hard | {
"lang": "rust",
"repo": "awslabs/amazon-qldb-shell",
"path": "/src/tracing.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gkoz/build-helper path: /src/resources.rs
extern crate xml;
use std::env;
use std::error::Error;
use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use std::process::Command;
use self::xml::reader::{EventReader, ParserConfig, XmlEvent};
use self::xml:... | code_fim | hard | {
"lang": "rust",
"repo": "gkoz/build-helper",
"path": "/src/resources.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (n, byte) in resource.bytes().enumerate() {
try!(write!(rust, " 0x{:02x},", try!(byte)));
if (n + 1) % 8 == 0 {
try!(write!(rust, "\n "));
}
}
try!(write!(rust, "{}", "
],
_align: [],
};
}
"));
Ok(())
}
type Reader = ... | code_fim | hard | {
"lang": "rust",
"repo": "gkoz/build-helper",
"path": "/src/resources.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gentoli/wio-term-hid path: /src/delay.rs
use embedded_hal::blocking::delay::DelayMs;
use cortex_m::asm::delay as cycle_delay;
// use wio::prelude::*;
use wio_terminal::hal::time::{Nanoseconds, U32Ext};
<|fim_suffix|>fn ms_to_cycle(ms: u16) -> u32 {
static PERIOD: Nanoseconds = Nanoseconds... | code_fim | medium | {
"lang": "rust",
"repo": "Gentoli/wio-term-hid",
"path": "/src/delay.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> static PERIOD: Nanoseconds = Nanoseconds(1_000_u32 / 100);
let delay: Nanoseconds = (ms as u32).ms().into();
PERIOD.0 / delay.0
}
impl DelayMs<u16> for InstDelay {
fn delay_ms(&mut self, ms: u16) {
// Use 100MHz instead of 120MHz to have at least `ms` delay
cycle_delay(ms_... | code_fim | medium | {
"lang": "rust",
"repo": "Gentoli/wio-term-hid",
"path": "/src/delay.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> process_info.set_len(n_proc_info as usize);
let mut ents: Vec<Process> = Vec::new();
for info in process_info {
ents.push(Process {
parent: 0,
id: info.Process.dwProcessId,
path: None,
name: String::... | code_fim | hard | {
"lang": "rust",
"repo": "andrewmd5/quiche",
"path": "/quiche/src/os/process.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewmd5/quiche path: /quiche/src/os/process.rs
use crate::os::guid::Guid;
use std::io::{Error, ErrorKind};
use std::mem::{MaybeUninit, size_of_val};
use std::path::{Path, PathBuf};
use std::ptr::null_mut;
use winapi::shared::minwindef::DWORD;
use winapi::shared::winerror::{ERROR_MORE_D... | code_fim | hard | {
"lang": "rust",
"repo": "andrewmd5/quiche",
"path": "/quiche/src/os/process.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Turns a `PROCESSENTRY32W` structure into a `Process` object.
fn process(entry: PROCESSENTRY32W) -> Process {
let mut ps = Process {
id: entry.th32ProcessID,
parent: entry.th32ParentProcessID,
name: String::from_utf16_lossy(&entry.szExeFile)
.trim_end_match... | code_fim | hard | {
"lang": "rust",
"repo": "andrewmd5/quiche",
"path": "/quiche/src/os/process.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_error(
&mut p,
&mut h,
&[b],
ParserError::StatusCode(b)
);
}
}
#[test]
fn not_allowed_error2() {
// skip `\t` and `space`, otherwise state will change
for b in (0..255).filter(|&x| !is_digit!(x))
.filt... | code_fim | hard | {
"lang": "rust",
"repo": "seankerr/rust-http-box",
"path": "/src/http1/test/response/status_code.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seankerr/rust-http-box path: /src/http1/test/response/status_code.rs
// +-----------------------------------------------------------------------------------------------+
// | Copyright 2016 Sean Kerr |
// | ... | code_fim | hard | {
"lang": "rust",
"repo": "seankerr/rust-http-box",
"path": "/src/http1/test/response/status_code.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn floor_indicator(&self, floor: u8){
let buf = [3, floor, 0, 0];
let mut sock = self.socket.lock().unwrap();
sock.write(&buf).unwrap();
}
pub fn door_light(&self, on: bool){
let buf = [4, on as u8, 0, 0];
let mut sock = self.socket.lock().unwra... | code_fim | hard | {
"lang": "rust",
"repo": "Embla-Flatlandsmo/TTK4145-distributed-elevator-project",
"path": "/src/local_elevator/elevio/elev.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn stop_button_light(&self, on: bool){
let buf = [5, on as u8, 0, 0];
let mut sock = self.socket.lock().unwrap();
sock.write(&buf).unwrap();
}
pub fn call_button(&self, floor: u8, call: u8) -> bool {
let mut buf = [6, call, floor, 0];
... | code_fim | hard | {
"lang": "rust",
"repo": "Embla-Flatlandsmo/TTK4145-distributed-elevator-project",
"path": "/src/local_elevator/elevio/elev.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Embla-Flatlandsmo/TTK4145-distributed-elevator-project path: /src/local_elevator/elevio/elev.rs
//#![allow(dead_code)]
use std::net::TcpStream;
use std::sync::*;
use std::fmt;
use std::io::*;
pub const DIRN_DOWN: u8 = u8::MAX;
pub const DIRN_STOP: u8 = 0;
pub const DIRN_UP: u8 = 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "Embla-Flatlandsmo/TTK4145-distributed-elevator-project",
"path": "/src/local_elevator/elevio/elev.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (min_y, max_y, world) = compute_world();
count_water(&world, min_y, max_y)
}
fn part2() -> usize {
let (min_y, max_y, mut world) = compute_world();
let mut count = count_water(&world, min_y, max_y);
let row_len = world[0].len();
loop {
for x in 0..(row_len) {
... | code_fim | hard | {
"lang": "rust",
"repo": "Ameobea/advent-of-code-2018",
"path": "/src/day17.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ameobea/advent-of-code-2018 path: /src/day17.rs
use std::usize;
use regex::Regex;
const INPUT: &str = include_str!("../input/day17.txt");
lazy_static! {
static ref X_RGX: Regex = Regex::new("x=(\\d+)(?:\\.\\.(\\d+))?").unwrap();
static ref Y_RGX: Regex = Regex::new("y=(\\d+)(?:\\.\\.(... | code_fim | hard | {
"lang": "rust",
"repo": "Ameobea/advent-of-code-2018",
"path": "/src/day17.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spotlease/stripe-rust path: /src/error.rs
use serde::Deserialize;
use std::io;
use reqwest;
use serde_json;
use serde_qs;
use failure::{Fail, SyncFailure};
/// An error encountered when communicating with the Stripe API.
#[derive(Debug, Fail)]
pub enum Error {
/// An error reported by Strip... | code_fim | hard | {
"lang": "rust",
"repo": "spotlease/stripe-rust",
"path": "/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DataBlockRecord {
/// Returns a new DataBlockRecord
/// # Arguments
/// * `values` - Vector of data block values for a given row indexed by column
#[inline]
pub fn new(values: Vec<Arc<DataBlockValue>>) -> DataBlockRecord {
DataBlockRecord { values }
}
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/data_block/record.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: microsoft/synthetic-data-showcase path: /packages/core/src/data_block/record.rs
use super::value::DataBlockValue;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
<|fim_suffix|>impl DataBlockRecord {
/// Returns a new DataBlockRecord
/// # Arguments
/// * `values` - Vector o... | code_fim | hard | {
"lang": "rust",
"repo": "microsoft/synthetic-data-showcase",
"path": "/packages/core/src/data_block/record.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let boards: Collection<Board> = client.database("pinterust").collection_with_type("boards");
let query = doc! { "_id": { "$in": user.group_boards } };
let group_boards: Vec<Board> = boards
.find(query, None)
.await
.unwrap()
.try_collect()
.await
... | code_fim | hard | {
"lang": "rust",
"repo": "isabelatkinson/pinterust",
"path": "/src/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabelatkinson/pinterust path: /src/user.rs
use actix_session::Session;
use actix_web::{get, post, web, HttpResponse};
use futures::stream::TryStreamExt;
use mongodb::{
bson::{doc, oid::ObjectId},
Client, Collection,
};
use serde::Deserialize;
use tera::{Context, Tera};
use super::data_... | code_fim | hard | {
"lang": "rust",
"repo": "isabelatkinson/pinterust",
"path": "/src/user.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>::seconds(10i64.pow(9));
date + gigaseconds
}<|fim_prefix|>// repo: tlwalker/exercism path: /rust/gigasecond/src/lib.rs
extern crate chrono;
use chrono::{DateTime, Dura<|fim_middle|>tion, UTC};
pub fn after(date: DateTime<UTC>) -> DateTime<UTC> {
let gigaseconds = Duration | code_fim | medium | {
"lang": "rust",
"repo": "tlwalker/exercism",
"path": "/rust/gigasecond/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>> DateTime<UTC> {
let gigaseconds = Duration::seconds(10i64.pow(9));
date + gigaseconds
}<|fim_prefix|>// repo: tlwalker/exercism path: /rust/gigasecond/src/lib.rs
extern crate chrono;
use chrono::{DateTime, Dura<|fim_middle|>tion, UTC};
pub fn after(date: DateTime<UTC>) - | code_fim | easy | {
"lang": "rust",
"repo": "tlwalker/exercism",
"path": "/rust/gigasecond/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tlwalker/exercism path: /rust/gigasecond/src/lib.rs
extern crate chrono;
use chrono::{DateTime, Duration, UTC};
pub fn after(date: DateTime<UTC>) -<|fim_suffix|>::seconds(10i64.pow(9));
date + gigaseconds
}<|fim_middle|>> DateTime<UTC> {
let gigaseconds = Duration | code_fim | easy | {
"lang": "rust",
"repo": "tlwalker/exercism",
"path": "/rust/gigasecond/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awslabs/tough path: /tuftool/tests/download_command.rs
mod test_utils;
use assert_cmd::assert::Assert;
use assert_cmd::Command;
use httptest::{matchers::*, responders::*, Expectation, Server};
use std::fs::read_to_string;
use std::path::Path;
use std::str::FromStr;
use tempfile::TempDir;
use ur... | code_fim | hard | {
"lang": "rust",
"repo": "awslabs/tough",
"path": "/tuftool/tests/download_command.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Assert the files are exactly correct
assert_file_match(&outdir, "file1.txt");
assert_file_match(&outdir, "file2.txt");
// Download again into the same outdir, this will fail because the directory exists.
Command::cargo_bin("tuftool")
.unwrap()
.args([
"d... | code_fim | hard | {
"lang": "rust",
"repo": "awslabs/tough",
"path": "/tuftool/tests/download_command.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>(move || {
let mut old_len = 0;
while old_len < 1000 {
let s = vv.as_slice();
if s.len() > old_len {
println!("{:?}", &s[old_len..]);
old_len = s.len();
}
}
});
h1.join().unwrap();
h2.join().unwrap();
}... | code_fim | medium | {
"lang": "rust",
"repo": "critiqjo/cvec",
"path": "/examples/threaded.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: critiqjo/cvec path: /examples/threaded.rs
extern crate cvec;
use cvec::CVec;
use std::thread;
fn main() {
let mut v = CVec::with_capacity(1000);
let vv = v.view();
let h1 = thread:<|fim_suffix|> println!("{:?}", &s[old_len..]);
old_len = s.len();
}
... | code_fim | hard | {
"lang": "rust",
"repo": "critiqjo/cvec",
"path": "/examples/threaded.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thirtyspokes/advent-of-code-2018 path: /day1/src/main.rs
use std::io::prelude::*;
use std::io::BufReader;
use std::io::SeekFrom;
use std::fs::File;
use std::collections::HashMap;
fn main() {
let input = File::open("inputs/part-1.txt").expect("Couldn't open input!");
let result = ca... | code_fim | hard | {
"lang": "rust",
"repo": "thirtyspokes/advent-of-code-2018",
"path": "/day1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn calculate_loop_frequency(input_file: &File) -> isize {
let mut reader = BufReader::new(input_file);
let mut seen: HashMap<isize, bool> = HashMap::new();
let mut frequency: isize = 0;
loop {
reader.seek(SeekFrom::Start(0)).expect("Failed to seek to start of file!");
for... | code_fim | medium | {
"lang": "rust",
"repo": "thirtyspokes/advent-of-code-2018",
"path": "/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZodiacalComet/fimfic-tracker path: /core/src/config/sensibility.rs
use std::{cmp, fmt};
use serde::de::{self, Unexpected, Visitor};
use serde::{Deserialize, Deserializer};
/// The different available options of update sensibility level.
///
/// Meant for the conditions of one level to be prese... | code_fim | hard | {
"lang": "rust",
"repo": "ZodiacalComet/fimfic-tracker",
"path": "/core/src/config/sensibility.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn le(&self, other: &SensibilityLevel) -> bool {
(*self as u8) <= (*other as u8)
}
fn gt(&self, other: &SensibilityLevel) -> bool {
(*self as u8) > (*other as u8)
}
fn ge(&self, other: &SensibilityLevel) -> bool {
(*self as u8) >= (*other as u8)
}
}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "ZodiacalComet/fimfic-tracker",
"path": "/core/src/config/sensibility.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{} batches", self.batches.len())
}
}
impl RecordSet {
pub fn add(mut self, batch: DefaultBatch) -> Self {
self.batches.push(batch);
self
}
}
impl Decoder for RecordSet {
fn decode<T>(&mut self, src: &mut T, version: Version) -> Result<(), Error>
whe... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/flv-kf-protocol",
"path": "/kf-protocol-api/src/record.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.