text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> pub fn name<'a>(&'a self) -> &'a str {
&self.name[..]
}
pub fn reset_name(&mut self) {
self.name = Self::generate_name();
}
fn generate_name() -> String {
// A robot name consists of 2 letters followed by 3 digits
let mut name = String::new();
... | code_fim | medium | {
"lang": "rust",
"repo": "iacsa/exercism-solutions",
"path": "/rust/robot-name/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iacsa/exercism-solutions path: /rust/robot-name/src/lib.rs
use rand::prelude::*;
const DIGITS: &'static [char; 10] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
const LETTERS: &'static [char; 26] = &[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', '... | code_fim | medium | {
"lang": "rust",
"repo": "iacsa/exercism-solutions",
"path": "/rust/robot-name/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn generate_name() -> String {
// A robot name consists of 2 letters followed by 3 digits
let mut name = String::new();
name.push(*LETTERS.choose(&mut thread_rng()).unwrap());
name.push(*LETTERS.choose(&mut thread_rng()).unwrap());
name.push(*DIGITS.choose(&mut ... | code_fim | medium | {
"lang": "rust",
"repo": "iacsa/exercism-solutions",
"path": "/rust/robot-name/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: opp11/chemtool2 path: /src/main.rs
#![allow(unused_features)] // so we can still feature(os) when testing
#![feature(collections, path, io, core, os, plugin, env)]
extern crate getopts;
use getopts::Options;
use std::env;
use parser::Parser;
use database::ElemDatabase;
use error::{CTResult, CTE... | code_fim | hard | {
"lang": "rust",
"repo": "opp11/chemtool2",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn balance_cmd(args: &[String]) -> CTResult<()> {
if args.len() < 1 {
Err(CTError {
kind: UsageError,
desc: "Missing reaction.".to_string(),
pos: None,
})
} else if args.len() > 1 {
Err(CTError {
kind: UsageError,
... | code_fim | hard | {
"lang": "rust",
"repo": "opp11/chemtool2",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AdamLatos/RaytracingInOneWeekend path: /src/utils.rs
pub const PI: f64 = std::f64::consts::PI;
pub const INF: f64 = std::f64::INFINITY;
pub fn deg_to_rad(degrees: f64) -> f64 {
return degrees * PI / 180.0;
}
#[allow(dead_code)]
fn rad_to_deg(radians: f64) -> f64 {
<|fim_suffix|>pub fn clam... | code_fim | easy | {
"lang": "rust",
"repo": "AdamLatos/RaytracingInOneWeekend",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn clamp(x: f64, min: f64, max: f64) -> f64 {
if x < min {
min
} else if x > max {
max
} else {
x
}
}<|fim_prefix|>// repo: AdamLatos/RaytracingInOneWeekend path: /src/utils.rs
pub const PI: f64 = std::f64::consts::PI;
pub const INF: f64 = std::f64::INFINITY;
... | code_fim | easy | {
"lang": "rust",
"repo": "AdamLatos/RaytracingInOneWeekend",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreddieRidell/hypertask path: /rust/hypertask_sync_server/src/server.rs
use crate::cli_args::CliArgs;
use crate::sync_secret;
use futures::future::BoxFuture;
use hypertask_engine::prelude::*;
use hypertask_task_io_operations::{delete_task, get_input_tasks, get_task, put_task};
use std::collectio... | code_fim | hard | {
"lang": "rust",
"repo": "FreddieRidell/hypertask",
"path": "/rust/hypertask_sync_server/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn start(config: CliArgs) -> HyperTaskResult<()> {
info!("starting http server");
let hostname = config.hostname.as_ref().cloned().unwrap_or_else(|| {
info!("no host name provided, falling back to `localhost`");
"localhost".to_string()
});
let port = config.port... | code_fim | hard | {
"lang": "rust",
"repo": "FreddieRidell/hypertask",
"path": "/rust/hypertask_sync_server/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Build the trait implementation
item
}<|fim_prefix|>// repo: fernandoalex/stuff path: /rust/example_macros/make_hello/src/lib.rs
extern crate proc_macro;
use proc_macro::TokenStream;
//use quote::quote;
<|fim_middle|>#[proc_macro_attribute]
pub fn make_hello(_attr: TokenStream, item: TokenStr... | code_fim | medium | {
"lang": "rust",
"repo": "fernandoalex/stuff",
"path": "/rust/example_macros/make_hello/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fernandoalex/stuff path: /rust/example_macros/make_hello/src/lib.rs
extern crate proc_macro;
use proc_macro::TokenStream;
//use quote::quote;
<|fim_suffix|> // Build the trait implementation
item
}<|fim_middle|>#[proc_macro_attribute]
pub fn make_hello(_attr: TokenStream, item: TokenStr... | code_fim | medium | {
"lang": "rust",
"repo": "fernandoalex/stuff",
"path": "/rust/example_macros/make_hello/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andruhon/rust-in-node-examples path: /src/embed.rs
#![feature(alloc_system)]
#![feature(const_fn)]
extern crate libc;
use libc::{c_char, c_int, c_double};
use std::ffi::{CStr,CString};
use std::vec::{Vec};
use std::{mem,thread};
use std::time::Duration;
use std::sync::{Mutex, Arc};
// #[no_m... | code_fim | hard | {
"lang": "rust",
"repo": "andruhon/rust-in-node-examples",
"path": "/src/embed.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe{ std::ptr::copy(res.as_ptr(), dst, res_size); };
return res_size as c_int;
}
#[repr(C)]
pub struct SomeStruct {
some_item: c_int,
another_item: c_int,
test: c_int,
float_item: c_double
}
#[no_mangle]
pub extern "C" fn rs_struct_out() -> SomeStruct {
let sss = SomeStr... | code_fim | hard | {
"lang": "rust",
"repo": "andruhon/rust-in-node-examples",
"path": "/src/embed.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sam-Jeston/locker path: /src/database/messages.rs
extern crate diesel;
use database::establish_connection;
use database::models::*;
use database::schema::messages;
use database::schema::messages::dsl::*;
use diesel::prelude::*;
use diesel::RunQueryDsl;
pub fn get_messsages_for_channel(chan_id:... | code_fim | hard | {
"lang": "rust",
"repo": "Sam-Jeston/locker",
"path": "/src/database/messages.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn returns_all_messages_for_a_channel() {
truncate_tables();
let chan = create_channel("foo", "bar");
let chan2 = create_channel("baz", "bar");
create_message(chan.id, "message", "nonce");
create_message(chan2.id, "message2", "nonce2");
let... | code_fim | hard | {
"lang": "rust",
"repo": "Sam-Jeston/locker",
"path": "/src/database/messages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn routes() -> impl HttpServiceFactory {
web::scope("/api")
.service(hello)
.service(authorized)
.service(authentication::routes())
.service(channels::routes())
.service(channel::routes())
}<|fim_prefix|>// repo: viktorstrate/lingo path: /api/src/routes/mod... | code_fim | hard | {
"lang": "rust",
"repo": "viktorstrate/lingo",
"path": "/api/src/routes/mod_old.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(HttpResponse::Ok().body(format!("Welcome: {}", &user.username)))
}
pub fn routes() -> impl HttpServiceFactory {
web::scope("/api")
.service(hello)
.service(authorized)
.service(authentication::routes())
.service(channels::routes())
.service(channel::rout... | code_fim | medium | {
"lang": "rust",
"repo": "viktorstrate/lingo",
"path": "/api/src/routes/mod_old.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: viktorstrate/lingo path: /api/src/routes/mod_old.rs
use actix_web::{dev::HttpServiceFactory, get, web, HttpResponse, Responder};
<|fim_suffix|>pub fn routes() -> impl HttpServiceFactory {
web::scope("/api")
.service(hello)
.service(authorized)
.service(authentication... | code_fim | hard | {
"lang": "rust",
"repo": "viktorstrate/lingo",
"path": "/api/src/routes/mod_old.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone)]
pub struct Intersection {
pub position: Point3f,
pub normal: Vec3f
}<|fim_prefix|>// repo: wbrbr/rusttracer path: /src/types.rs
use cgmath::{Vector3, Matrix4, Point3, Point2};
use cgmath::prelude::*;
pub type Vec3f = Vector3<f32>;
pub type Matrix4f = Matrix4<f32>;
pub type... | code_fim | medium | {
"lang": "rust",
"repo": "wbrbr/rusttracer",
"path": "/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn at(&self, t: f32) -> Point3f {
self.origin + t * self.direction
}
}
#[derive(Copy, Clone)]
pub struct Intersection {
pub position: Point3f,
pub normal: Vec3f
}<|fim_prefix|>// repo: wbrbr/rusttracer path: /src/types.rs
use cgmath::{Vector3, Matrix4, Point3, Point2};
use cgmath::prelud... | code_fim | hard | {
"lang": "rust",
"repo": "wbrbr/rusttracer",
"path": "/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wbrbr/rusttracer path: /src/types.rs
use cgmath::{Vector3, Matrix4, Point3, Point2};
use cgmath::prelude::*;
pub type Vec3f = Vector3<f32>;
pub type Matrix4f = Matrix4<f32>;
pub type Point2f = Point2<f32>;
pub type Point3f = Point3<f32>;
#[derive(Copy, Clone)]
pub struct Ray {
pub origin: Poi... | code_fim | medium | {
"lang": "rust",
"repo": "wbrbr/rusttracer",
"path": "/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/csen/status.rs
#[doc = "Reader of register STATUS"]
pub type R = crate::R<u32, super::STATUS>;
#[doc = "Reader of field `CSENBUSY`"]
pub type CSENBUSY_R = crate::R<bool, b<|fim_suffix|>fn csenbusy(&self) -> CSENBUSY_R { CSENBUSY_R::new((self.bits & ... | code_fim | medium | {
"lang": "rust",
"repo": "pablo-mansanet-bluefruit/efm32gg11b",
"path": "/src/csen/status.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn csenbusy(&self) -> CSENBUSY_R { CSENBUSY_R::new((self.bits & 0x01) != 0) }
}<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/csen/status.rs
#[doc = "Reader of register STATUS"]
pub type R = crate::R<u32, super::STATUS><|fim_middle|>;
#[doc = "Reader of field `CSENBUSY`"]
pub type ... | code_fim | medium | {
"lang": "rust",
"repo": "pablo-mansanet-bluefruit/efm32gg11b",
"path": "/src/csen/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/failure_ext/src/context_streams.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* Licens... | code_fim | hard | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/failure_ext/src/context_streams.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
inner: stream,
displayable,
}
}
}
impl<A, E, D> Stream for ContextStream<A, D>
where
A: Stream<Error = E>,
E: Into<anyhow::Error>,
D: Display + Clone + Send + Sync + 'static,
{
type Item = A::Item;
type Error = anyhow::Error;
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/failure_ext/src/context_streams.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bgaster/audio_anywhere path: /plugins/gain/src/lib.rs
#![feature(wasm_target_feature)]
// ALL OF THE FOLLOWING WARNINGS NEED TO BE ADDRESSED IN THE FAUST COMPILER
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_parens)]
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![all... | code_fim | hard | {
"lang": "rust",
"repo": "bgaster/audio_anywhere",
"path": "/plugins/gain/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub fn handle_note_on(mn: i32, vel: f32) {
unsafe { ENGINE.handle_note_on(mn, vel); }
}
#[no_mangle]
pub fn handle_note_off(mn: i32, vel: f32) {
unsafe { ENGINE.handle_note_off(mn, vel); }
}
#[no_mangle]
pub fn get_voices() -> i32 {
unsafe { ENGINE.get_voices() }
}
#[no_mangle]... | code_fim | hard | {
"lang": "rust",
"repo": "bgaster/audio_anywhere",
"path": "/plugins/gain/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for l0 in 0..2 {
self.fRec0[l0 as usize] = 0.0;
}
}
fn instance_constants(&mut self, sample_rate: i32) {
self.fSampleRate = sample_rate;
}
fn instance_init(&mut self, sample_rate: i32) {
self.instance_constants(sample_rate);
self.instance_reset_params();
self.instance_clear();
}
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "bgaster/audio_anywhere",
"path": "/plugins/gain/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hmeyer/tessellation path: /src/qef.rs
use crate::{plane::Plane, RealField};
use bbox::BoundingBox;
use nalgebra as na;
use num_traits::Float;
use std::{convert, fmt::Debug};
pub const EPSILON: f32 = 1e-10;
/// Quadratic error function
#[derive(Clone, Debug)]
pub struct Qef<S: RealField + Debug... | code_fim | hard | {
"lang": "rust",
"repo": "hmeyer/tessellation",
"path": "/src/qef.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut qef = Qef::new(
&[
Plane {
p: na::Point3::new(1., 0., 0.),
n: na::Vector3::new(0., 1., 1.).normalize(),
},
Plane {
p: na::Point3::new(0., 1., 0.),
n: ... | code_fim | hard | {
"lang": "rust",
"repo": "hmeyer/tessellation",
"path": "/src/qef.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn points_on_origin_solution_on_cube() {
let mut qef = Qef::new(
&[
Plane {
p: na::Point3::new(1., 0., 0.),
n: na::Vector3::new(1., 0., 0.),
},
Plane {
p: na::Poi... | code_fim | hard | {
"lang": "rust",
"repo": "hmeyer/tessellation",
"path": "/src/qef.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // sigh
let b_there_or_b = Rectangle::square(4);
let c_u_ther = Rectangle::also_square(9);
}<|fim_prefix|>// repo: dmgolembiowski/RustyKitchen path: /wat/associated_func.rs
// Continuing this theme of Rectangles as structs, we have
struct Rectangle {
width: u32,
height: u32,
}
impl ... | code_fim | medium | {
"lang": "rust",
"repo": "dmgolembiowski/RustyKitchen",
"path": "/wat/associated_func.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
// sigh
let b_there_or_b = Rectangle::square(4);
let c_u_ther = Rectangle::also_square(9);
}<|fim_prefix|>// repo: dmgolembiowski/RustyKitchen path: /wat/associated_func.rs
// Continuing this theme of Rectangles as structs, we have
struct Rectangle {
width: u32,
height: u... | code_fim | medium | {
"lang": "rust",
"repo": "dmgolembiowski/RustyKitchen",
"path": "/wat/associated_func.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmgolembiowski/RustyKitchen path: /wat/associated_func.rs
// Continuing this theme of Rectangles as structs, we have
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn square(size: u32) -> Rectangle {
<|fim_suffix|> Rectangle { width: size, height: size }
}... | code_fim | medium | {
"lang": "rust",
"repo": "dmgolembiowski/RustyKitchen",
"path": "/wat/associated_func.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ciiol/icfpc2020 path: /src/interactor.rs
use crate::solver::{self, Solver, Value};
use std::fmt;
pub struct Interactor {
solver: Solver,
protocol: solver::Ref,
state: Value,
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Point {
pub x: i64,
pub y: i64,
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "ciiol/icfpc2020",
"path": "/src/interactor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use crate::ast;
use crate::parser::parse;
fn rules(input: &[&str]) -> Vec<solver::Rule> {
input
.iter()
.map(|s| solver::Rule::from(ast::build_define_tree(&parse(s)).unwrap()))
.collect()
}
fn with... | code_fim | hard | {
"lang": "rust",
"repo": "ciiol/icfpc2020",
"path": "/src/interactor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clay53/from_anarchy path: /from_anarchy_lib/src/commands.rs
use crate::*;
use std::borrow::Cow;
use serde::{Serialize, Deserialize};
pub trait Command<'a>: Serialize + Deserialize<'a> + std::fmt::Debug {
fn to_bin(&self) -> Vec<u8> {
bincode::serialize(self).unwrap()
}
fn f... | code_fim | medium | {
"lang": "rust",
"repo": "clay53/from_anarchy",
"path": "/from_anarchy_lib/src/commands.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)]
pub enum ServerCommand {
RegisterPlayer
}
impl Command<'_> for ServerCommand {}
#[derive(Serialize, Deserialize, Debug)]
pub enum ClientCommand<'a> {
FirstSync(FirstSyncData<'a>)
}
impl Command<'_> for ClientCommand<'_> {}
#[derive(Serialize, Deserialize,... | code_fim | medium | {
"lang": "rust",
"repo": "clay53/from_anarchy",
"path": "/from_anarchy_lib/src/commands.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)]
pub struct FirstSyncData<'a> {
pub player_entity_id: EntityId,
pub map: Cow<'a, TileMap>,
pub entities: Cow<'a, EntityMap>,
}<|fim_prefix|>// repo: clay53/from_anarchy path: /from_anarchy_lib/src/commands.rs
use crate::*;
use std::borrow::Cow;
use serd... | code_fim | hard | {
"lang": "rust",
"repo": "clay53/from_anarchy",
"path": "/from_anarchy_lib/src/commands.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kamirr/blogrs_backend path: /src/auth.rs
use crate::db::connection::*;
use crate::db::special::*;
use rocket::State;
use rand::random;
pub type AuthKey = String;
fn random_hex(count: u32) -> String {
let mut res = AuthKey::new();
for _ in 0 .. count {
let n = random::<u8>();
... | code_fim | hard | {
"lang": "rust",
"repo": "kamirr/blogrs_backend",
"path": "/src/auth.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> res.push_str(&s);
}
res
}
pub fn verify_auth_key(key: AuthKey, pool: &State<Pool>) -> bool {
match Special::new(pool).get("current_auth") {
Some(key_in_db) => key == key_in_db,
None => false
}
}
pub fn generate_auth_key(pool: &State<Pool>) -> AuthKey {
let re... | code_fim | hard | {
"lang": "rust",
"repo": "kamirr/blogrs_backend",
"path": "/src/auth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut res = AuthKey::new();
for _ in 0 .. count {
let n = random::<u8>();
let s = if n < 16 {
format!("0{:x?}", n)
} else {
format!("{:x?}", n)
};
res.push_str(&s);
}
res
}
pub fn verify_auth_key(key: AuthKey, pool: &Stat... | code_fim | medium | {
"lang": "rust",
"repo": "kamirr/blogrs_backend",
"path": "/src/auth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfelsche/simd-json path: /src/stage2.rs
c = *get!(input2, idx);
} else {
fail!(ErrorType::Syntax);
}
};
}
macro_rules! goto {
($state:expr) => {{
state = $state;
... | code_fim | hard | {
"lang": "rust",
"repo": "mfelsche/simd-json",
"path": "/src/stage2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfelsche/simd-json path: /src/stage2.rs
[cfg(not(feature = "safe"))]
macro_rules! get {
($a:expr, $i:expr) => {{
unsafe { $a.get_unchecked($i) }
}};
}
#[cfg(feature = "safe")]
macro_rules! get_mut {
($a:expr, $i:expr) => {
&mut $a[$i]
};
}
#[cfg(not(feature = "s... | code_fim | hard | {
"lang": "rust",
"repo": "mfelsche/simd-json",
"path": "/src/stage2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
use self::State::{MainArraySwitch, ObjectKey, ScopeEnd};
match state {
////////////////////////////// OBJECT STATES /////////////////////////////
ObjectKey => {
update_char!();
if unlikely!(c != ... | code_fim | hard | {
"lang": "rust",
"repo": "mfelsche/simd-json",
"path": "/src/stage2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-bakery/nom path: /src/character/complete.rs
parser(input: &str) -> IResult<&str, &str> {
/// oct_digit1(input)
/// }
///
/// assert_eq!(parser("21cZ"), Ok(("cZ", "21")));
/// assert_eq!(parser("H2"), Err(Err::Error(Error::new("H2", ErrorKind::OctDigit))));
/// assert_eq!(parser(""), Err... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bakery/nom",
"path": "/src/character/complete.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Recognizes one or more spaces, tabs, carriage returns and line feeds.
///
/// *Complete version*: will return an error if there's not enough input data,
/// or the whole input if no terminating token is found (a non space character).
/// # Example
///
/// ```
/// # use nom::{Err, error::{Error, ErrorK... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bakery/nom",
"path": "/src/character/complete.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Recognizes one or more octal characters: 0-7
///
/// *Complete version*: Will return an error if there's not enough input data,
/// or the whole input if no terminating token is found (a non octal digit character).
/// # Example
///
/// ```
/// # use nom::{Err, error::{Error, ErrorKind}, IResult, Need... | code_fim | hard | {
"lang": "rust",
"repo": "rust-bakery/nom",
"path": "/src/character/complete.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub fn apply(&self, aggregate: Option<TAggregate>, event: &TEvent) -> Option<TAggregate> {
// (self.handler)(aggregate, event)
// }
// }<|fim_prefix|>// repo: b-vennes/event_biscuit path: /src/event_handler.rs
pub trait EventHandler<TEvent, TState> {
fn apply(event: &TEvent, state:... | code_fim | hard | {
"lang": "rust",
"repo": "b-vennes/event_biscuit",
"path": "/src/event_handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// impl<TAggregate, TEvent> EventHandler<TAggregate, TEvent> {
// pub fn new(handler: fn(Option<TAggregate>, &TEvent) -> Option<TAggregate>) -> Self {
// EventHandler {
// handler
// }
// }
// pub fn apply(&self, aggregate: Option<TAggregate>, event: &TEvent) -> Op... | code_fim | medium | {
"lang": "rust",
"repo": "b-vennes/event_biscuit",
"path": "/src/event_handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: b-vennes/event_biscuit path: /src/event_handler.rs
pub trait EventHandler<TEvent, TState> {
fn apply(event: &TEvent, state: Option<TState>) -> Option<TState>;
}
<|fim_suffix|>// pub fn apply(&self, aggregate: Option<TAggregate>, event: &TEvent) -> Option<TAggregate> {
// (self.h... | code_fim | hard | {
"lang": "rust",
"repo": "b-vennes/event_biscuit",
"path": "/src/event_handler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn part2(stride : usize) {
let mut buf_len = 1;
let mut pos = 0;
let mut pos1_value = 0;
for i in 0..50000000 {
pos = (pos + stride) % buf_len + 1;
if pos == 1 {
pos1_value = i + 1;
}
buf_len += 1;
}
println!("Part 2: {}", pos1_value);
}
pub fn solve() {
let stdin = io::stdin();
let in... | code_fim | medium | {
"lang": "rust",
"repo": "galenelias/AdventOfCode_2017",
"path": "/src/Day17/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: galenelias/AdventOfCode_2017 path: /src/Day17/mod.rs
use std::io::{self, BufRead};
fn part1(stride : usize) {
let mut buffer : Vec<usize> = Vec::new();
let mut pos = 0;
buffer.push(0);
for i in 0..2017 {
pos = (pos + stride) % buffer.len() + 1;
buffer.insert(pos, i + 1);
}
match buff... | code_fim | hard | {
"lang": "rust",
"repo": "galenelias/AdventOfCode_2017",
"path": "/src/Day17/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m8e/bsync path: /bsync/src/cmd_list.rs
use serde::Serialize;
use std::path::PathBuf;
use anyhow::Result;
use chrono::NaiveDateTime;
use prettytable::{cell, row, Table};
use structopt::StructOpt;
<|fim_suffix|> if self.json {
let out: Vec<OutputEntry> = cp_list
.iter()
... | code_fim | hard | {
"lang": "rust",
"repo": "m8e/bsync",
"path": "/bsync/src/cmd_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Listcmd {
pub fn run(&self) -> Result<()> {
let db = Database::open_file(&self.db, false)?;
let cp_list = db.list_consistent_point();
if self.json {
let out: Vec<OutputEntry> = cp_list
.iter()
.map(|x| OutputEntry {
lsn: x.lsn,
created_at: x.cr... | code_fim | medium | {
"lang": "rust",
"repo": "m8e/bsync",
"path": "/bsync/src/cmd_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stuartlynn/geozero path: /geozero/src/gdal/gdal_writer.rs
use crate::error::{GeozeroError, Result};
use crate::{CoordDimensions, FeatureProcessor, GeomProcessor, PropertyProcessor};
use gdal::vector::Geometry;
use gdal_sys::OGRwkbGeometryType;
/// Generator for GDAL geometry type.
pub struct Gd... | code_fim | hard | {
"lang": "rust",
"repo": "stuartlynn/geozero",
"path": "/geozero/src/gdal/gdal_writer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn line_geom() {
let geojson = GeoJson(r#"{"type": "LineString", "coordinates": [[1,1], [2,2]]}"#);
let wkt = "LINESTRING (1 1,2 2)";
let geom = geojson.to_gdal().unwrap();
assert_eq!(geom.wkt().unwrap(), wkt);
}
// TODO: 3D output is broken!
//... | code_fim | hard | {
"lang": "rust",
"repo": "stuartlynn/geozero",
"path": "/geozero/src/gdal/gdal_writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let geojson = GeoJson(
r#"{"type": "MultiPolygon", "coordinates": [[[[0,0],[0,1],[1,1],[1,0],[0,0]]]]}"#,
);
let wkt = "MULTIPOLYGON (((0 0,0 1,1 1,1 0,0 0)))";
let geom = geojson.to_gdal().unwrap();
assert_eq!(geom.wkt().unwrap(), wkt);
}
// #[... | code_fim | hard | {
"lang": "rust",
"repo": "stuartlynn/geozero",
"path": "/geozero/src/gdal/gdal_writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `TX_START`"]
pub type TX_START_R = crate::R<bool, TX_START_A>;
impl TX_START_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<bool, TX_START_A> {
use crate::Variant::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanfisher/max32650-rs",
"path": "/src/spid/ctrl1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonathanfisher/max32650-rs path: /src/spid/ctrl1.rs
riant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TIMER_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Timer is disabled."]
#[inline(always)]
pub fn dis(self) ->... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanfisher/max32650-rs",
"path": "/src/spid/ctrl1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `SS_CTRL`"]
pub type SS_CTRL_R = crate::R<bool, SS_CTRL_A>;
impl SS_CTRL_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> SS_CTRL_A {
match self.bits {
false => SS_CTRL_A::DE... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanfisher/max32650-rs",
"path": "/src/spid/ctrl1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apoloval/simproc path: /src/bin/spasm/asm/inst/full.rs
. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use simproc::inst::*;
use simproc::mem::*;
use asm::expr::*;
use asm::inst::*;
pub struct InstAssembler<E: ExprAssembler> {
... | code_fim | hard | {
"lang": "rust",
"repo": "apoloval/simproc",
"path": "/src/bin/spasm/asm/inst/full.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[test]
fn should_asm_rjmp() { should_asm_inst_raddr(Inst::Rjmp, Inst::Rjmp); }
#[test]
fn should_asm_ijmp() { should_asm_inst_areg(Inst::Ijmp, Inst::Ijmp); }
#[test]
fn should_asm_call() { should_asm_inst_addr(Inst::Call, Inst::Call); }
#[test]
fn should_asm_rcall() { ... | code_fim | hard | {
"lang": "rust",
"repo": "apoloval/simproc",
"path": "/src/bin/spasm/asm/inst/full.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.next_areg.push_back(areg);
}
fn with_imm(&mut self, imm: Result<Immediate, ExprAssembleError>) {
self.next_imm.push_back(imm);
}
fn with_addr(&mut self, addr: Result<Addr, ExprAssembleError>) {
self.next_addr.push_back(addr);
... | code_fim | hard | {
"lang": "rust",
"repo": "apoloval/simproc",
"path": "/src/bin/spasm/asm/inst/full.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ezaanm/money-market-contracts path: /contracts/market/examples/schema.rs
use std::env::current_dir;
use std::fs::create_dir_all;
use cosmwasm_schema::{export_schema, remove_schemas, schema_for};
<|fim_suffix|> export_schema(&schema_for!(InitMsg), &out_dir);
export_schema(&schema_for!(Ha... | code_fim | hard | {
"lang": "rust",
"repo": "ezaanm/money-market-contracts",
"path": "/contracts/market/examples/schema.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> export_schema(&schema_for!(InitMsg), &out_dir);
export_schema(&schema_for!(HandleMsg), &out_dir);
export_schema(&schema_for!(Cw20HookMsg), &out_dir);
export_schema(&schema_for!(QueryMsg), &out_dir);
export_schema(&schema_for!(ConfigResponse), &out_dir);
export_schema(&schema_for!(S... | code_fim | medium | {
"lang": "rust",
"repo": "ezaanm/money-market-contracts",
"path": "/contracts/market/examples/schema.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fruitbox12/hypercore-wasm-experiments path: /src/hypercore.rs
use futures::channel::mpsc::UnboundedSender as Sender;
use futures::lock::Mutex;
use futures::sink::SinkExt;
use futures::stream::StreamExt;
use hypercore_protocol::schema::*;
use hypercore_protocol::{discovery_key, Channel, Duplex, E... | code_fim | hard | {
"lang": "rust",
"repo": "fruitbox12/hypercore-wasm-experiments",
"path": "/src/hypercore.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let next = msg.index + 1;
if state.remote_head >= next {
// Request next data block.
let msg = Request {
index: next,
bytes: None,
hash: None,
nodes: None,
};
channel.request(msg... | code_fim | hard | {
"lang": "rust",
"repo": "fruitbox12/hypercore-wasm-experiments",
"path": "/src/hypercore.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut res = base.clone();
let mut i = (n.len() - 2) as isize;
while i >= 0 {
res = f.square(&res);
if n[i as usize] == BigInt::one() {
res = f.mul(&res, &base);
}
i -= 1;
}
return res;
}<|fim_prefix|>// repo: Sotatek-DucPham/mimc-hash path... | code_fim | medium | {
"lang": "rust",
"repo": "Sotatek-DucPham/mimc-hash",
"path": "/src/futils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sotatek-DucPham/mimc-hash path: /src/futils.rs
use crate::f1field::ZqField;
use crate::scalar;
use num_bigint::BigInt;
use num_traits::One;
use num_traits::Zero;
<|fim_suffix|> let mut res = base.clone();
let mut i = (n.len() - 2) as isize;
while i >= 0 {
res = f.square(&res)... | code_fim | hard | {
"lang": "rust",
"repo": "Sotatek-DucPham/mimc-hash",
"path": "/src/futils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut state: State = toml::from_str(&TOML).unwrap();
assert_eq!("/this/is/path/2", state.backup_paths.last().unwrap());
state.remove("/this/is/path/2").unwrap();
let state: State = State::load();
assert_eq!(1, state.backup_paths.len());
assert_eq!("/this/... | code_fim | hard | {
"lang": "rust",
"repo": "mkazutaka/ramup",
"path": "/src/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkazutaka/ramup path: /src/state.rs
use crate::appenv;
use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::Path;
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct State {
pub backup_paths: Vec<String>,
}
impl State {
#[allow(dead_c... | code_fim | hard | {
"lang": "rust",
"repo": "mkazutaka/ramup",
"path": "/src/state.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sp = appenv::state();
if !Path::new(&sp).exists() {
let parent = Path::new(&sp).parent().with_context(|| "No Parent")?;
fs::create_dir_all(parent)?;
fs::File::create(&sp)?;
}
let out = toml::to_string(&self)?;
fs::write(&sp, o... | code_fim | hard | {
"lang": "rust",
"repo": "mkazutaka/ramup",
"path": "/src/state.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn current_sha256_pricer() -> Pricer {
let l = LinearPricer {
constant: 60,
scalar_shift: 0,
scalar_chunk_size: 32,
per_chunk: 12,
use_ceil_div: true,
};
Pricer::Linear(l)
}
pub fn proposed_sha256_pricer() -> Pricer {
let l = LinearPricer {
... | code_fim | hard | {
"lang": "rust",
"repo": "shamatar/bench_precompiles",
"path": "/src/pricers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Pricer::Linear(l)
}
pub fn current_bnadd_pricer() -> Pricer {
let l = ConstantPricer {
constant: 150
};
Pricer::Constant(l)
}
pub fn proposed_bnadd_pricer() -> Pricer {
let l = ConstantPricer {
constant: 350
};
Pricer::Constant(l)
}
pub fn current_bnmul_pri... | code_fim | hard | {
"lang": "rust",
"repo": "shamatar/bench_precompiles",
"path": "/src/pricers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shamatar/bench_precompiles path: /src/pricers.rs
pub struct ConstantPricer {
pub constant: u64
}
pub struct LinearPricer{
pub constant: u64,
pub scalar_shift: u64,
pub scalar_chunk_size: u64,
pub per_chunk: u64,
pub use_ceil_div: bool,
}
pub enum Pricer {
Constant(C... | code_fim | hard | {
"lang": "rust",
"repo": "shamatar/bench_precompiles",
"path": "/src/pricers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mapper: &mut HashMap<String, Vec<(String, f64)>>,
a: &String,
b: &String,
val: f64,
) {
match mapper.get_mut(a) {
Some(rel) => match rel.iter().find(|v| v.0 == &b[..]) {
Some(_) => (),
None => rel.push((b.clone(), val)... | code_fim | hard | {
"lang": "rust",
"repo": "euclidr/leetcode",
"path": "/examples/p399.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: euclidr/leetcode path: /examples/p399.rs
use std::collections::{HashMap, HashSet};
struct Solution;
impl Solution {
pub fn calc_equation(
equations: Vec<Vec<String>>,
values: Vec<f64>,
queries: Vec<Vec<String>>,
) -> Vec<f64> {
let mut relations = HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "euclidr/leetcode",
"path": "/examples/p399.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type WindowMessage = UINT;
pub type SoundPlayOption = DWORD;<|fim_prefix|>// repo: bywayboy/RINAPI path: /code/rinapi/etypes.rs
use super::prelude::{
UINT , CCINT , DWORD
};
<|fim_middle|>pub type DialogBoxCommand = CCINT;
pub type MessageBoxStyle = UINT;
pub type WindowClassStyle = UINT;
pub t... | code_fim | hard | {
"lang": "rust",
"repo": "bywayboy/RINAPI",
"path": "/code/rinapi/etypes.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bywayboy/RINAPI path: /code/rinapi/etypes.rs
use super::prelude::{
UINT , CCINT , DWORD
};
<|fim_suffix|>pub type StockLogicalObject = CCINT;
pub type WindowMessage = UINT;
pub type SoundPlayOption = DWORD;<|fim_middle|>pub type DialogBoxCommand = CCINT;
pub type MessageBoxStyle = UINT;
p... | code_fim | hard | {
"lang": "rust",
"repo": "bywayboy/RINAPI",
"path": "/code/rinapi/etypes.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tuzz/moonlight path: /src/components/transform/test.rs
use super::*;
type Subject = Transform;
mod new {
use super::*;
// For now, we always compute the inverse matrix for a transform, but we could
// make this more sophisticated later, e.g. convert it lazily on first use and
... | code_fim | medium | {
"lang": "rust",
"repo": "tuzz/moonlight",
"path": "/src/components/transform/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(subject.matrix, matrix);
assert_eq!(subject.inverse, matrix);
}
}
mod deref {
use super::*;
#[test]
fn it_calls_through_to_the_matrix() {
let matrix = Matrix4::identity();
let subject = Subject::new(matrix);
assert_eq!(subject[0][0], 1.... | code_fim | medium | {
"lang": "rust",
"repo": "tuzz/moonlight",
"path": "/src/components/transform/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0031_next_permutation/find_last_inversion.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn next_permutation(nums: &mut [i32]) {
... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0031_next_permutation/find_last_inversion.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> nums.swap(i, i + 1 + j);
nums[i + 1..].reverse();
} else {
nums.reverse();
}
}
}
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl super::Solution for Solution {
fn nex... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0031_next_permutation/find_last_inversion.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server = HttpServer::new(move || {
App::new()
.data(pool.clone())
.wrap(actix_web::middleware::Logger::default())
.wrap(config::error_handler::config_error_handlers())
.configure(config::route::config_routes)
.default_service(
... | code_fim | hard | {
"lang": "rust",
"repo": "knysyy/actix_todo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: knysyy/actix_todo path: /src/main.rs
#[macro_use]
extern crate actix_web;
extern crate derive_new;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate serde_json;
<|fim_suffix|>#[actix_web::main]
async fn main() -> anyhow::... | code_fim | hard | {
"lang": "rust",
"repo": "knysyy/actix_todo",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[actix_web::main]
async fn main() -> anyhow::Result<()> {
dotenv::dotenv().ok();
env_logger::init();
let app_host = env::var("APP_HOST").context("APP_HOST is not defined.")?;
let app_port = env::var("APP_PORT").context("APP_PORT is not defined.")?;
let db_url = env::var("DATABASE_URL... | code_fim | hard | {
"lang": "rust",
"repo": "knysyy/actix_todo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lowRISC/opentitan path: /sw/host/opentitanlib/src/util/rom_detect.rs
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
use anyhow::Result;
use regex::Regex;
use std::time::Duration;
use std::time... | code_fim | hard | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/host/opentitanlib/src/util/rom_detect.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RomDetect {
pub fn new(bitstream: &[u8], timeout: Option<Duration>) -> Result<RomDetect> {
Ok(RomDetect {
usr_access: usr_access_get(bitstream)?,
console: UartConsole {
timeout,
exit_success: Some(Regex::new(r"(\w*ROM):([^\r\n]+)[\r\... | code_fim | medium | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/host/opentitanlib/src/util/rom_detect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl_digit_utils_test!(i64);
}
#[test]
fn i32_digit_test() {
impl_digit_utils_test!(i32);
}
#[test]
fn usize_digit_test() {
impl_digit_utils_test!(usize);
}
#[test]
fn isize_digit_test() {
impl_digit_utils_test!(isize);
}
}<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "hppRC/competitive-hpp-rs",
"path": "/src/utils/digit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn u32_digit_test() {
impl_digit_utils_test!(u32);
}
#[test]
fn i64_digit_test() {
impl_digit_utils_test!(i64);
}
#[test]
fn i32_digit_test() {
impl_digit_utils_test!(i32);
}
#[test]
fn usize_digit_test() {
impl_digit_util... | code_fim | hard | {
"lang": "rust",
"repo": "hppRC/competitive-hpp-rs",
"path": "/src/utils/digit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hppRC/competitive-hpp-rs path: /src/utils/digit.rs
pub trait DigitUtils {
fn digit(self) -> u32;
fn leftmost_digit(self) -> Self;
fn rightmost_digit(self) -> Self;
fn nth_digit(self, n: u32) -> Self;
fn digit_sum(self) -> Self;
}
macro_rules! impl_digit_utils(($($ty:ty),*) =... | code_fim | hard | {
"lang": "rust",
"repo": "hppRC/competitive-hpp-rs",
"path": "/src/utils/digit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lighty0410/srt-rs path: /srt-tokio/src/pending_connection.rs
use bytes::BytesMut;
use futures::select;
use log::{debug, warn};
use std::{
io::{self, Cursor, ErrorKind},
net::{IpAddr, SocketAddr},
time::{Duration, Instant},
};
use srt_protocol::{
accesscontrol::AllowAllStreamAcc... | code_fim | hard | {
"lang": "rust",
"repo": "Lighty0410/srt-rs",
"path": "/srt-tokio/src/pending_connection.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("{:?}:connect - {:?}", streamid, result);
match result {
ConnectionResult::SendPacket((packet, sa)) => {
ser_buffer.clear();
packet.serialize(&mut ser_buffer);
sock.send_to(&ser_buffer, sa).await?;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Lighty0410/srt-rs",
"path": "/srt-tokio/src/pending_connection.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ChannelMessage::TestMessage
}
}
use crate::sprites::channel_wiring;
pub type ChannelWiring = channel_wiring::TheChannelWiring<ChannelMessage>;
pub struct Exchange {
messages: Vec<ChannelMessage>,
senders: Vec<Sender<ChannelMessage>>,
receiver: Option<Receiver<ChannelMessage>>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "BruceBrown/rust-minesweeper",
"path": "/src/sprites/message_exchange.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BruceBrown/rust-minesweeper path: /src/sprites/message_exchange.rs
use std::mem::swap;
use std::sync::mpsc::{Receiver, Sender};
use crate::sprites::GameState;
use crate::sprites::{RendererContext, MouseEventData};
pub trait MessageExchange {
fn pull(&mut self) -> u32 {
0
}
... | code_fim | hard | {
"lang": "rust",
"repo": "BruceBrown/rust-minesweeper",
"path": "/src/sprites/message_exchange.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zellij-org/zellij path: /zellij-utils/src/setup.rs
IR"),
"/",
"assets/layouts/default.kdl"
));
pub const DEFAULT_SWAP_LAYOUT: &[u8] = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/",
"assets/layouts/default.swap.kdl"
));
pub const STRIDER_LAYOUT: &[u8] = include_byt... | code_fim | hard | {
"lang": "rust",
"repo": "zellij-org/zellij",
"path": "/zellij-utils/src/setup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zellij-org/zellij path: /zellij-utils/src/setup.rs
format!("Swap Layout not found for: {}", not_found),
)),
}
}
#[cfg(not(target_family = "wasm"))]
pub fn dump_builtin_plugins(path: &PathBuf) -> Result<()> {
for (asset_path, bytes) in ASSET_MAP.iter() {
let plugin_path =... | code_fim | hard | {
"lang": "rust",
"repo": "zellij-org/zellij",
"path": "/zellij-utils/src/setup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cli_args = CliArgs::default();
cli_args.config = Some(PathBuf::from(format!(
"{}/src/test-fixtures/config-with-ui-config.kdl",
env!("CARGO_MANIFEST_DIR")
)));
cli_args.layout = Some(PathBuf::from(format!(
"{}/src/test-fixtures/lay... | code_fim | hard | {
"lang": "rust",
"repo": "zellij-org/zellij",
"path": "/zellij-utils/src/setup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thalesfragoso/keykey path: /host/src/packets.rs
use crate::key_code::KeyCode;
use num_enum::TryFromPrimitive;
#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum DescriptorType {
Hid = 0x21,
Report = 0x22,
_Physical = 0x23,
}
<|fim_suffix|>impl AppCommand {
pub fn from_req_value... | code_fim | hard | {
"lang": "rust",
"repo": "thalesfragoso/keykey",
"path": "/host/src/packets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.