text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> println!("{} {}", A, B);
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/let-else/const-fn.rs
// run-pass
// issue #101932
const fn foo(a: Option<i32>) -> i32 {
let Some(a) = a else {
return 42
};
<|fim_middle|> a + 1
}
fn main() {
const A: i32 = foo(None);
const... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/let-else/const-fn.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/let-else/const-fn.rs
// run-pass
// issue #101932
<|fim_suffix|> const A: i32 = foo(None);
const B: i32 = foo(Some(1));
println!("{} {}", A, B);
}<|fim_middle|>
const fn foo(a: Option<i32>) -> i32 {
let Some(a) = a else {
return 42
};
... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/let-else/const-fn.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> const A: i32 = foo(None);
const B: i32 = foo(Some(1));
println!("{} {}", A, B);
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/let-else/const-fn.rs
// run-pass
// issue #101932
const fn foo(a: Option<i32>) -> i32 {
let Some(a) = a else {
return 42
};
<|fim_middle|>... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/let-else/const-fn.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::env::set_var("RUST_LOG", "info");
std::env::set_var("RUST_BACKTRACE", "full");
let _guard = init_sentry();
let _handle = std::thread::spawn(|| {
crate::config::background_update();
});
let appfn = move || {
App::new()
.wrap(middleware::Logger::default())
.service(web::resource("/gam... | code_fim | medium | {
"lang": "rust",
"repo": "steamroller-airmash/airmash-front-page-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steamroller-airmash/airmash-front-page-server path: /src/main.rs
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
mod clienterror;
mod games;
mod spec;
mod config;
use actix_web::{http, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer};
use futures::prelu... | code_fim | hard | {
"lang": "rust",
"repo": "steamroller-airmash/airmash-front-page-server",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _handle = std::thread::spawn(|| {
crate::config::background_update();
});
let appfn = move || {
App::new()
.wrap(middleware::Logger::default())
.service(web::resource("/games").route(web::get().to_async(games_wrapper)))
.service(web::resource("/clienterror").route(web::get().to_async(... | code_fim | hard | {
"lang": "rust",
"repo": "steamroller-airmash/airmash-front-page-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Leopard2A5/fhttp path: /fhttp-core/src/path_utils.rs
use std::fmt::Display;
use std::fs;
use std::path::{Path, PathBuf};
use anyhow::{Context, Result};
pub fn canonicalize(p: &Path) -> Result<CanonicalizedPathBuf> {
fs::canonicalize(&p)
.with_context(|| format!("error opening file ... | code_fim | hard | {
"lang": "rust",
"repo": "Leopard2A5/fhttp",
"path": "/fhttp-core/src/path_utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsRef<Path> for CanonicalizedPathBuf {
fn as_ref(&self) -> &Path {
&self.0
}
}
impl From<CanonicalizedPathBuf> for PathBuf {
fn from(cpb: CanonicalizedPathBuf) -> Self {
cpb.0
}
}
fn get_dependency_path<O: AsRef<Path>>(
origin_path: O,
path: &str
) -> Result<... | code_fim | hard | {
"lang": "rust",
"repo": "Leopard2A5/fhttp",
"path": "/fhttp-core/src/path_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl CanonicalizedPathBuf {
pub fn to_str(&self) -> &str {
self.0.to_str().expect("encountered a non-utf8 character in file path!")
}
/// This function may panic, it's intended for test purposes!
pub fn join<P: AsRef<Path>>(
&self,
path: P
) -> Self {
c... | code_fim | hard | {
"lang": "rust",
"repo": "Leopard2A5/fhttp",
"path": "/fhttp-core/src/path_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Never fails so convert is unreachable.
fn convert_write_err(_error: Infallible) -> Error {
unreachable!()
}
}
impl ReadWriter {
/// Creates a new mock device.
fn new(address: u8, expecting: &[u8], buffer_limit: u8) -> Self {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "yellowsquid/i2cwrite",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yellowsquid/i2cwrite path: /src/lib.rs
use embedded_hal::blocking::i2c::{self, Read};
use std::cmp;
use std::io::{self, Error, ErrorKind};
use std::thread;
use std::time::Duration;
const BUFFER_WAIT: Duration = Duration::from_millis(4);
/// Encodes a single byte of data.
pub trait Encoding {
... | code_fim | hard | {
"lang": "rust",
"repo": "yellowsquid/i2cwrite",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_departments(&self) -> EntryDomainResult<Vec<String>>;
fn get_cities(&self) -> EntryDomainResult<Vec<String>>;
fn search_cities(
&self,
department: String,
query: String,
) -> EntryDomainResult<BTreeMap<String, CityDetail>>;
fn get_national_index(&self) ->... | code_fim | medium | {
"lang": "rust",
"repo": "SGecko-Design4Green/design4green-api",
"path": "/domain/src/business/traits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SGecko-Design4Green/design4green-api path: /domain/src/business/traits.rs
use crate::business::error::EntryDomainResult;
use crate::core::entry::*;
use std::collections::{HashMap, BTreeMap};
pub trait EntryDomainTrait: Sync + Send {
fn get_all(&self) -> EntryDomainResult<Vec<Entry>>;
fn... | code_fim | hard | {
"lang": "rust",
"repo": "SGecko-Design4Green/design4green-api",
"path": "/domain/src/business/traits.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_departmental_index(&self, department: String) -> EntryDomainResult<Entry>;
fn get_in_departmental_index(&self, department: String, page: i32) -> EntryDomainResult<BTreeMap<String, Entry>>;
fn get_city_index(&self, code_insee: String) -> EntryDomainResult<Entry>;
fn get_city_district... | code_fim | hard | {
"lang": "rust",
"repo": "SGecko-Design4Green/design4green-api",
"path": "/domain/src/business/traits.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackyarndley/rust-fluid path: /src/advection/mod.rs
use crate::interpolation::Interpolation;
use crate::integration::Integration;
use crate::util::fluid_quantity::{FluidQuantity};
pub enum Advection {
SemiLagrangian
}
impl Advection {
pub fn advect(&self, u_velocity: &mut FluidQuantity... | code_fim | hard | {
"lang": "rust",
"repo": "jackyarndley/rust-fluid",
"path": "/src/advection/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let old_x: f64 = integration.run(0.0, x, &f1, timestep);
let old_y: f64 = integration.run(0.0, y, &f2, timestep);
*density.dst_at_mut(row, column) = interpolation.run(old_x, old_y, density);
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jackyarndley/rust-fluid",
"path": "/src/advection/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: curiosityyy/graphsurge path: /src/computations/scc/mod.rs
use crate::computations::ComputationProperties;
use crate::error::computation_error;
use crate::error::GraphSurgeError;
use gs_analytics_api::{ComputationTypes, VertexId};
use hashbrown::HashMap;
<|fim_suffix|>#[derive(Clone)]
pub struct... | code_fim | medium | {
"lang": "rust",
"repo": "curiosityyy/graphsurge",
"path": "/src/computations/scc/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct SCC;
impl SCC {
pub fn instance(
properties: &HashMap<String, ComputationProperties>,
) -> Result<Self, GraphSurgeError> {
if properties.is_empty() {
Ok(Self {})
} else {
Err(computation_error(format!(
"SC... | code_fim | medium | {
"lang": "rust",
"repo": "curiosityyy/graphsurge",
"path": "/src/computations/scc/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SCC {
pub fn instance(
properties: &HashMap<String, ComputationProperties>,
) -> Result<Self, GraphSurgeError> {
if properties.is_empty() {
Ok(Self {})
} else {
Err(computation_error(format!(
"SCC does not need any property, but ... | code_fim | medium | {
"lang": "rust",
"repo": "curiosityyy/graphsurge",
"path": "/src/computations/scc/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_crossings() {
let wires1 = vec![
(Direction::R, 75),
(Direction::D, 30),
(Direction::R, 83),
(Direction::U, 83),
(Direction::L, 12),
(Direction::D, 49),
(Direction::R, 71),
(Direction::U, 7),
(Direction::L, 72),
... | code_fim | hard | {
"lang": "rust",
"repo": "mattiast/aoc2019",
"path": "/src/day03/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattiast/aoc2019 path: /src/day03/mod.rs
mod parse;
mod types;
use parse::read_input;
use types::*;
fn crossing(s1: Segment, s2: Segment) -> Option<(f64, f64, Point)> {
match (s1, s2) {
(Segment::Horizontal(x1, x2, y), Segment::Vertical(x, y1, y2)) => {
let kx = (x - x1... | code_fim | hard | {
"lang": "rust",
"repo": "mattiast/aoc2019",
"path": "/src/day03/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let command = process::Command::new("stdbuf", &["-oL", "alsactl", "monitor"]);
command.listen_stdout(|| communication::send_message(self.id, &self.sender))
}
}<|fim_prefix|>// repo: Gerschtli/dwm-status path: /src/features/audio/notifier.rs
use crate::communication;
use crate::error:... | code_fim | medium | {
"lang": "rust",
"repo": "Gerschtli/dwm-status",
"path": "/src/features/audio/notifier.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gerschtli/dwm-status path: /src/features/audio/notifier.rs
use crate::communication;
use crate::error::Result;
use crate::wrapper::channel;
use crate::wrapper::process;
use crate::wrapper::thread;
pub(super) struct Notifier {
id: usize,
sender: channel::Sender<communication::Message>,
}... | code_fim | medium | {
"lang": "rust",
"repo": "Gerschtli/dwm-status",
"path": "/src/features/audio/notifier.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl thread::Runnable for Notifier {
fn run(&self) -> Result<()> {
let command = process::Command::new("stdbuf", &["-oL", "alsactl", "monitor"]);
command.listen_stdout(|| communication::send_message(self.id, &self.sender))
}
}<|fim_prefix|>// repo: Gerschtli/dwm-status path: /src... | code_fim | hard | {
"lang": "rust",
"repo": "Gerschtli/dwm-status",
"path": "/src/features/audio/notifier.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Censkh/Maxwell path: /src/plugins/prettify_plugin.rs
use compiler::transform::PluginPass;
use compiler::transform::Plugin;
use std::result::Result;
use std::error::Error;
use compiler::ast::statement::StatementTerminator;
<|fim_suffix|> use self::PluginPass::*;
use self::Expres... | code_fim | hard | {
"lang": "rust",
"repo": "Censkh/Maxwell",
"path": "/src/plugins/prettify_plugin.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(String::from(""))
}
_ => Ok(String::from(""))
}
}
_ => Ok("".to_owned())
}
}
fn get_name(&self) -> &str {
return "internal.prettify";
}
}<|fim_prefix|>// repo: Censkh/Max... | code_fim | hard | {
"lang": "rust",
"repo": "Censkh/Maxwell",
"path": "/src/plugins/prettify_plugin.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jasperav/cdrs_orm path: /cdrs_query_writer/src/crud/delete.rs
use crate::method_writer::{Crud, Inf, Writer};
use crate::DELETE_UNIQUE;
use proc_macro2::TokenStream;
use quote::format_ident;
<|fim_suffix|> writer.write(
inf,
&format_ident!("{}", &db_mirror_fn_name),
&f... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs_orm",
"path": "/cdrs_query_writer/src/crud/delete.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> writer.write(
inf,
&format_ident!("{}", &db_mirror_fn_name),
&format_ident!("{}", &custom_fn_name),
Crud::DeleteUnique,
)
}<|fim_prefix|>// repo: Jasperav/cdrs_orm path: /cdrs_query_writer/src/crud/delete.rs
use crate::method_writer::{Crud, Inf, Writer};
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "Jasperav/cdrs_orm",
"path": "/cdrs_query_writer/src/crud/delete.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sciencentistguy/rust-clippy path: /clippy_lints/src/methods/filter_flat_map.rs
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::is_trait_method;
use rustc_hir as hir;
use rustc_lint::LateContext;
use rustc_span::sym;
<|fim_suffix|>/// lint use of `filter().flat_map()` for `I... | code_fim | medium | {
"lang": "rust",
"repo": "Sciencentistguy/rust-clippy",
"path": "/clippy_lints/src/methods/filter_flat_map.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// lint use of `filter().flat_map()` for `Iterators`
pub(super) fn check<'tcx>(
cx: &LateContext<'tcx>,
expr: &'tcx hir::Expr<'_>,
_filter_args: &'tcx [hir::Expr<'_>],
_map_args: &'tcx [hir::Expr<'_>],
) {
// lint if caller of `.filter().flat_map()` is an Iterator
if is_trait_meth... | code_fim | medium | {
"lang": "rust",
"repo": "Sciencentistguy/rust-clippy",
"path": "/clippy_lints/src/methods/filter_flat_map.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn is_closed(&self) -> bool;
}
pub type GraphicsDriverCell = Box<dyn GraphicsDriver>;<|fim_prefix|>// repo: rykrr/Emerald path: /src/graphics/graphics_driver.rs
use std::cell::RefCell;
pub struct Point {
pub x: u16,
pub y: u16,
}
pub fn encode_rgb(r: u8, g: u8, b: u8) -> u32 {
... | code_fim | easy | {
"lang": "rust",
"repo": "rykrr/Emerald",
"path": "/src/graphics/graphics_driver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rykrr/Emerald path: /src/graphics/graphics_driver.rs
use std::cell::RefCell;
pub struct Point {
pub x: u16,
pub y: u16,
}
pub fn encode_rgb(r: u8, g: u8, b: u8) -> u32 {
return (r as u32) << 16 | (g as u32) << 8 | (b as u32);
}
<|fim_suffix|>}
pub type GraphicsDriver... | code_fim | medium | {
"lang": "rust",
"repo": "rykrr/Emerald",
"path": "/src/graphics/graphics_driver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn check_result(mut res: reqwest::Response) {
if res.status().is_success() {
println!("success!");
let mut buf: Vec<u8> = vec![];
let _cres = res.copy_to(&mut buf);
let s = match str::from_utf8(buf.as_slice()) {
Ok(v) => v,
Err(e) => panic!("Inva... | code_fim | hard | {
"lang": "rust",
"repo": "ianco/rest_server",
"path": "/rest_client/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ianco/rest_server path: /rest_client/src/main.rs
extern crate hyper;
extern crate serde_json;
extern crate reqwest;
use std::str;
use std::collections::HashMap;
use hyper::header::{Headers, Authorization, Basic};
use serde_json::{Value, Error};
fn main() {
println!("Hello, world!");
... | code_fim | hard | {
"lang": "rust",
"repo": "ianco/rest_server",
"path": "/rest_client/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if res.status().is_success() {
println!("success!");
let mut buf: Vec<u8> = vec![];
let _cres = res.copy_to(&mut buf);
let s = match str::from_utf8(buf.as_slice()) {
Ok(v) => v,
Err(e) => panic!("Invalid UTF-8 sequence: {}", e),
};
... | code_fim | hard | {
"lang": "rust",
"repo": "ianco/rest_server",
"path": "/rest_client/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AuxControl/twelf path: /twelf/tests/mixed.rs
use std::collections::HashMap;
use config_derive::config;
use twelf::Layer;
fn default_array() -> Vec<String> {
vec!["first".to_owned(), "second".to_owned()]
}
const TOML_TEST_FILE: &str = "./tests/fixtures/test.toml";
const JSON_TEST_FILE: &st... | code_fim | hard | {
"lang": "rust",
"repo": "AuxControl/twelf",
"path": "/twelf/tests/mixed.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn mixed_with_array_and_hashmap_with_default() {
#[config]
#[derive(Debug)]
struct Conf {
elements_def: HashMap<String, String>,
#[serde(default = "default_array")]
array_def: Vec<String>,
}
std::env::set_var("ELEMENTS_DEF", "coucou=toi,hello=you");
... | code_fim | hard | {
"lang": "rust",
"repo": "AuxControl/twelf",
"path": "/twelf/tests/mixed.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn mixed_with_array_and_hashmap_string() {
#[config]
#[derive(Debug)]
struct Conf {
elements: HashMap<String, String>,
#[serde(default = "default_array")]
array: Vec<String>,
}
std::env::set_var("ARRAY", "test,test2");
std::env::set_var("ELEMENTS", ... | code_fim | hard | {
"lang": "rust",
"repo": "AuxControl/twelf",
"path": "/twelf/tests/mixed.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/exodus path: /src/daemon.rs
use std::process::Command;
use std::env;
fn worker() {
loop {
// do something ...
}
}
fn main() {
<|fim_suffix|> println!("executable: {:?}", executable);
match args.next() {
Some(sub_command) => match sub_command.as_st... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/exodus",
"path": "/src/daemon.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut args = env::args();
let executable = args.next().unwrap();
println!("executable: {:?}", executable);
match args.next() {
Some(sub_command) => match sub_command.as_str() {
"daemon" => {
let child = Command::new(executable)
... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/exodus",
"path": "/src/daemon.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("executable: {:?}", executable);
match args.next() {
Some(sub_command) => match sub_command.as_str() {
"daemon" => {
let child = Command::new(executable)
.spawn()
.expect("Child pro... | code_fim | hard | {
"lang": "rust",
"repo": "gitter-badger/exodus",
"path": "/src/daemon.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b mod brute_force;
pub mod segment_tree;<|fim_prefix|>// repo: prajithkb/datastructures_in_rust path: /src/intervals/mod.rs
//! The intervals module.
//! This modu<|fim_middle|>le implements data structures to perform queries and updates on intervals.
pu | code_fim | medium | {
"lang": "rust",
"repo": "prajithkb/datastructures_in_rust",
"path": "/src/intervals/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prajithkb/datastructures_in_rust path: /src/intervals/mod.rs
//! The intervals module.
//! This module implements data structures to perfor<|fim_suffix|>b mod brute_force;
pub mod segment_tree;<|fim_middle|>m queries and updates on intervals.
pu | code_fim | easy | {
"lang": "rust",
"repo": "prajithkb/datastructures_in_rust",
"path": "/src/intervals/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn activate(context: &dyn UnauthContext, token: &str) -> Result<(), ActivationError> {
tx(context.db(), |conn| {
let token_hash = sha256_hex(token.as_bytes());
let (user, uc) = UserCredential::find_by_activation_key(conn, &token_hash)?
.ok_or_else(|| ActivationErrorKind... | code_fim | medium | {
"lang": "rust",
"repo": "mmrath/ara",
"path": "/ara-client-api/src/core/user/service/activation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmrath/ara path: /ara-client-api/src/core/user/service/activation.rs
use failure::Fail;
use serde::Serialize;
use ara_error::{AppError, HttpStatus};
use ara_model::core::{User, UserCredential};
use ara_model::db::tx;
<|fim_suffix|>#[derive(Debug, Serialize, Fail, HttpStatus)]
pub enum Activati... | code_fim | hard | {
"lang": "rust",
"repo": "mmrath/ara",
"path": "/ara-client-api/src/core/user/service/activation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
main::main();
}<|fim_prefix|>// repo: bfops/opencl-raytrace path: /src/bin.rs
#![feature(repr_simd)]
extern crate cgmath;
#[macro_use]
extern crate glium;
extern crate glutin;
#[macro_use]
extern crate log;
extern crate opencl;
extern crate rand;
extern crate time;
<|fim_middle|>mod main;... | code_fim | easy | {
"lang": "rust",
"repo": "bfops/opencl-raytrace",
"path": "/src/bin.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bfops/opencl-raytrace path: /src/bin.rs
#![feature(repr_simd)]
extern crate cgmath;
#[macro_use]
extern crate glium;
extern crate glutin;
#[macro_use]
extern crate log;
extern crate opencl;
extern crate rand;
extern crate time;
<|fim_suffix|>fn main() {
main::main();
}<|fim_middle|>mod main;... | code_fim | easy | {
"lang": "rust",
"repo": "bfops/opencl-raytrace",
"path": "/src/bin.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ryPropertyFlagBits,
pub heapIndex: u32,
}<|fim_prefix|>// repo: hodasemi/Context path: /vulkan-sys/src/structs/core/memorytype.rs
use crate::prelude::*;
#[repr(C)]
#[derive(<|fim_middle|>Debug, Clone, Default, Copy)]
pub struct VkMemoryType {
pub propertyFlagBits: VkMemo | code_fim | medium | {
"lang": "rust",
"repo": "hodasemi/Context",
"path": "/vulkan-sys/src/structs/core/memorytype.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hodasemi/Context path: /vulkan-sys/src/structs/core/memorytype.rs
use crate::prelude::*;
#[repr(C)]
#[derive(Debug, Clone, Default, Copy)]
pub struct VkM<|fim_suffix|>ryPropertyFlagBits,
pub heapIndex: u32,
}<|fim_middle|>emoryType {
pub propertyFlagBits: VkMemo | code_fim | easy | {
"lang": "rust",
"repo": "hodasemi/Context",
"path": "/vulkan-sys/src/structs/core/memorytype.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let nics = unsafe { get_nic_addresses()? };
let mut nic_ptr: *const IP_ADAPTER_ADDRESSES = nics.as_ptr();
while !nic_ptr.is_null() {
unsafe {
let mut mir: MIB_IF_ROW2 = mem::MaybeUninit::uninit().assume_init();
mir.InterfaceLuid = mem::zeroed();
mir.InterfaceIndex = (*(nic_ptr)).u.s().IfInd... | code_fim | hard | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/network/sys/windows/net_io_counters.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while !nic_ptr.is_null() {
unsafe {
let mut mir: MIB_IF_ROW2 = mem::MaybeUninit::uninit().assume_init();
mir.InterfaceLuid = mem::zeroed();
mir.InterfaceIndex = (*(nic_ptr)).u.s().IfIndex;
match GetIfEntry2(&mut mir as *mut _) {
ERROR_SUCCESS => {
map.insert(
mir.InterfaceIn... | code_fim | hard | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/network/sys/windows/net_io_counters.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arturkow2000/rust-psutil path: /src/network/sys/windows/net_io_counters.rs
use std::collections::HashMap;
use std::{mem, ptr};
use winapi::shared::{
netioapi::{GetIfEntry2, MIB_IF_ROW2},
ntdef::ULONG,
winerror::{ERROR_BUFFER_OVERFLOW, ERROR_SUCCESS},
ws2def::AF_UNSPEC,
};
use winapi::um::ip... | code_fim | hard | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/network/sys/windows/net_io_counters.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for result in reader.records(&header) {
let record = result?;
writer.write_alignment_record(&header, &record)?;
}
writer.finish(&header)?;
Ok(())
}<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-bam/examples/bam_view.rs
//! Prints a BAM file in the SAM format.
//!
... | code_fim | medium | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-bam/examples/bam_view.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-bam/examples/bam_view.rs
//! Prints a BAM file in the SAM format.
//!
//! The result matches the output of `samtools view <src>`.
use std::{env, io};
<|fim_suffix|> let stdout = io::stdout().lock();
let mut writer = sam::Writer::new(stdout);
for resul... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-bam/examples/bam_view.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spazm/find-cargo-toml path: /src/lib.rs
use std::env::current_dir;
use std::io;
use std::path::{Path, PathBuf};
use std::fmt::Display;
pub fn find_config_toml() -> Result<(PathBuf), (io::Error)> {
//! Walks upward from `current_dir()` looking for the first `Cargo.toml` file.
find_file_u... | code_fim | hard | {
"lang": "rust",
"repo": "spazm/find-cargo-toml",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(find_file_upwards(&src, "lib.rs").unwrap(), expected);
//
let expected = Path::new("src/lib.rs")
.canonicalize()
.expect("relative path should turn into full path");
assert_eq!(find_file_upwards("src/", "lib.rs").unwrap(), expected);
... | code_fim | hard | {
"lang": "rust",
"repo": "spazm/find-cargo-toml",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hatsuyuki/cs4414 path: /ps0/tut1/find_collatz_memoized.rs
use std::env;
// Find the minimum number whose collatz sequence takes n steps
// to terminate.
// 17s for n = 500 and vector size = 10^7
fn main() {
let error = "Error: Please provide a number as an argument.";
<|fim_suffix|>fn col... | code_fim | hard | {
"lang": "rust",
"repo": "hatsuyuki/cs4414",
"path": "/ps0/tut1/find_collatz_memoized.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut a: Vec<u32> = vec![0; 10000000];
// println!("collatz of {} is {}", i, collatz(i, &mut a));
println!("{} is the lowest number with {} Collatz steps", find_collatz(i, &mut a), i);
}
fn collatz(mut n: u64, a: &mut Vec<u32>) -> u32 {
let l = a.len();
let mut i: usize;
le... | code_fim | medium | {
"lang": "rust",
"repo": "hatsuyuki/cs4414",
"path": "/ps0/tut1/find_collatz_memoized.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Crocodoctopus/Ezgl path: /src/shader.rs
use gl;
use gl::types::*;
use super::gl_shader_resource::*;
use std::ffi::OsStr;
use std::fs::File;
use std::io::prelude::*;
use std::path::*;
pub struct Shader {
pub(super) resource: GLShaderResource,
}
#[derive(Debug, Clone)]
pub enum ShaderError... | code_fim | hard | {
"lang": "rust",
"repo": "Crocodoctopus/Ezgl",
"path": "/src/shader.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // check for errors (this may not be necessary since opengl has an error callback)
unsafe {
let mut shader_compiler_success: i32 = 0;
gl::GetShaderiv(
resource.get_raw(),
gl::COMPILE_STATUS,
&mut shader_compiler_succes... | code_fim | hard | {
"lang": "rust",
"repo": "Crocodoctopus/Ezgl",
"path": "/src/shader.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let err_string = format!("?: {}", String::from_utf8(error_log).unwrap());
return Err(ShaderError::CompileError(err_string));
//return Err(path.to_str().append(String::from_utf8(error_log).unwrap()));
}
}
// return
Ok(Sha... | code_fim | hard | {
"lang": "rust",
"repo": "Crocodoctopus/Ezgl",
"path": "/src/shader.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DKFN/JiRust path: /src/main.rs
extern crate reqwest;
extern crate hyper;
extern crate base64;
extern crate clap;
use base64::encode;
fn main() {
let cli_conf = clap::App::new("JiRust")
.version("0.1.0")
.author("Valere Tetelin - Deadly :3 -")
.about("Formats your Ji... | code_fim | hard | {
"lang": "rust",
"repo": "DKFN/JiRust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> jira_mail: &str,
jira_pass: &str,
jira_project: &str)
{
let fin = format!("{}{}{}", jira_host, "rest/api/2/search?jql=project=", jira_project);
println!("Targetting URL : {}", fin);
let client = reqwest::Client::new();
let mut cred... | code_fim | hard | {
"lang": "rust",
"repo": "DKFN/JiRust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_config(path: &str) -> Result<Config> {
let f = File::open(path).with_context(|| format!("Couldn't open config file {}", path))?;
Ok(serde_yaml::from_reader(f)?)
}<|fim_prefix|>// repo: ZofiaZementa/killswitch-server path: /src/config.rs
use anyhow::{Context, Result};
use serde::Deseria... | code_fim | medium | {
"lang": "rust",
"repo": "ZofiaZementa/killswitch-server",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn ssh_config_default() -> String {
"/etc/killswitch/ssh/config".to_string()
}
pub fn get_config(path: &str) -> Result<Config> {
let f = File::open(path).with_context(|| format!("Couldn't open config file {}", path))?;
Ok(serde_yaml::from_reader(f)?)
}<|fim_prefix|>// repo: ZofiaZementa/kills... | code_fim | medium | {
"lang": "rust",
"repo": "ZofiaZementa/killswitch-server",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZofiaZementa/killswitch-server path: /src/config.rs
use anyhow::{Context, Result};
use serde::Deserialize;
use serde_yaml;
use std::{collections::BTreeMap, fs::File};
<|fim_suffix|>fn ssh_config_default() -> String {
"/etc/killswitch/ssh/config".to_string()
}
pub fn get_config(path: &str) ... | code_fim | hard | {
"lang": "rust",
"repo": "ZofiaZementa/killswitch-server",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mominul/giribus path: /src/auto/property.rs
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
u... | code_fim | hard | {
"lang": "rust",
"repo": "mominul/giribus",
"path": "/src/auto/property.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
ibus_sys::ibus_property_set_symbol(self.as_ref().to_glib_none().0, symbol.as_ref().to_glib_none().0);
}
}
fn set_tooltip<P: IsA<Text>>(&self, tooltip: &P) {
unsafe {
ibus_sys::ibus_property_set_tooltip(self.as_ref().to_glib_none().0, toolti... | code_fim | hard | {
"lang": "rust",
"repo": "mominul/giribus",
"path": "/src/auto/property.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Map of values, with separate key and value types
pub struct BinMap {
/// Type of map keys
pub ktype: BinType,
/// Type of map values
pub vtype: BinType,
pub(crate) values: Box<dyn Any>, // Any = Vec<(ktype, vtype)>
}
impl BinMap {
/// Downcast the map to a vector of `(key, v... | code_fim | hard | {
"lang": "rust",
"repo": "CommunityDragon/cdragon-rs",
"path": "/cdragon-prop/src/data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CommunityDragon/cdragon-rs path: /cdragon-prop/src/data.rs
//! Bin data definitions
use std::any::Any;
use num_enum::TryFromPrimitive;
use super::BinHashMappers;
use cdragon_hashes::{
define_hash_type,
HashOrStr,
bin::{BinHashKind, compute_binhash},
wad::compute_wad_hash,
};
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "CommunityDragon/cdragon-rs",
"path": "/cdragon-prop/src/data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(not(feature = "ink-as-dependency"))]
use ink_env::call::FromAccountId;
#[cfg(not(feature = "ink-as-dependency"))]
use crate::flip_on_me::CallerOfFlip;
#[ink(storage)]
#[derive(Default, ReentrancyGuardStorage)]
pub struct MyFlipper {
#[ReentrancyGuardStorageField... | code_fim | hard | {
"lang": "rust",
"repo": "pormeu/openbrush-contracts",
"path": "/examples/reentrancy-guard/flipper/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pormeu/openbrush-contracts path: /examples/reentrancy-guard/flipper/lib.rs
#![cfg_attr(not(feature = "std"), no_std)]
/// This is a stub implementation of contract with method `flip_on_me`.
/// We need this implementation to create wrapper for contract's account id.
/// With this wrapper, we ca... | code_fim | hard | {
"lang": "rust",
"repo": "pormeu/openbrush-contracts",
"path": "/examples/reentrancy-guard/flipper/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[ink(message)]
#[modifiers(non_reentrant)]
pub fn call_flip_on_me(&mut self, callee: AccountId) {
// This method will do a cross-contract call to callee account. It calls method `flip_on_me`.
// Callee contract during execution of `flip_on_me` will call `fl... | code_fim | hard | {
"lang": "rust",
"repo": "pormeu/openbrush-contracts",
"path": "/examples/reentrancy-guard/flipper/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let registry = Registry::new("https://registry-1.docker.io");
let image = registry
.image::<ImagePlatformSelector>("library/hello-world", "latest")
.expect("Could not get image");
println!("{:#?}", image.manifest());
println!("{:#?}", image.config());
for layer in ima... | code_fim | medium | {
"lang": "rust",
"repo": "theLastOfCats/opencontainers-rs",
"path": "/examples/manifest.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theLastOfCats/opencontainers-rs path: /examples/manifest.rs
use opencontainers::image::ImagePlatformSelector;
use opencontainers::Registry;
<|fim_suffix|> let registry = Registry::new("https://registry-1.docker.io");
let image = registry
.image::<ImagePlatformSelector>("library/h... | code_fim | medium | {
"lang": "rust",
"repo": "theLastOfCats/opencontainers-rs",
"path": "/examples/manifest.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set texture to nearest filtering using nearest mipmap.
pub fn nearest_mipmap_nearest(&self) {
unsafe {
gl::BindTexture(gl::TEXTURE_2D, self.id);
gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::NEAREST_MIPMAP_NEAREST as i32);
gl::TexPara... | code_fim | hard | {
"lang": "rust",
"repo": "trip-flip/sample-engine",
"path": "/sample-core/src/texture.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trip-flip/sample-engine path: /sample-core/src/texture.rs
use std::path::Path;
use std::ffi::c_void;
use gl::{
self,
types::{
GLuint
}
};
use image::{open as open_image,
DynamicImage as DI,
GenericImageView,
ColorType::*
};
/// A texture that gets wrapped onto a... | code_fim | hard | {
"lang": "rust",
"repo": "trip-flip/sample-engine",
"path": "/sample-core/src/texture.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thatmarkenglishguy/move_numeric_files path: /src/move_numeric_files/file_system/tests/file_adder.rs
#[cfg(test)]
pub(crate) mod tests {
use tempdir::TempDir;
pub(crate) struct SubdirectoryFileAdder {
sub_directory: std::path::PathBuf,
}
impl SubdirectoryFileAdder {
... | code_fim | hard | {
"lang": "rust",
"repo": "thatmarkenglishguy/move_numeric_files",
"path": "/src/move_numeric_files/file_system/tests/file_adder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl FileAdderOperations for TempFileAdder {
fn directory(&self) -> &std::path::Path {
self.directory.path()
}
}
impl FileAdderOperations for SubdirectoryFileAdder {
fn directory(&self) -> &std::path::Path {
self.sub_directory.as_path()
... | code_fim | hard | {
"lang": "rust",
"repo": "thatmarkenglishguy/move_numeric_files",
"path": "/src/move_numeric_files/file_system/tests/file_adder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sogapalag/contest path: /atcoder/abc035/b.rs
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
return ret;
}
#[allow(dead_code)]
fn getword() -> String {
l... | code_fim | medium | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/atcoder/abc035/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = getword();
let t: usize = parse(&getword());
let mut x = 0_i32;
let mut y = 0_i32;
let mut q = 0_i32;
for c in s.chars() {
match c {
'L' => x -= 1,
'R' => x += 1,
'U' => y += 1,
'D' => y -= 1,
'?' => q += 1... | code_fim | hard | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/atcoder/abc035/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let s = getword();
let t: usize = parse(&getword());
let mut x = 0_i32;
let mut y = 0_i32;
let mut q = 0_i32;
for c in s.chars() {
match c {
'L' => x -= 1,
'R' => x += 1,
'U' => y += 1,
'D' => y -= 1,
'... | code_fim | medium | {
"lang": "rust",
"repo": "sogapalag/contest",
"path": "/atcoder/abc035/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn shuffle<T, G: Rng64>(data: &mut [T], eng: &mut G) {
let n = data.len();
for i in 0..=(n - 2) {
let j = generate_uniform_u64(eng, (n-i-1) as u64) as usize + i;
data.swap(i, j);
}
}<|fim_prefix|>// repo: blindley/stdex path: /src/algorithms/mod.rs
use crate::random::{
... | code_fim | medium | {
"lang": "rust",
"repo": "blindley/stdex",
"path": "/src/algorithms/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod deflate;
pub use self::deflate::inflate;
pub fn shuffle<T, G: Rng64>(data: &mut [T], eng: &mut G) {
let n = data.len();
for i in 0..=(n - 2) {
let j = generate_uniform_u64(eng, (n-i-1) as u64) as usize + i;
data.swap(i, j);
}
}<|fim_prefix|>// repo: blindley/stdex path: /... | code_fim | easy | {
"lang": "rust",
"repo": "blindley/stdex",
"path": "/src/algorithms/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blindley/stdex path: /src/algorithms/mod.rs
use crate::random::{
generate_uniform_u64,
Rng64
};
<|fim_suffix|>mod deflate;
pub use self::deflate::inflate;
pub fn shuffle<T, G: Rng64>(data: &mut [T], eng: &mut G) {
let n = data.len();
for i in 0..=(n - 2) {
let j = gener... | code_fim | easy | {
"lang": "rust",
"repo": "blindley/stdex",
"path": "/src/algorithms/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if scenario.is_ok() {
// for car in scenario.unwrap().cars {
// CarCmdListController::create_car(&mut world, &mut physics_world, id_provider.clone(),
// car.pose, car.cmds, car.rgb);
// }
// }
// }
while let Some(e) = ... | code_fim | hard | {
"lang": "rust",
"repo": "clynamen/roadsim2d",
"path": "/src/bin/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clynamen/roadsim2d path: /src/bin/main.rs
#![feature(duration_as_u128)]
#![feature(fn_traits)]
#![feature(unboxed_closures)]
#[macro_use]
extern crate specs_derive;
extern crate nphysics2d;
// #[macro_use]
// extern crate rosrust;
extern crate piston_window;
extern crate piston;
extern crate ... | code_fim | hard | {
"lang": "rust",
"repo": "clynamen/roadsim2d",
"path": "/src/bin/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sat = solver.check_sat();
match sat {
Satisfiability::Sat => {
min_n = n;
last_solution = Some(Solution::new(&mut solver, students, teachers, rounds));
}
_ => max_n = n,
}
println!("n = {}: {:?}", n, s... | code_fim | hard | {
"lang": "rust",
"repo": "aochagavia/optimization-experiment",
"path": "/src/solver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aochagavia/optimization-experiment path: /src/solver.rs
use std::error::Error;
use std::fmt::Write;
use std::iter;
use crate::solution::Solution;
use crate::z3::{Satisfiability, Z3};
pub fn student_const(student: usize, round: usize, teacher: usize) -> String {
format!("s{}_a{}_t{}", stude... | code_fim | hard | {
"lang": "rust",
"repo": "aochagavia/optimization-experiment",
"path": "/src/solver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut min_n = 0;
let mut max_n = (students * (students - 1)) / 2;
let mut n;
let mut last_solution = None;
println!("Start binary search with min_n = {} and max_n = {}", min_n, max_n);
while min_n + 1 < max_n {
n = (min_n + max_n) / 2;
// Save current state, so w... | code_fim | hard | {
"lang": "rust",
"repo": "aochagavia/optimization-experiment",
"path": "/src/solver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> val, Val, ValMem(MemLit(1, 1)));
mips_ast_test!(val_mem_rrr5, "rrr5", val, Val, ValMem(MemLit(5, 2)));
mips_ast_test!(val_mem_x, "x", val, Val, ValMem(MemAlias("x".into())));<|fim_prefix|>// repo: nilsso/mips-rs path: /mips-parser/tests/val.rs
#![feature(cus... | code_fim | hard | {
"lang": "rust",
"repo": "nilsso/mips-rs",
"path": "/mips-parser/tests/val.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>al_lit_neg_801_75_e_neg_7, "-801.75e-7", val, Val, ValLit(-0.000080175));
mips_ast_test!(val_mem_r0, "r0", val, Val, ValMem(MemLit(0, 0)));
mips_ast_test!(val_mem_rr1, "rr1", val, Val, ValMem(MemLit(1, 1)));
mips_ast_test!(val_mem_rrr5, "rrr5", ... | code_fim | hard | {
"lang": "rust",
"repo": "nilsso/mips-rs",
"path": "/mips-parser/tests/val.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilsso/mips-rs path: /mips-parser/tests/val.rs
#![feature(custom_inner_attributes)]
#![rustfmt::skip::macros(mips_ast_test)]
use mips_parser::{ast::all_node_variants::*, prelude::*, Rule::*};
use util::mips_ast_test;
mips_ast_test!(val_lit_37, "37", <|fim_suffix|>al_lit_neg_801_... | code_fim | hard | {
"lang": "rust",
"repo": "nilsso/mips-rs",
"path": "/mips-parser/tests/val.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let guess: u32 = guess.trim().parse() // Checks the guess is a 32 bit unsigned int
.ok()
.expect("Please type a number!"); // unwraps in the event of the above being not true
println!("You guessed: {}", guess);
println!("My random number: {}", secret_number);
match gues... | code_fim | hard | {
"lang": "rust",
"repo": "JamesRocker-Simply/rust_levelup",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JamesRocker-Simply/rust_levelup path: /src/main.rs
// use srd is for the rust standard library
use std::io; // io functionality (e.g. read and write)
use std::cmp::Ordering; // result of a a comparison between two values
use rand::Rng; //
extern crate rand;
fn main() {
<|fim_suffix|> mat... | code_fim | hard | {
"lang": "rust",
"repo": "JamesRocker-Simply/rust_levelup",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iptq/flubber path: /flubber-irc/src/errors.rs
use irc::error::IrcError;
<|fim_suffix|> Error::Irc(err)
}
}<|fim_middle|>#[derive(Debug)]
pub enum Error {
Irc(IrcError),
}
impl From<IrcError> for Error {
fn from(err: IrcError) -> Self {
| code_fim | medium | {
"lang": "rust",
"repo": "iptq/flubber",
"path": "/flubber-irc/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iptq/flubber path: /flubber-irc/src/errors.rs
use irc::error::IrcError;
<|fim_suffix|>impl From<IrcError> for Error {
fn from(err: IrcError) -> Self {
Error::Irc(err)
}
}<|fim_middle|>#[derive(Debug)]
pub enum Error {
Irc(IrcError),
}
| code_fim | easy | {
"lang": "rust",
"repo": "iptq/flubber",
"path": "/flubber-irc/src/errors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<IrcError> for Error {
fn from(err: IrcError) -> Self {
Error::Irc(err)
}
}<|fim_prefix|>// repo: iptq/flubber path: /flubber-irc/src/errors.rs
use irc::error::IrcError;
<|fim_middle|>#[derive(Debug)]
pub enum Error {
Irc(IrcError),
}
| code_fim | easy | {
"lang": "rust",
"repo": "iptq/flubber",
"path": "/flubber-irc/src/errors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (i, j) = idx;
&mut self.data[i + self.size_x * j]
}
}
impl IndexMut<usize> for Array2D {
#[inline]
fn index_mut(&mut self, idx: usize) -> &mut f64 {
&mut self.data[idx]
}
}<|fim_prefix|>// repo: Debilski/simple-benchmarks path: /rust/rd2d/src/lib.rs
#[cfg(test... | code_fim | hard | {
"lang": "rust",
"repo": "Debilski/simple-benchmarks",
"path": "/rust/rd2d/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Debilski/simple-benchmarks path: /rust/rd2d/src/lib.rs
#[cfg(test)]
mod tests {
#[test]
fn it_works() {}
}
extern crate time;
pub struct AutoTimer {
start: time::SteadyTime,
}
impl AutoTimer {
pub fn new() -> AutoTimer {
AutoTimer {
start: time::SteadyTime::... | code_fim | hard | {
"lang": "rust",
"repo": "Debilski/simple-benchmarks",
"path": "/rust/rd2d/src/lib.rs",
"mode": "psm",
"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.