text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: mkulagowski/rustAOCean2020 path: /src/points.rs
use itertools::iproduct;
pub trait Point: Sized {
fn get_neighbours(&self) -> Vec<Self>;
fn new(from: (i32, i32, i32, i32)) -> Self;
}
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct Point3 {
x: i32,
y: i32,
z: i32,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mkulagowski/rustAOCean2020",
"path": "/src/points.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub struct Point4 {
x: i32,
y: i32,
z: i32,
w: i32,
}
impl Point for Point4 {
fn new(from: (i32, i32, i32, i32)) -> Self {
Self {
x: from.0,
y: from.1,
z: from.2,
w: from.3,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mkulagowski/rustAOCean2020",
"path": "/src/points.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brymko/AdventOfCode2020 path: /src/main.rs
#![allow(unused)]
mod d1;
mod d10;
mod d11;
mod d12;
mod d13;
mod d14;
mod d15;
mod d16;
mod d17;
mod d18;
mod d19;
mod d2;
mod d20;
mod d21;
mod d3;
mod d4;
mod d5;
mod d6;
mod d7;
mod d8;
mod d9;
<|fim_suffix|> println!(
"{} took: ... | code_fim | hard | {
"lang": "rust",
"repo": "brymko/AdventOfCode2020",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Perf {
fn default() -> Self {
Self {
start: time::Instant::now(),
last_ms: Cell::new(0.0),
}
}
}
impl Perf {
pub fn print(&self, ident: &str) {
let time_in_ms = self.start.elapsed().as_secs_f64() * 1_000.0;
let since_las... | code_fim | medium | {
"lang": "rust",
"repo": "brymko/AdventOfCode2020",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/base64ct-1.0.1/benches/mod.rs
#![feature(test)]
extern crate test;
use test::Bencher;
const B64_LEN: usize = 100_002;
const RAW_LEN: usize = (3 * B64_LEN) / 4;
#[inline(never)]
fn get_raw_data() -> Vec<u8> {
(0..RAW_LEN).map(|i| i as u... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/base64ct-1.0.1/benches/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn encode_bench(b: &mut Bencher) {
let mut buf = get_b64_data().into_bytes();
let raw_data = get_raw_data();
b.iter(|| {
let out = base64ct::encode(&raw_data, &mut buf).unwrap();
test::black_box(out);
});
b.bytes = RAW_LEN as u64;
}<|fim_prefix|>// repo: gnoliy... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/base64ct-1.0.1/benches/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LaplaceKorea/hacspec path: /examples/chacha20poly1305/src/chacha20poly1305.rs
// Import hacspec and all needed definitions.
use hacspec_lib::*;
// Import chacha20 and poly1305
use hacspec_chacha20::*;
use hacspec_poly1305::*;
pub type ChaChaPolyKey = ChaChaKey;
pub type ChaChaPolyIV = ChaChaIV... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/hacspec",
"path": "/examples/chacha20poly1305/src/chacha20poly1305.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn encrypt(key: ChaChaPolyKey, iv: ChaChaPolyIV, aad: &ByteSeq, msg: &ByteSeq) -> (ByteSeq, Tag) {
let cipher_text = chacha20(key, iv, 1u32, msg);
let mut poly_st = init(key,iv);
poly_st = poly1305_update_padded(aad, poly_st);
poly_st = poly1305_update_padded(&cipher_text, poly_st);
... | code_fim | hard | {
"lang": "rust",
"repo": "LaplaceKorea/hacspec",
"path": "/examples/chacha20poly1305/src/chacha20poly1305.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Spxg/library-tool path: /src/library.rs
use crate::CLIENT;
use crate::qrcode_api::QRCodeAPI;
use crate::message::Msg;
pub fn in_by_api1() -> Msg {
let api = QRCodeAPI::in_code1();
sweep(&api.url())
}
<|fim_suffix|>pub fn out() -> Msg {
let api = QRCodeAPI::out_code();
sweep(&ap... | code_fim | medium | {
"lang": "rust",
"repo": "Spxg/library-tool",
"path": "/src/library.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn sweep(url: &str) -> Msg {
let resp = CLIENT.get(url)
.send().unwrap();
Msg::from_url(resp.url())
}<|fim_prefix|>// repo: Spxg/library-tool path: /src/library.rs
use crate::CLIENT;
use crate::qrcode_api::QRCodeAPI;
use crate::message::Msg;
pub fn in_by_api1() -> Msg {
let api =... | code_fim | medium | {
"lang": "rust",
"repo": "Spxg/library-tool",
"path": "/src/library.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("name: {:?}", cli.name);
}<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/clap/v3/crate/examples/tutorial_derive/03_05_default_values.rs
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
struct Cli {
#[clap(default_value... | code_fim | easy | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/clap/v3/crate/examples/tutorial_derive/03_05_default_values.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/clap/v3/crate/examples/tutorial_derive/03_05_default_values.rs
use clap::Parser;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
struct Cli {
#[clap(default_value_t = String::from("alice"))]
name: String,
}
fn ... | code_fim | easy | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/clap/v3/crate/examples/tutorial_derive/03_05_default_values.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cdbattags/polygon-iex-deep path: /src/iex/mod.rs
pub mod dt;
pub mod header;
pub mod message;
pub mod body;
#[cfg(test)]
mod tests {
use super::*;
use std::fs::File;
use std::io::prelude::*;
fn read_sample() -> Vec<u8> {
let mut file = File::open("./data/sample-packet.... | code_fim | hard | {
"lang": "rust",
"repo": "cdbattags/polygon-iex-deep",
"path": "/src/iex/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let payload = read_sample();
let header = header::parse_header(&payload as &[u8]).unwrap();
assert!(header.version == 0x1);
assert!(header.message_protocol_id == 0x8004);
}
#[test]
fn test_parse_body() {
let payload = read_sample();
let header ... | code_fim | medium | {
"lang": "rust",
"repo": "cdbattags/polygon-iex-deep",
"path": "/src/iex/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Record {
pub fn new(from: String, record_data: RecordData, time: Duration) -> Self {
Record {
from,
record: record_data,
created_at: time,
}
}
/// Will change the world state
pub fn execute(&self, world_state: &mut dyn WorldState) -... | code_fim | hard | {
"lang": "rust",
"repo": "Elianagam/blockchain",
"path": "/src/blockchain/record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Calculates the hash using Blake2 hasher
pub fn calculate_hash(&self) -> Vec<u8> {
let mut hasher = Blake2b::new();
let record_as_string = format!("{:?}", (&self.created_at, &self.record, &self.from));
hasher.update(&record_as_string);
return Vec::from(hasher.fi... | code_fim | hard | {
"lang": "rust",
"repo": "Elianagam/blockchain",
"path": "/src/blockchain/record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Elianagam/blockchain path: /src/blockchain/record.rs
use super::world_state::WorldState;
use blake2::{Blake2b, Digest};
use std::time::Duration;
/// Request to the blockchain
#[derive(Clone, Debug)]
pub struct Record {
/// Client ID
pub from: String,
/// The duration since EPOCH (w... | code_fim | hard | {
"lang": "rust",
"repo": "Elianagam/blockchain",
"path": "/src/blockchain/record.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tyg13/tylang path: /crates/utils/src/source_utils.rs
use crate::{Anchor, Span};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Position {
pub offset: usize,
pub line: u32,
pub column: u32,
}
impl std::fmt::Display for Position {
fn fmt(&self, f: &mut std::fmt::Formatte... | code_fim | hard | {
"lang": "rust",
"repo": "Tyg13/tylang",
"path": "/crates/utils/src/source_utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = Source::from_str("lorem\nipsum\n").anchor_at(11).unwrap();
assert_eq!(a.line, 2);
assert_eq!(a.column, 6);
assert_eq!(a.offset, 11);
}
#[test]
fn anchor_out_of_bounds() {
let a = Source::from_str("lorem\n\nipsum\n").anchor_at(20);
assert... | code_fim | hard | {
"lang": "rust",
"repo": "Tyg13/tylang",
"path": "/crates/utils/src/source_utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe{
gl::ValidateProgram(args);
}
Ok(())
}
fn use_program(
_state: &mut OpState,
args: u32,
_: ()
) -> Result<(),AnyError>{
unsafe{
gl::UseProgram(args);
}
Ok(())
}
fn link_program(
_state: &mut OpState,
args: u32,
_: ()
) -> Result<(... | code_fim | hard | {
"lang": "rust",
"repo": "ReddikHaien/render_plugin",
"path": "/src/shader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn get_shader_parameter(
_: &mut OpState,
args: CommonGetParameterArgs,
_: ()
) -> Result<i32,AnyError>{
let mut out: i32 = 0;
unsafe{
gl::GetShaderiv(args.id,args.pname,&mut out);
}
Ok(out)
}
fn get_program_info_log(
_state: &mut OpState,
args: u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "ReddikHaien/render_plugin",
"path": "/src/shader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ReddikHaien/render_plugin path: /src/shader.rs
use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use deno_core::op_sync;
use deno_core::error::AnyError;
use deno_core::OpFn;
use serde::Deserialize;
pub fn init(ops: &mut Vec<(&'static str, Box<OpFn>)>){
ops.push(("op_validate_program",op_... | code_fim | hard | {
"lang": "rust",
"repo": "ReddikHaien/render_plugin",
"path": "/src/shader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use ParseError::*;
match e {
InvalidToken { location } => {
println!("Error type B at Line {}: Invalid Token.", location.line);
}
UnrecognizedEOF {
location,
expected: _,
} => {
println!("Error type B at Line {}: Unrec... | code_fim | hard | {
"lang": "rust",
"repo": "chirsz-ever/cminus",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn println_err(e: &ParseError<lexer::Location, lexer::Token<'_>, lexer::LexicalError>) {
use ParseError::*;
match e {
InvalidToken { location } => {
println!("Error type B at Line {}: Invalid Token.", location.line);
}
UnrecognizedEOF {
location,
... | code_fim | hard | {
"lang": "rust",
"repo": "chirsz-ever/cminus",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chirsz-ever/cminus path: /src/main.rs
#![allow(dead_code)]
use lalrpop_util::lalrpop_mod;
mod ast;
mod lexer;
lalrpop_mod!(parser);
use ast::*;
use lalrpop_util::ParseError;
use lexer::*;
use parser::ProgramParser;
use std::env;
use std::fs;
fn main() {
let fname = env::args().nth(1).expe... | code_fim | hard | {
"lang": "rust",
"repo": "chirsz-ever/cminus",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AddAssign<u16> for Word {
fn add_assign(&mut self, rhs: u16) {
let result = self.get().wrapping_add(rhs);
self.set(result);
}
}
impl Sub<u16> for Word {
type Output = Word;
fn sub(self, rhs: u16) -> Word {
Word::new(self.get().wrapping_sub(rhs))
}
}
impl... | code_fim | medium | {
"lang": "rust",
"repo": "jlippitt/yargbe",
"path": "/src/memory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlippitt/yargbe path: /src/memory.rs
use std::ops::{Add, AddAssign, Sub, SubAssign};
pub type Byte = u8;
#[derive(Clone, Copy, Default, Debug, Eq, PartialEq)]
pub struct Word {
pub high: Byte,
pub low: Byte
}
impl Word {
pub fn new(value: u16) -> Word {
Word {
... | code_fim | hard | {
"lang": "rust",
"repo": "jlippitt/yargbe",
"path": "/src/memory.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stegos/stegos path: /blockchain/src/api.rs
//
// Copyright (c) 2018 Stegos AG
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including with... | code_fim | hard | {
"lang": "rust",
"repo": "stegos/stegos",
"path": "/blockchain/src/api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> MacroBlock {
header: b.header,
multisig: b.multisig,
multisigmap: b.multisigmap,
inputs: b.inputs,
outputs: b.outputs,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MicroBlockInfo {
pub block_hash: Hash... | code_fim | hard | {
"lang": "rust",
"repo": "stegos/stegos",
"path": "/blockchain/src/api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> MacroBlockInfo {
block_hash: Hash::digest(&b),
header: b.header,
multisig: b.multisig,
multisigmap: b.multisigmap,
inputs: b.inputs,
outputs: b.outputs,
}
}
}
impl From<MacroBlockInfo> for MacroBlock {
fn from... | code_fim | hard | {
"lang": "rust",
"repo": "stegos/stegos",
"path": "/blockchain/src/api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bradtgmurray/aoc2020 path: /src/bin/22.rs
use aoc2020::utils;
use std::collections::{VecDeque, HashSet};
fn parse(data: &Vec<String>) -> (Vec<usize>, Vec<usize>) {
let mut player1: Vec<usize> = vec![];
let mut player2: Vec<usize> = vec![];
let mut lines = data.iter();
lines.nex... | code_fim | hard | {
"lang": "rust",
"repo": "bradtgmurray/aoc2020",
"path": "/src/bin/22.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while state.0.len() > 0 && state.1.len() > 0 {
if game_log.contains(&state) {
// Player 1 wins
return (true, state.0);
}
game_log.insert(state.clone());
let player1_card = state.0.pop_front().unwrap();
let player2_card = state.1.pop_fron... | code_fim | hard | {
"lang": "rust",
"repo": "bradtgmurray/aoc2020",
"path": "/src/bin/22.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Part 1: {}", part1(VecDeque::from(player1.clone()), VecDeque::from(player2.clone())));
println!("Part 2: {}", part2(VecDeque::from(player1), VecDeque::from(player2)));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_example() {
let data: Vec<String> = vec![... | code_fim | hard | {
"lang": "rust",
"repo": "bradtgmurray/aoc2020",
"path": "/src/bin/22.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drewet/name-my-indie-game-please path: /shared/src/playercmd.rs
use component::{ComponentStore, EntityComponent, EntityHandle};
use cgmath::{Point, Vector, Vector3, Quaternion};
pub struct ControllableComponent {
pub entity: EntityHandle
//pub topspeed: f32,
//pub lastcmd: Pla... | code_fim | hard | {
"lang": "rust",
"repo": "drewet/name-my-indie-game-please",
"path": "/shared/src/playercmd.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: validate angles and movoment
ent.rot = cmd.angles;
// TODO: collision check. there should be a function in physics::
// for trying to move by a vector, with collisions.
ent.pos = ent.pos.add_v(&cmd.angles.rotate_vector(&cmd.movement));
}<|fim_prefix|>// repo: drewet/name-my-in... | code_fim | hard | {
"lang": "rust",
"repo": "drewet/name-my-indie-game-please",
"path": "/shared/src/playercmd.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ent = entities.find_mut(controllable.entity).unwrap();
// TODO: validate angles and movoment
ent.rot = cmd.angles;
// TODO: collision check. there should be a function in physics::
// for trying to move by a vector, with collisions.
ent.pos = ent.pos.add_v(&cmd.angles.rotate_v... | code_fim | hard | {
"lang": "rust",
"repo": "drewet/name-my-indie-game-please",
"path": "/shared/src/playercmd.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgoodlad/onebitsy-rs path: /examples/button.rs
#![no_std]
#![no_main]
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
use cortex_m_rt::ExceptionFrame;
use cortex_m_rt::{entry, exception};
use hal::prelude::*;
use onebitsy::{self, hal, stm32, Button, ... | code_fim | hard | {
"lang": "rust",
"repo": "dgoodlad/onebitsy-rs",
"path": "/examples/button.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pins = onebitsy::Pins::new(
dp.GPIOA.split(),
dp.GPIOB.split(),
dp.GPIOC.split(),
dp.GPIOD.split(),
);
let mut led = onebitsy::led(pins.pa8);
let button = onebitsy::button(pins.pc1);
loop {
if button.i... | code_fim | hard | {
"lang": "rust",
"repo": "dgoodlad/onebitsy-rs",
"path": "/examples/button.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[entry]
fn main() -> ! {
if let (Some(dp), Some(_cp)) = (
stm32::Peripherals::take(),
cortex_m::peripheral::Peripherals::take(),
) {
let _clocks = onebitsy::configure_clocks(dp.RCC.constrain());
let pins = onebitsy::Pins::new(
dp.GPIOA.split(),
... | code_fim | medium | {
"lang": "rust",
"repo": "dgoodlad/onebitsy-rs",
"path": "/examples/button.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kammitama5/9_14_16_RustDocumentationworkingthrough path: /hundredsix.rs
//calling functions in Rust
<|fim_suffix|>
let mut x = 23;
println!("x = {}", x);
x = my_func();
println!("x = {}", x);
}
fn my_func() -> i32{
let x = 9;
x
}<|fim_middle|>fn main(){
| code_fim | easy | {
"lang": "rust",
"repo": "kammitama5/9_14_16_RustDocumentationworkingthrough",
"path": "/hundredsix.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let x = 9;
x
}<|fim_prefix|>// repo: kammitama5/9_14_16_RustDocumentationworkingthrough path: /hundredsix.rs
//calling functions in Rust
fn main(){
let mut x = 23;
println!("x = {}", x);
x = my_func();
println!("x = {}", x);
}
<|fim_middle|>fn my_func() -> i32{
| code_fim | easy | {
"lang": "rust",
"repo": "kammitama5/9_14_16_RustDocumentationworkingthrough",
"path": "/hundredsix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn my_func() -> i32{
let x = 9;
x
}<|fim_prefix|>// repo: kammitama5/9_14_16_RustDocumentationworkingthrough path: /hundredsix.rs
//calling functions in Rust
fn main(){
<|fim_middle|>
let mut x = 23;
println!("x = {}", x);
x = my_func();
println!("x = {}", x);
}
| code_fim | medium | {
"lang": "rust",
"repo": "kammitama5/9_14_16_RustDocumentationworkingthrough",
"path": "/hundredsix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>at!("{} {} times", health_check_response, visit_count);
*visit_count += 1;
Ok(HttpResponse::Ok().json(&response))
}<|fim_prefix|>// repo: hrodrig/rust-servers-services-apps path: /chapter7/ezytutors/tutor-web-service/src/iter5/handlers/general.rs
use crate::errors::EzyTutorError;
use crate::state... | code_fim | hard | {
"lang": "rust",
"repo": "hrodrig/rust-servers-services-apps",
"path": "/chapter7/ezytutors/tutor-web-service/src/iter5/handlers/general.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hrodrig/rust-servers-services-apps path: /chapter7/ezytutors/tutor-web-service/src/iter5/handlers/general.rs
use crate::errors::EzyTutorError;
use crate::state::AppState;
use actix_web::{web, HttpResponse};
pub async fn health_check_handler(
app_state: web::Data<AppState>,
) -> Result<HttpR... | code_fim | medium | {
"lang": "rust",
"repo": "hrodrig/rust-servers-services-apps",
"path": "/chapter7/ezytutors/tutor-web-service/src/iter5/handlers/general.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>&app_state.health_check_response;
let mut visit_count = app_state.visit_count.lock().unwrap();
let response = format!("{} {} times", health_check_response, visit_count);
*visit_count += 1;
Ok(HttpResponse::Ok().json(&response))
}<|fim_prefix|>// repo: hrodrig/rust-servers-services-apps pa... | code_fim | medium | {
"lang": "rust",
"repo": "hrodrig/rust-servers-services-apps",
"path": "/chapter7/ezytutors/tutor-web-service/src/iter5/handlers/general.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// In addition to the "query provider" traits, you may have other
/// trait requirements that your application needs -- you can
/// implement those yourself (in this case, an `interner`).
impl CompilerDatabase for DatabaseImpl {
fn interner(&self) -> &Interner {
&self.interner
}
}<|fim_pr... | code_fim | hard | {
"lang": "rust",
"repo": "cormacrelf/salsa",
"path": "/examples/compiler/implementation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cormacrelf/salsa path: /examples/compiler/implementation.rs
use crate::class_table;
use crate::compiler::{CompilerDatabase, Interner};
/// Our "database" will be threaded through our application (though
/// 99% of the application only interacts with it through traits and
/// never knows its rea... | code_fim | hard | {
"lang": "rust",
"repo": "cormacrelf/salsa",
"path": "/examples/compiler/implementation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m9s/xmc1000 path: /xmc1000/src/vadc_g0/vfr/mod.rs
#[doc = "Read access: No new valid data available Write access: No effect"]
VALUE1,
#[doc = "Read access: Result register x contains valid data and has not yet been read, or bit FCR has been updated Write access: Clear this valid flag a... | code_fim | hard | {
"lang": "rust",
"repo": "m9s/xmc1000",
"path": "/xmc1000/src/vadc_g0/vfr/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m9s/xmc1000 path: /xmc1000/src/vadc_g0/vfr/mod.rs
{
#[doc = r" Returns `true` if the bit is clear (0)"]
#[inline]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r" Returns `true` if the bit is set (1)"]
#[inline]
pub fn bit_is_set(&self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "m9s/xmc1000",
"path": "/xmc1000/src/vadc_g0/vfr/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Change the probability with which this `FastBernoulliTrial` produces `true` values
/// to the given `probability`.
pub fn set_probability(&mut self, probability: f64) {
assert!(0.0 <= probability && probability <= 1.0);
self.probability = probability;
if 0.0 < self.... | code_fim | hard | {
"lang": "rust",
"repo": "jimblandy/fast-bernoulli-trial",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jimblandy/fast-bernoulli-trial path: /src/lib.rs
//! you can't be sure exactly how many samples you'll get.
//! Technically, it's possible that you might sample none of them, or all of them.
//! But if the number of events *n* is large, these aren't likely outcomes;
//! you can generally expect ... | code_fim | hard | {
"lang": "rust",
"repo": "jimblandy/fast-bernoulli-trial",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This comment should just read, "Generate skip counts with a geometric
// distribution", and leave everyone to go look that up and see why it's the right
// thing to do, if they don't know already.
//
// BUT IF YOU'RE CURIOUS, COMMENTS ARE FREE...
//
... | code_fim | hard | {
"lang": "rust",
"repo": "jimblandy/fast-bernoulli-trial",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let rect1 = Rectangle { width: 30, height: 50};
let rect2 = Rectangle { width: 10, height: 40};
let rect3 = Rectangle { width: 60, height: 45};
let square = Rectangle::square(7);
println!("Can rect1 hold rect2? {}", rect1.can_hold(&rect2));
println!("Can rect1 hold rec... | code_fim | medium | {
"lang": "rust",
"repo": "SBentley/rust-book-examples",
"path": "/rectangle_structs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SBentley/rust-book-examples path: /rectangle_structs/src/main.rs
#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32,
}
// Implement methods on Rectangle
impl Rectangle {
fn area(&self) -> u32 {
<|fim_suffix|> self.width > other.width && self.height > other.height
... | code_fim | medium | {
"lang": "rust",
"repo": "SBentley/rust-book-examples",
"path": "/rectangle_structs/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mr-amirka/tr_logic_llc_test path: /app/src/utils/image.rs
use opencv::{
core::{self, Mat, Size},
prelude::*,
types::*,
};
/// Конвертирует объект изображения в массив байт
#[allow(dead_code)]
#[inline]
pub fn mat_to_data(src_image: &Mat, extension: &str) -> Option<VectorOfuchar> {
... | code_fim | hard | {
"lang": "rust",
"repo": "mr-amirka/tr_logic_llc_test",
"path": "/app/src/utils/image.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
const SIGN_FF_D8_FF: &'static [u8] = &[ 0xFF, 0xD8, 0xFF ]; //JPG
const SIGN_89_50_4E_47_0D_0A_1A_0A: &'static [u8] = &[ 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A ]; //PNG
const SIGN_42_4D: &'static [u8] = &[ 0x42, 0x4D ]; //BMP
/// Возвращвает content-type сооответсвующий сигнатуре изображения по ... | code_fim | hard | {
"lang": "rust",
"repo": "mr-amirka/tr_logic_llc_test",
"path": "/app/src/utils/image.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut resized_image = match unsafe {
Mat::new_rows_cols(0, 0, core::CV_8UC1)
} {
Ok(v) => v,
_ => {
return None;
}
};
let flag = if width > original_width || height > original_height {
opencv::imgproc::INTER_CUBIC
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "mr-amirka/tr_logic_llc_test",
"path": "/app/src/utils/image.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Qixalite/regi-slash-commands path: /src/discord/command/location.rs
use crate::discord::interaction::{
InteractionApplicationCommandCallbackData, InteractionResponse, Interac<|fim_suffix|>a {
content: "https://docs.qixalite.com/guides/games/tf2/#regions".to_string(),
}),
... | code_fim | hard | {
"lang": "rust",
"repo": "Qixalite/regi-slash-commands",
"path": "/src/discord/command/location.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>InteractionResponseType::ChannelMessageWithSource,
data: Some(InteractionApplicationCommandCallbackData {
content: "https://docs.qixalite.com/guides/games/tf2/#regions".to_string(),
}),
}
}<|fim_prefix|>// repo: Qixalite/regi-slash-commands path: /src/discord/command/locat... | code_fim | medium | {
"lang": "rust",
"repo": "Qixalite/regi-slash-commands",
"path": "/src/discord/command/location.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let prefix = dst.chars().next().unwrap();
assert_ne!(prefix, '^', "Footnotes should be handled by pulldown-cmark already");
let mut uppercase = None;
if prefix == '#' {
dst.truncate_start(1);
// TODO: don't panic on invalid links (`#`)
uppercase = Some(dst.chars().n... | code_fim | hard | {
"lang": "rust",
"repo": "oberien/heradoc",
"path": "/src/frontend/refs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let next_at = self.s[1..].find('@').map_or(self.s.len(), |i| i + 1);
let single_end = self.s[..next_at].rfind(',').unwrap_or(self.s.len());
let single = self.s.split_to(single_end);
self.s.truncate_start(next_at - single_end);
Some(parse_single_b... | code_fim | hard | {
"lang": "rust",
"repo": "oberien/heradoc",
"path": "/src/frontend/refs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oberien/heradoc path: /src/frontend/refs.rs
use std::borrow::Cow;
use std::str::FromStr;
use diagnostic::Span;
pub use pulldown_cmark::LinkType;
use super::event::{BiberReference, InterLink, Url};
use crate::config::Config;
use crate::Diagnostics;
use crate::error::DiagnosticCode;
use crate::e... | code_fim | hard | {
"lang": "rust",
"repo": "oberien/heradoc",
"path": "/src/frontend/refs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nervosnetwork/ckb path: /util/types/src/utilities/difficulty.rs
use numext_fixed_uint::prelude::UintConvert;
use numext_fixed_uint::{u512, U256, U512};
/// The minimal difficulty that can be represented in the compact format.
pub const DIFF_TWO: u32 = 0x2080_0000;
const ONE: U256 = U256::one()... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/util/types/src/utilities/difficulty.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Converts PoW target into compact format of difficulty.
pub fn target_to_compact(target: U256) -> u32 {
let bits = 256 - target.leading_zeros();
let exponent = u64::from((bits + 7) / 8);
let mut compact = if exponent <= 3 {
get_low64(&target) << (8 * (3 - exponent))
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/util/types/src/utilities/difficulty.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.props.errors.as_ref() {
Some(Some(errors)) => {
let errors = errors.field_errors();
if let Some(errors) = errors.get("__all__") {
html! {
<div class="invalid-feedback">
{ ... | code_fim | hard | {
"lang": "rust",
"repo": "cmdln/empholite",
"path": "/client/src/components/editor/rule_editor/view.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn validation_parent_class(
errors: &Option<Option<Box<ValidationErrors>>>,
prefix: &str,
) -> Classes {
let mut class = Classes::from(prefix);
match errors.as_ref() {
Some(Some(_)) => {
class.push("was-invalidated");
}
Some(None) => {
class.... | code_fim | hard | {
"lang": "rust",
"repo": "cmdln/empholite",
"path": "/client/src/components/editor/rule_editor/view.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cmdln/empholite path: /client/src/components/editor/rule_editor/view.rs
use super::{key_path::KeyPathSelector, verb_select::VerbSelect, Msg, RuleEditor};
use crate::RuleType;
use bootstrap_rs::{input::InputType, prelude::*, Button, ButtonToolbar, Input};
use validator::ValidationErrors;
use yew:... | code_fim | hard | {
"lang": "rust",
"repo": "cmdln/empholite",
"path": "/client/src/components/editor/rule_editor/view.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let inst_hours_pattern : Vec<u8> = vec![
// 111111 11112222
//01234567 89012345 67890123
0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00001111,
0b11110000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b0000... | code_fim | medium | {
"lang": "rust",
"repo": "blaubart69/InstallHoursPattern",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> installslot::from_hex_to_install_slots(&inst_hours_pattern, printOneSlot);
}<|fim_prefix|>// repo: blaubart69/InstallHoursPattern path: /src/main.rs
use crate::installslot::InstallSlot;
use std::num::ParseIntError;
mod installslot;
const WEEK_BYTE_LEN : usize = 24*7/8;
fn main() {
<|fim_middle|>... | code_fim | hard | {
"lang": "rust",
"repo": "blaubart69/InstallHoursPattern",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blaubart69/InstallHoursPattern path: /src/main.rs
use crate::installslot::InstallSlot;
use std::num::ParseIntError;
mod installslot;
const WEEK_BYTE_LEN : usize = 24*7/8;
fn main() {
<|fim_suffix|> let printOneSlot = | slot:&InstallSlot| {
println!("{}", slot.to_string());
};
... | code_fim | hard | {
"lang": "rust",
"repo": "blaubart69/InstallHoursPattern",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get an additional reference to the contained Arguments.
pub fn arguments(&self) -> Rc<Arguments> {
match self {
Validity::Valid { name: _, args } => args.clone(),
Validity::Invalid { name: _, args } => args.clone()
}
}
pub fn has_list_as_sole_argument(&self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "paulchernoch/feel",
"path": "/src/parsing/arguments.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulchernoch/feel path: /src/parsing/arguments.rs
f.arguments();
if args.as_ref().args.len() != 1 {
false
}
else {
args.as_ref().args[0].get_type() == FeelType::List
}
}
pub fn and(self, passes: bool) -> Self {
match (passes, &self.is_valid()) {
(true, ... | code_fim | hard | {
"lang": "rust",
"repo": "paulchernoch/feel",
"path": "/src/parsing/arguments.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulchernoch/feel path: /src/parsing/arguments.rs
g>, args: &Rc<Arguments>) -> Self {
Validity::Valid { name: name.clone(), args: args.clone() }
}
/// Does this represent a Valid or an Invalid state?
pub fn is_valid(&self) -> bool {
match self {
Validity::Valid {..} => true,... | code_fim | hard | {
"lang": "rust",
"repo": "paulchernoch/feel",
"path": "/src/parsing/arguments.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_server(&address, set_size, id_size, max_payload, payload_size);
}<|fim_prefix|>// repo: Ra1issa/match-compute path: /src/bin/simple-server/main.rs
// A simple single threaded example of PSI with match and compute
mod utils;
use match_compute::util;
use crate::utils::run_server::run_server;
<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "Ra1issa/match-compute",
"path": "/src/bin/simple-server/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ra1issa/match-compute path: /src/bin/simple-server/main.rs
// A simple single threaded example of PSI with match and compute
mod utils;
use match_compute::util;
use crate::utils::run_server::run_server;
<|fim_suffix|> run_server(&address, set_size, id_size, max_payload, payload_size);
}<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "Ra1issa/match-compute",
"path": "/src/bin/simple-server/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone)]
pub struct GraphPosData(pub Rect);
impl Default for GraphPosData {
fn default() -> Self {
GraphPosData(Rect::new(00.0, 0.0, 10.0, 10.0))
}
}
#[derive(Copy, Clone, Default)]
pub struct MovingGraph(pub bool);
#[derive(Copy, Clone, Default)]
pub struct ScalingGraph(p... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/SIMple-Mechanics",
"path": "/src/resources.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/SIMple-Mechanics path: /src/resources.rs
use crate::{Point, Vector};
use ggez::graphics::Rect;
#[derive(Copy, Clone)]
pub struct MousePos(pub Vector);
#[derive(Copy, Clone)]
pub struct MouseStartPos(pub Option<Vector>);
impl Default for MousePos {
fn default() -> Self {
Mo... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/SIMple-Mechanics",
"path": "/src/resources.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jenndox/AoC path: /cargo-project/src/day6.rs
pub mod customs {
pub use crate::helper::helper_fns;
pub fn question(filename: &String) {
let data = helper_fns::file_into_vec(filename);
<|fim_suffix|> if result.len() > 0 {
if have_group == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "jenndox/AoC",
"path": "/cargo-project/src/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if result.len() > 0 {
if have_group == 0 {
for letter in result {
// Establish the super set we care about
answers.push(letter);
}
have_group = 1;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jenndox/AoC",
"path": "/cargo-project/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let big_n =
if n < 10 && n > -10 {
println!(", and is a small number, increase ten-fold");
// This expression returns an `i32`.
10 * n
} else {
println!(", and is a big number, halve the number");
// This expression must ret... | code_fim | medium | {
"lang": "rust",
"repo": "kkredit/pl-study",
"path": "/rust/8_1-flow_control-if_else.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kkredit/pl-study path: /rust/8_1-flow_control-if_else.rs
/* Original source by the Rust Team
* Modifications by Kevin Kredit
* Licensed under https://www.apache.org/licenses/LICENSE-2.0
*
* https://doc.rust-lang.org/stable/rust-by-example/flow_control/if_else.html
*/
fn main() {
let n ... | code_fim | hard | {
"lang": "rust",
"repo": "kkredit/pl-study",
"path": "/rust/8_1-flow_control-if_else.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This expression returns an `i32`.
10 * n
} else {
println!(", and is a big number, halve the number");
// This expression must return an `i32` as well.
n / 2
// TODO ^ Try suppressing this expression with a semicolon.
... | code_fim | medium | {
"lang": "rust",
"repo": "kkredit/pl-study",
"path": "/rust/8_1-flow_control-if_else.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinyon/node-bindgen path: /examples/logging/src/lib.rs
use node_bindgen::derive::node_bindgen;
use node_bindgen::init::node_bindgen_init_once;
use log::{info, warn};
<|fim_suffix|> // initialize logging framework
env_logger::init();
info!("logging initialized");
}
#[node_bindgen()... | code_fim | easy | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/examples/logging/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> warn!("calling hello");
format!("hello world {count}")
}<|fim_prefix|>// repo: infinyon/node-bindgen path: /examples/logging/src/lib.rs
use node_bindgen::derive::node_bindgen;
use node_bindgen::init::node_bindgen_init_once;
use log::{info, warn};
<|fim_middle|>#[node_bindgen_init_once]
fn init_l... | code_fim | medium | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/examples/logging/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[node_bindgen()]
fn hello(count: i32) -> String {
warn!("calling hello");
format!("hello world {count}")
}<|fim_prefix|>// repo: infinyon/node-bindgen path: /examples/logging/src/lib.rs
use node_bindgen::derive::node_bindgen;
use node_bindgen::init::node_bindgen_init_once;
use log::{info, warn};... | code_fim | medium | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/examples/logging/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>const PR5: [f64; 6] = [
/* for x in [8,4.5454]=1/[0.125,0.22001] */
1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */
1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */
6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */
1.08308182990189109773e+02, /* 0x405B13B9, 0x45... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/libm",
"path": "/src/math/j1.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/libm path: /src/math/j1.rs
/* origin: FreeBSD /usr/src/lib/msun/src/e_j1.c */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/libm",
"path": "/src/math/j1.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Size2::Original
}
}
impl From<Size2> for String {
fn from(val: Size2) -> Self {
match val {
Size2::S => "thumb_s".to_string(),
Size2::M => "thumb_m".to_string(),
Size2::L => "thumb_l".to_string(),
Size2::Original => "thumb".to_string... | code_fim | hard | {
"lang": "rust",
"repo": "Tarnadas/smmdb-api",
"path": "/crates/smmdb/src/routes/courses2/thumbnail.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tarnadas/smmdb-api path: /crates/smmdb/src/routes/courses2/thumbnail.rs
use crate::server::ServerData;
use actix_web::{error::ResponseError, http::StatusCode, HttpRequest, HttpResponse};
use bson::oid::ObjectId;
use paperclip::actix::{api_v2_errors, api_v2_operation, web, Apiv2Schema};
use serd... | code_fim | hard | {
"lang": "rust",
"repo": "Tarnadas/smmdb-api",
"path": "/crates/smmdb/src/routes/courses2/thumbnail.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ResponseError for GetCourse2ThumbnailError {
fn error_response(&self) -> HttpResponse {
match *self {
GetCourse2ThumbnailError::CourseNotFound(_) => HttpResponse::new(StatusCode::NOT_FOUND),
GetCourse2ThumbnailError::MongoOid(bson::oid::Error::FromHexError(_)) => {... | code_fim | hard | {
"lang": "rust",
"repo": "Tarnadas/smmdb-api",
"path": "/crates/smmdb/src/routes/courses2/thumbnail.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bathtor/rust-hash-wheel-timer path: /benches/wheel_benchmark.rs
use criterion::{criterion_group, criterion_main, BatchSize, Bencher, Criterion, Throughput};
use hierarchical_hash_wheel_timer::{wheels::cancellable::*, UuidOnlyTimerEntry};
use rand::prelude::*;
use std::{rc::Rc, time::Duration};
u... | code_fim | hard | {
"lang": "rust",
"repo": "Bathtor/rust-hash-wheel-timer",
"path": "/benches/wheel_benchmark.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_write_bench(bencher: &mut Bencher) {
let id = Uuid::new_v4();
let entry = UuidOnlyTimerEntry {
id,
delay: Duration::from_millis(1),
};
let entry_rc = Rc::new(entry);
bencher.iter_batched(
|| {
let timer: QuadWheelWithOverflow<UuidOnlyTimerEnt... | code_fim | hard | {
"lang": "rust",
"repo": "Bathtor/rust-hash-wheel-timer",
"path": "/benches/wheel_benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bitspleaseee/auth-service path: /src/migration.rs
use diesel::prelude::*;
use diesel::sql_query;
use crate::db::establish_connection;
use crate::{IntErrorKind, IntResult};
pub fn run() -> IntResult<()> {
let con = establish_connection();
<|fim_suffix|> id INT UNSIGNED AUTO_INC... | code_fim | medium | {
"lang": "rust",
"repo": "Bitspleaseee/auth-service",
"path": "/src/migration.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = sql_query(
r#"CREATE TABLE roles (
id INT UNSIGNED NOT NULL,
name VARCHAR(20) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(id) REFERENCES users(id)
);"#,
).execute(&con)
.map_err(|_| IntErrorKind::QueryError);
Ok(())
}<|fim_prefix|>// repo: Bitsple... | code_fim | hard | {
"lang": "rust",
"repo": "Bitspleaseee/auth-service",
"path": "/src/migration.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeroenpelgrims/rust-by-example path: /4/scope.rs
fn main() {
//let long_lived_var = 1i;
let i = 1i;
{ //block start
let i = 2i;
<|fim_suffix|> println!("outer: {0}", i);
}<|fim_middle|> println!("inner: {0}", i);
} //block end
| code_fim | easy | {
"lang": "rust",
"repo": "jeroenpelgrims/rust-by-example",
"path": "/4/scope.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("outer: {0}", i);
}<|fim_prefix|>// repo: jeroenpelgrims/rust-by-example path: /4/scope.rs
fn main() {
//let long_lived_var = 1i;
let i = 1i;
<|fim_middle|> { //block start
let i = 2i;
println!("inner: {0}", i);
} //block end
| code_fim | medium | {
"lang": "rust",
"repo": "jeroenpelgrims/rust-by-example",
"path": "/4/scope.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> SolutionArgs {
year: 2022,
day: Z,
input_type: InputType::EXAMPLE(1),
}
}
fn part1(&self) -> Option<String> {
None
}
fn part2(&self) -> Option<String> {
None
}
}
**/<|fim_prefix|>// repo: Weizilla/advent-of-code pat... | code_fim | hard | {
"lang": "rust",
"repo": "Weizilla/advent-of-code",
"path": "/rust/advent_of_code/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Weizilla/advent-of-code path: /rust/advent_of_code/src/lib.rs
use std::fs;
use crate::InputType::{EXAMPLE, INPUT};
pub enum InputType {
INPUT,
EXAMPLE(i32),
}
pub struct SolutionArgs {
pub year: i32,
pub day: i32,
pub input_type: InputType,
}
// This is prob bad shoving O... | code_fim | hard | {
"lang": "rust",
"repo": "Weizilla/advent-of-code",
"path": "/rust/advent_of_code/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution for Day0Z {
fn args(&self) -> SolutionArgs {
SolutionArgs {
year: 2022,
day: Z,
input_type: InputType::EXAMPLE(1),
}
}
fn part1(&self) -> Option<String> {
None
}
fn part2(&self) -> Option<String> {
None... | code_fim | hard | {
"lang": "rust",
"repo": "Weizilla/advent-of-code",
"path": "/rust/advent_of_code/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Neurrone/rust-libaudioverse path: /src/nodes/environment_node.rs
use super::super::{buffer, libaudioverse_sys, server};
use super::properties::{
DistanceModelProperty, Float3Property, Float6Property, FloatProperty, IntProperty,
PanningStrategyProperty,
};
use super::Node;
use check... | code_fim | hard | {
"lang": "rust",
"repo": "Neurrone/rust-libaudioverse",
"path": "/src/nodes/environment_node.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.