text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>pub fn drop_coin(board: &mut Board, coin: Coin, col: usize) -> (bool, Coord) {
let col_idx = col;
for i in 0..(&board[col_idx]).len() {
if board[col_idx][i] == Coin::Empty {
board[col_idx][i] = coin;
return (true, (col_idx, i))
}
}
(false, (0,0))
}<|... | code_fim | medium | {
"lang": "rust",
"repo": "marc-costello/rustConnect4",
"path": "/src/board.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new_board() -> Board {
[[Coin::Empty; Y_BOARD_LENGTH]; X_BOARD_LENGTH]
}
pub fn drop_coin(board: &mut Board, coin: Coin, col: usize) -> (bool, Coord) {
let col_idx = col;
for i in 0..(&board[col_idx]).len() {
if board[col_idx][i] == Coin::Empty {
board[col_idx][i] =... | code_fim | medium | {
"lang": "rust",
"repo": "marc-costello/rustConnect4",
"path": "/src/board.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marc-costello/rustConnect4 path: /src/board.rs
use crate::coin::Coin;
pub const X_BOARD_LENGTH: usize = 7;
pub const Y_BOARD_LENGTH: usize = 6;
pub type Board = [[Coin; Y_BOARD_LENGTH]; X_BOARD_LENGTH];
pub type Coord = (usize, usize);
<|fim_suffix|>pub fn drop_coin(board: &mut Board, coin: C... | code_fim | medium | {
"lang": "rust",
"repo": "marc-costello/rustConnect4",
"path": "/src/board.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Old debugging function, new plan is to spawn another process
//LEAVING DEBUG ALONE FOR NOW, MAYBE WORK ON IT LATER
//thread::spawn(|| debuggui::run(&cpu));
//let mut debug = Command::new("debug/target/debug/debug").stdin(Stdio::piped())
//.spawn().expect("Failed to execute comman... | code_fim | hard | {
"lang": "rust",
"repo": "JordanLevin/Rust-emulator",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JordanLevin/Rust-emulator path: /src/main.rs
use std::fs::File;
use std::io::prelude::*;
use std::{thread, time};
//use std::process::{Command, Stdio};
//use std::io::Write;
use std::env;
//Random vals
extern crate rand;
//Graphics
extern crate sdl2;
mod graphics;
mod instruct;
mod disas;
f... | code_fim | hard | {
"lang": "rust",
"repo": "JordanLevin/Rust-emulator",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.pc = 0;
loop {
let op = self.parse_next();
if op == Operation::End {
break;
}
self.evaluate(op);
}
}
}
pub fn run(program: &[i64], input: &[i64]) -> (Vec<i64>, Vec<i64>) {
let mut ctx = IntcodeContext::ne... | code_fim | hard | {
"lang": "rust",
"repo": "verath/advent-of-code-2019",
"path": "/intcode/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: verath/advent-of-code-2019 path: /intcode/src/lib.rs
use std::mem;
const PARAM_MODE_POSITION: u8 = 0;
const PARAM_MODE_IMMEDIATE: u8 = 1;
#[derive(Debug, Copy, Clone, PartialEq)]
enum Parameter {
Position(usize),
Immediate(i64),
}
fn position_param(position: i64) -> Parameter {
as... | code_fim | hard | {
"lang": "rust",
"repo": "verath/advent-of-code-2019",
"path": "/intcode/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn resolve_param(&self, param: Parameter) -> i64 {
match param {
Parameter::Immediate(value) => value,
Parameter::Position(pos) => self.program[pos],
}
}
fn evaluate(&mut self, op: Operation) {
match op {
Operation::Add(p1, p2, Param... | code_fim | hard | {
"lang": "rust",
"repo": "verath/advent-of-code-2019",
"path": "/intcode/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nikomatsakis/rust path: /src/test/run-pass/expr-alt-struct.rs
// -*- rust -*-
// Tests for alt as expressions resulting in structural types
fn test_rec() {
<|fim_suffix|>fn test_tag() {
tag mood { happy; sad; }
let rs = alt true { true { happy } false { sad } };
assert (rs == hap... | code_fim | medium | {
"lang": "rust",
"repo": "nikomatsakis/rust",
"path": "/src/test/run-pass/expr-alt-struct.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> tag mood { happy; sad; }
let rs = alt true { true { happy } false { sad } };
assert (rs == happy);
}
fn main() { test_rec(); test_tag(); }<|fim_prefix|>// repo: nikomatsakis/rust path: /src/test/run-pass/expr-alt-struct.rs
// -*- rust -*-
// Tests for alt as expressions resulting in stru... | code_fim | easy | {
"lang": "rust",
"repo": "nikomatsakis/rust",
"path": "/src/test/run-pass/expr-alt-struct.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
#[should_panic(expected = "UnexpectedEof")]
fn check_disallow_empty_expression() {
Expression::new(String::new()).unwrap();
}
}<|fim_prefix|>// repo: 4nickel/tag-suite path: /src/expression/expression.rs
use super::{import::*, Tokenizer, Parser, Ast, error::{Error as E}};
... | code_fim | hard | {
"lang": "rust",
"repo": "4nickel/tag-suite",
"path": "/src/expression/expression.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 4nickel/tag-suite path: /src/expression/expression.rs
use super::{import::*, Tokenizer, Parser, Ast, error::{Error as E}};
/// A compiled expression
#[derive(Debug, Clone)]
pub struct Expression {
raw: String,
ast: Ast,
}
impl Expression {
/// Create a new compiled Expression
... | code_fim | medium | {
"lang": "rust",
"repo": "4nickel/tag-suite",
"path": "/src/expression/expression.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
#[should_panic(expected = "UnexpectedEof")]
fn check_disallow_empty_expression() {
Expression::new(String::new()).unwrap();
}
}<|fim_prefix|>// repo: 4nickel/tag-suite path: /src/expression/expression.rs
use super::{import::*, T... | code_fim | hard | {
"lang": "rust",
"repo": "4nickel/tag-suite",
"path": "/src/expression/expression.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: insinfo/remotefs-rs path: /src/fs/file.rs
le system files
#[derive(Clone, Debug)]
pub struct File {
pub name: String,
pub abs_path: PathBuf,
pub last_change_time: SystemTime,
pub last_access_time: SystemTime,
pub creation_time: SystemTime,
pub size: usize,
pub ftype:... | code_fim | hard | {
"lang": "rust",
"repo": "insinfo/remotefs-rs",
"path": "/src/fs/file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: insinfo/remotefs-rs path: /src/fs/file.rs
pub symlink: Option<Box<Entry>>, // UNIX only
pub user: Option<u32>, // UNIX only
pub group: Option<u32>, // UNIX only
pub unix_pex: Option<(UnixPex, UnixPex, UnixPex)... | code_fim | hard | {
"lang": "rust",
"repo": "insinfo/remotefs-rs",
"path": "/src/fs/file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t_now: SystemTime = SystemTime::now();
let entry: Entry = Entry::File(File {
name: String::from("bar.txt"),
abs_path: PathBuf::from("/bar.txt"),
last_change_time: t_now,
last_access_time: t_now,
creation_time: t_now,
... | code_fim | hard | {
"lang": "rust",
"repo": "insinfo/remotefs-rs",
"path": "/src/fs/file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut app = tide::App::new(());
app.at("/add_one/:num").get(add_one);
let mut server = make_server(app.into_http_service()).unwrap();
let req = http::Request::get("/add_one/").body(Body::empty()).unwrap();
let res = server.simulate(req).unwrap();
assert_eq!(res.status(), 404);
}... | code_fim | hard | {
"lang": "rust",
"repo": "niklasf/tide",
"path": "/tests/wildcard.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niklasf/tide path: /tests/wildcard.rs
#![feature(futures_api, async_await)]
use futures::executor::block_on;
use http_service::Body;
use http_service_mock::make_server;
use tide::{error::ResultExt, Context};
async fn add_one(cx: Context<()>) -> Result<String, tide::Error> {
let num: i64 = ... | code_fim | hard | {
"lang": "rust",
"repo": "niklasf/tide",
"path": "/tests/wildcard.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tarshish0906/Rust_grep path: /fizzbuzz/src/main.rs
fn fizzbuzz(n: u32) -> String {
if n & 15 == 0 {
"FizzBuzz".to_string()
} else if n % 5 == 0 {
"Buzz".to_string()
} else if n % 3 == 0 {
"Fizz".to_string()
} else {
format!("{}", n)
}
}
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "Tarshish0906/Rust_grep",
"path": "/fizzbuzz/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_fizzbuzz_returns_fizzbuzz() {
let expected = "FizzBuzz".to_string();
let actual = fizzbuzz(15);
assert_eq!(expected, actual);
}<|fim_prefix|>// repo: Tarshish0906/Rust_grep path: /fizzbuzz/src/main.rs
fn fizzbuzz(n: u32) -> String {
if n & 15 == 0 {
"FizzBuzz".to_s... | code_fim | medium | {
"lang": "rust",
"repo": "Tarshish0906/Rust_grep",
"path": "/fizzbuzz/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmcarther/depend path: /example/engine/src/systems.rs
use std::time::Duration;
use specs::World;
use specs::RunArg;
use specs::System;
macro_rules! null_system {
($thing:ty, $message:expr) => {
impl System<Duration> for $thing {
fn run(&mut self, arg: RunArg, _: Duration) {
... | code_fim | medium | {
"lang": "rust",
"repo": "acmcarther/depend",
"path": "/example/engine/src/systems.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct SomeSystem;
null_system!(SomeSystem, "hello23");
declare_data_dependencies!(SomeSystem, []);
declare_system_dependencies!(SomeSystem, []);
standalone_installer_from_new!(SomeSystem, Duration);
impl SomeSystem {
pub fn new() -> SomeSystem {
SomeSystem
}
}
pub struct SomeOtherSystem;
n... | code_fim | medium | {
"lang": "rust",
"repo": "acmcarther/depend",
"path": "/example/engine/src/systems.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub struct SomeOtherSystem;
null_system!(SomeOtherSystem, "goodbye23");
declare_data_dependencies!(SomeOtherSystem, []);
declare_system_dependencies!(SomeOtherSystem, []);
standalone_installer_from_new!(SomeOtherSystem, Duration);
impl SomeOtherSystem {
pub fn new() -> SomeOtherSystem {
SomeOtherS... | code_fim | medium | {
"lang": "rust",
"repo": "acmcarther/depend",
"path": "/example/engine/src/systems.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.mapper_internal
.get_prg_rom_byte(address, self.prg_bank, _32KB)
}
fn power_cycle(&mut self) {
self.prg_bank = 0;
self.chr_bank = 0;
self.mapper_internal.reset();
}
fn store_chr_byte(&mut self, address: u16, byte: u8) {
... | code_fim | hard | {
"lang": "rust",
"repo": "selassje/nes-rs",
"path": "/src/mappers/mapper66.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: selassje/nes-rs path: /src/mappers/mapper66.rs
use super::Mapper;
use crate::common::Mirroring;
use crate::mappers::mapper_internal::BankSize::*;
use crate::mappers::mapper_internal::MapperInternal;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Mapper6... | code_fim | hard | {
"lang": "rust",
"repo": "selassje/nes-rs",
"path": "/src/mappers/mapper66.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn store_prg_byte(&mut self, _: u16, byte: u8) {
self.chr_bank = (byte & 3) as usize;
self.prg_bank = ((byte & 0b00110000) >> 4) as usize;
}
}<|fim_prefix|>// repo: selassje/nes-rs path: /src/mappers/mapper66.rs
use super::Mapper;
use crate::common::Mirroring;
use crate::map... | code_fim | hard | {
"lang": "rust",
"repo": "selassje/nes-rs",
"path": "/src/mappers/mapper66.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Stinners/get-energies path: /src/get_filetype.rs
use std::fs::File;
use std::io::{BufReader, BufRead, Result, Lines};
use crate::{
gamess,
pychem,
qchem,
};
pub type Reader = Lines<BufReader<File>>;
#[derive(PartialEq, Eq, Debug)]
pub enum Program {
PyChem,
QChem,
Gam... | code_fim | hard | {
"lang": "rust",
"repo": "Stinners/get-energies",
"path": "/src/get_filetype.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in lines.by_ref().take(50) {
let line = line.unwrap();
if pychem::check(&line) { filetype = Program::PyChem }
else if qchem::check(&line) { filetype = Program::QChem }
else if gamess::check(&line) { filetype = Program::G... | code_fim | medium | {
"lang": "rust",
"repo": "Stinners/get-energies",
"path": "/src/get_filetype.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /frame/treasury/src/lib.rs
and use the funds to pay developers.
//!
//!
//! ### Terminology
//!
//! - **Proposal:** A suggestion to allocate funds from the pot to a beneficiary.
//! - **Beneficiary:** An account who will receive the funds from a proposal iff the propos... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/frame/treasury/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Maximum amount of funds that should be placed in a deposit for making a proposal.
#[pallet::constant]
type ProposalBondMaximum: Get<Option<BalanceOf<Self, I>>>;
/// Period between successive spends.
#[pallet::constant]
type SpendPeriod: Get<BlockNumberFor<Self>>;
/// Percentage of spar... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/frame/treasury/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /frame/treasury/src/lib.rs
ntimeOrigin>;
/// The overarching event type.
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Handler for the unbalanced decrease when slashing for a rejected proposal or bounty.
... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/frame/treasury/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("number is divisible by 3");
} else if number % 2 == 0 {
println!("number is divisible by 2");
} else {
println!("number is not divisible by 4,3, or 2");
}
//let 语句中使用if
let val = if 16 % 4 == 0 {
0
} else {
1
};
println!("val={}",... | code_fim | medium | {
"lang": "rust",
"repo": "huangqian/rust-in-action",
"path": "/examples/control-flow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s not divisible by 4,3, or 2");
}
//let 语句中使用if
let val = if 16 % 4 == 0 {
0
} else {
1
};
println!("val={}", val)
}<|fim_prefix|>// repo: huangqian/rust-in-action path: /examples/control-flow.rs
fn main() {
let number = 3;
if number < 5 {
println!... | code_fim | hard | {
"lang": "rust",
"repo": "huangqian/rust-in-action",
"path": "/examples/control-flow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huangqian/rust-in-action path: /examples/control-flow.rs
fn main() {
let number = 3;
if number < 5 {
println!("condition was true");
} else {
println!("condition was false");
}
//if-else if - else if - else
let number = 6;
if number % 4 == 0 {
prin... | code_fim | medium | {
"lang": "rust",
"repo": "huangqian/rust-in-action",
"path": "/examples/control-flow.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twuebi/ohnomore_seq2seq_rs path: /ohnomore_seq2seq_rs/src/lemma/tf/tf_config/debug.rs
t::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::P... | code_fim | hard | {
"lang": "rust",
"repo": "twuebi/ohnomore_seq2seq_rs",
"path": "/ohnomore_seq2seq_rs/src/lemma/tf/tf_config/debug.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn default_instance() -> &'static DebugOptions {
static mut instance: ::protobuf::lazy::Lazy<DebugOptions> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const DebugOptions,
};
unsafe {
instance.get(DebugOptions::new... | code_fim | hard | {
"lang": "rust",
"repo": "twuebi/ohnomore_seq2seq_rs",
"path": "/ohnomore_seq2seq_rs/src/lemma/tf/tf_config/debug.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn default_instance() -> &'static DebuggedSourceFiles {
static mut instance: ::protobuf::lazy::Lazy<DebuggedSourceFiles> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const DebuggedSourceFiles,
};
unsafe {
instance.... | code_fim | hard | {
"lang": "rust",
"repo": "twuebi/ohnomore_seq2seq_rs",
"path": "/ohnomore_seq2seq_rs/src/lemma/tf/tf_config/debug.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_resolver: F,
) -> Result<FlashManifest<impl FileResolver + Sync>> {
let reader = File::open(file_resolver.manifest()).map(BufReader::new)?;
Ok(FlashManifest { resolver: file_resolver, version: FlashManifestVersion::load(reader)? })
}
pub struct FlashManifest<F: FileResolver + Sync> {
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/lib/fastboot/src/manifest/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/lib/fastboot/src/manifest/mod.rs
requires_unlock: !product_bundle.partitions.bootstrap_partitions.is_empty(),
});
if !product_bundle.partitions.bootstrap_partitions.is_empty() {
products.push(v3::Product {
name... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/lib/fastboot/src/manifest/mod.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct FlashManifest<F: FileResolver + Sync> {
resolver: F,
version: FlashManifestVersion,
}
impl<F: FileResolver + Sync> FlashManifest<F> {
pub async fn flash<W: Write>(
&mut self,
writer: &mut W,
fastboot_proxy: FastbootProxy,
cmd: ManifestParams,
) -... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/lib/fastboot/src/manifest/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alphaville/unit_test_utils.rs path: /src/lib.rs
//! Collection of utilities for unit tests
//!
//! This crate offers tools for unit tests, especially for projects involving
//! numerical methods
//!
extern crate num;
use num::{Float, Zero};
fn float_max<T>(a: T, b: T) -> T
where
T: Float,
{... | code_fim | hard | {
"lang": "rust",
"repo": "alphaville/unit_test_utils.rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = 5.;
let b = 5.;
assert!(nearly_equal(
a,
b,
std::f64::MIN_POSITIVE,
std::f64::MIN_POSITIVE
))
}
#[test]
fn with_f32() {
let a = 1000.0_f32;
let b = 1001.0_f32;
assert!(nearly_equal(... | code_fim | hard | {
"lang": "rust",
"repo": "alphaville/unit_test_utils.rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> ObjectId<T> {
/// Changes the type this [`ObjectId`] points to, unchecked.
///
/// This will allow changing to any type - `ObjectId` makes no guarantees
/// about its ID matching the type of any object in the game that it
/// actually points to.
pub fn into_type<U>(self) ->... | code_fim | hard | {
"lang": "rust",
"repo": "smessmer/screeps-game-api",
"path": "/src/local/object_id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smessmer/screeps-game-api path: /src/local/object_id.rs
use std::{
cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd},
fmt,
hash::{Hash, Hasher},
marker::PhantomData,
str::FromStr,
};
use arrayvec::ArrayString;
use serde::{Deserialize, Serialize};
use stdweb::{Reference, Unsafe... | code_fim | hard | {
"lang": "rust",
"repo": "smessmer/screeps-game-api",
"path": "/src/local/object_id.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> PartialEq<RawObjectId> for ObjectId<T> {
#[inline]
fn eq(&self, other: &RawObjectId) -> bool {
self.raw == *other
}
}
impl<T> PartialEq<ObjectId<T>> for RawObjectId {
#[inline]
fn eq(&self, other: &ObjectId<T>) -> bool {
*self == other.raw
}
}
impl<T> Part... | code_fim | hard | {
"lang": "rust",
"repo": "smessmer/screeps-game-api",
"path": "/src/local/object_id.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input.trim().parse().expect("invalid input")
}
pub fn output(x: i128) -> i128 {
x
}
}<|fim_prefix|>// repo: sapkos/advent_of_code path: /2019/task09/src/intcode/operator.rs
use std::io;
pub struct Operator {}
impl Operator {
pub fn add(x: i128, y: i128) -> i128 {
... | code_fim | hard | {
"lang": "rust",
"repo": "sapkos/advent_of_code",
"path": "/2019/task09/src/intcode/operator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sapkos/advent_of_code path: /2019/task09/src/intcode/operator.rs
use std::io;
pub struct Operator {}
impl Operator {
pub fn add(x: i128, y: i128) -> i128 {
x + y
}
pub fn multiply(x: i128, y: i128) -> i128 {
x * y
}
<|fim_suffix|> pub fn output(x: i128) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "sapkos/advent_of_code",
"path": "/2019/task09/src/intcode/operator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn output(x: i128) -> i128 {
x
}
}<|fim_prefix|>// repo: sapkos/advent_of_code path: /2019/task09/src/intcode/operator.rs
use std::io;
pub struct Operator {}
impl Operator {
pub fn add(x: i128, y: i128) -> i128 {
x + y
}
<|fim_middle|> pub fn multiply(x: i128, y:... | code_fim | hard | {
"lang": "rust",
"repo": "sapkos/advent_of_code",
"path": "/2019/task09/src/intcode/operator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct CasbinMiddleware<S> {
service: Rc<RefCell<S>>,
enforcer: Arc<RwLock<CachedEnforcer>>,
}
impl<S, B> Service<ServiceRequest> for CasbinMiddleware<S>
where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
B: MessageBody,
{
type Response = Ser... | code_fim | hard | {
"lang": "rust",
"repo": "casbin-rs/actix-casbin-auth",
"path": "/src/middleware.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: casbin-rs/actix-casbin-auth path: /src/middleware.rs
#![allow(clippy::type_complexity)]
use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use std::sync::Arc;
use std::task::{Context, Poll};
use futures::future::{ok, LocalBoxFuture, Ready};
use futures::FutureExt;
use a... | code_fim | hard | {
"lang": "rust",
"repo": "casbin-rs/actix-casbin-auth",
"path": "/src/middleware.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn __getitem__(&self, name: &str) -> PyResult<PyObject> {
DictLikeAPI::__getitem__(self, name)
}
fn __len__(&self) -> PyResult<usize> {
DictLikeAPI::__len__(self)
}
fn __iter__(slf: PyRefMut<Self>) -> PyResult<DictLikeIter> {
DictLikeAPI::__iter__(&*slf)
}... | code_fim | hard | {
"lang": "rust",
"repo": "Origen-SDK/o2",
"path": "/rust/pyapi/src/pins/pin_container.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut endianness = Option::None;
match options {
Some(options) => {
if let Some(opt) = options.get_item("little_endian") {
if opt.extract::<bool>()? {
endianness = Option::Some(Endianness::LittleEndian);
... | code_fim | hard | {
"lang": "rust",
"repo": "Origen-SDK/o2",
"path": "/rust/pyapi/src/pins/pin_container.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Origen-SDK/o2 path: /rust/pyapi/src/pins/pin_container.rs
use crate::get_full_class_name;
use crate::meta::py_like_apis::dict_like_api::{DictLikeAPI, DictLikeIter};
use indexmap::map::IndexMap;
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyTuple};
use super::pin_collection::PinCollection;
u... | code_fim | hard | {
"lang": "rust",
"repo": "Origen-SDK/o2",
"path": "/rust/pyapi/src/pins/pin_container.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: n3f4s/gameboy_emulator path: /build.rs
// use std::{
// fs,
// io::{prelude::*, BufReader},
// };
// extern crate regex;
// use regex::Regex;
fn main() {
// println!("cargo:rerun-if-changed=src/z80/instructions.rs");
// let filename = "src/z80/instructions.rs";
// let file =... | code_fim | hard | {
"lang": "rust",
"repo": "n3f4s/gameboy_emulator",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct OpcodeMap<'a> {{
// pub op_map: [Box<Instruction>; {size}],
// pub op_name: [&'a str; {size}],
// }}
//
// impl<'a> OpcodeMap<'a> {{
// pub fn new() -> OpcodeMap<'a> {{
// OpcodeMap {{
// op_map: [ {map} ],
// op_name: [ {name} ],
// }}
// }}... | code_fim | hard | {
"lang": "rust",
"repo": "n3f4s/gameboy_emulator",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edualb/utils path: /rust/managing_growing_projects_with_packages_crates_and_modules/src/library_example/src/lib.rs
// Module tree
//
// crate
// - front_of_house
// - hosting
// - add_to_waitlist
// - seat_at_table
// - serving
// - take_order
// ... | code_fim | hard | {
"lang": "rust",
"repo": "edualb/utils",
"path": "/rust/managing_growing_projects_with_packages_crates_and_modules/src/library_example/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod back_of_house {
pub enum Appetizer {
Soup, // public
Salad, // public
}
pub struct Breakfast {
pub toast: String, // public
seasonal_fruit: String, // private
}
impl Breakfast {
pub fn summer(toast: &str) -> Breakfast {
Breakfas... | code_fim | hard | {
"lang": "rust",
"repo": "edualb/utils",
"path": "/rust/managing_growing_projects_with_packages_crates_and_modules/src/library_example/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn eat_at_restaurant4() {
hosting::add_to_waitlist();
add_to_waitlist();
hosting::add_to_waitlist();
}
// Import more than 1 Result:
use std::fmt;
use std::io;
// Or you can provide new name ->
//
// use std::fmt::Result
// use std::io::Result as IoResult
// fn function1() -> fmt::Resu... | code_fim | hard | {
"lang": "rust",
"repo": "edualb/utils",
"path": "/rust/managing_growing_projects_with_packages_crates_and_modules/src/library_example/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[deny(while_true)]
while true {}
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs
// compile-flags: -Ztreat-err-as-bug
// dont-check-failure-status
// error-pattern: aborting due to `-Z treat-err-as-bug=1`
// dont-check-compiler-stderr
// rustc-e... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs
// compile-flags: -Ztreat-err-as-bug
// dont-check-failure-status
// error-pattern: aborting due to `-Z treat-err-as-bug=1`
// dont-check-compiler-stderr
// rustc-env:RUST_BACKTRACE=0
<|fim_suffix|> #[deny(while_true)... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/cargo path: /credential/cargo-credential/examples/file-provider.rs
//! Example credential provider that stores credentials in a JSON file.
//! This is not secure
use cargo_credential::{
Action, CacheControl, Credential, CredentialResponse, RegistryInfo, Secret,
};
use std::{collec... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/credential/cargo-credential/examples/file-provider.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> match File::open("cargo-credentials.json") {
Ok(f) => Ok(serde_json::from_reader(f)?),
Err(e) if e.kind() == ErrorKind::NotFound => Ok(HashMap::new()),
Err(e) => Err(e)?,
}
}
fn write(value: &HashMap<String, Secret<String>>) -> Result<(), Error> ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/credential/cargo-credential/examples/file-provider.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> FileCredential::write(&creds).map_err(cargo_credential::Error::Other)?;
// Credentials were successfully stored.
Ok(CredentialResponse::Login)
}
Action::Logout => {
if creds.remove(registry.index_url).is_none() {
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/cargo",
"path": "/credential/cargo-credential/examples/file-provider.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut coins : Vec<u32> = Vec::new();
// All the values are meant to be Euro cents
coins.push(50000);
coins.push(20000);
coins.push(10000);
coins.push(5000);
coins.push(2000);
coins.push(1000);
coins.push(500);
coins.push(200);
coins.push(100);
coins.push(5... | code_fim | medium | {
"lang": "rust",
"repo": "ktilcu/daily-coding-challenge",
"path": "/01-make-change/PucklaMotzer09.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ktilcu/daily-coding-challenge path: /01-make-change/PucklaMotzer09.rs
fn change(mut money : u32, coins : &Vec<u32>) -> Vec<u32> {
// Stores all the amounts of the coins
let mut coin_amounts : Vec<u32> = Vec::new();
for c in coins.iter() {
// If the current coin value is great... | code_fim | medium | {
"lang": "rust",
"repo": "ktilcu/daily-coding-challenge",
"path": "/01-make-change/PucklaMotzer09.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut coins : Vec<u32> = Vec::new();
// All the values are meant to be Euro cents
coins.push(50000);
coins.push(20000);
coins.push(10000);
coins.push(5000);
coins.push(2000);
coins.push(1000);
coins.push(500);
coins.push(200);
coins.push(100);
... | code_fim | hard | {
"lang": "rust",
"repo": "ktilcu/daily-coding-challenge",
"path": "/01-make-change/PucklaMotzer09.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>bitflags! {
flags AHBENR: u32 {
const DMA1EN = 1 << 0,
const DMA2EN = 1 << 1,
const SRAMEN = 1 << 2,
const FLITFEN = 1 << 4,
const CRCEN = 1 << 6,
const GPIOAEN = 1 << 17,
const GPIOBEN = 1 << 18,
const GPIOCEN = 1 << 19,
... | code_fim | medium | {
"lang": "rust",
"repo": "SillyFreak/stm32f3-rust-demo",
"path": "/src/stm32f3/rcc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SillyFreak/stm32f3-rust-demo path: /src/stm32f3/rcc.rs
use registers::RegPtr;
#[repr(C, packed)]
#[allow(non_snake_case)]
pub struct Rcc {
pub CR: u32, //0x00
pub CFGR: u32, //0x04
pub CIR: u32, //0x08
pub APB2RSTR: u32, //0x0C
pub APB1RSTR: u32, //0x10
pu... | code_fim | medium | {
"lang": "rust",
"repo": "SillyFreak/stm32f3-rust-demo",
"path": "/src/stm32f3/rcc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yatekii/stm32mp1-pac path: /src/gicd/ppisr.rs
#[doc = "Reader of register PPISR"]
pub type R = crate::R<u32, super::PPISR>;
#[doc = "Reader of field `PPI6`"]
pub type PPI6_R = crate::R<bool, bool>;
#[doc = "Reader of field `PPI5`"]
pub type PPI5_R = crate::R<bool, bool>;
#[doc = "Reader of field... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/stm32mp1-pac",
"path": "/src/gicd/ppisr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline(always)]
pub fn ppi1(&self) -> PPI1_R {
PPI1_R::new(((self.bits >> 13) & 0x01) != 0)
}
#[doc = "Bit 14 - secure physical timer event"]
#[inline(always)]
pub fn ppi2(&self) -> PPI2_R {
PPI2_R::new(((self.bits >> 14) & 0x01) != 0)
}
#[doc = "Bit 15 - nIRQ... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/stm32mp1-pac",
"path": "/src/gicd/ppisr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Sets the global recorder to a `&'static Recorder`.
///
/// This function may only be called once in the lifetime of a program. Any metrics recorded
/// before the call to `set_recorder` occurs will be completely ignored.
///
/// This function does not typically need to be called manually. Metrics im... | code_fim | hard | {
"lang": "rust",
"repo": "str4d/metrics",
"path": "/metrics/src/recorder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: str4d/metrics path: /metrics/src/recorder.rs
use crate::{Key, Unit};
use core::fmt;
use core::sync::atomic::{AtomicUsize, Ordering};
static mut RECORDER: &'static dyn Recorder = &NoopRecorder;
static STATE: AtomicUsize = AtomicUsize::new(0);
const UNINITIALIZED: usize = 0;
const INITIALIZING: ... | code_fim | hard | {
"lang": "rust",
"repo": "str4d/metrics",
"path": "/metrics/src/recorder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spiveeworks/spell-craft_demo path: /src/game/mod.rs
use charm_internal::units;
use piston_window as app;
mod clock;
mod draw;
mod game_state;
mod grenade_builder;
mod user_input;
pub struct Game {
state: game_state::GameState,
real_time: clock::Stuttering,
input: user_input::In... | code_fim | hard | {
"lang": "rust",
"repo": "spiveeworks/spell-craft_demo",
"path": "/src/game/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> app::clear([0.0, 0.0, 0.0, 1.0], graphics);
let center = context
.transform
.trans(
(ren.width / 2) as f64,
(ren.height / 2) as f64
);
let position = self.state.player.body.position(now);
draw::draw_at(&se... | code_fim | hard | {
"lang": "rust",
"repo": "spiveeworks/spell-craft_demo",
"path": "/src/game/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let center = context
.transform
.trans(
(ren.width / 2) as f64,
(ren.height / 2) as f64
);
let position = self.state.player.body.position(now);
draw::draw_at(&self.state.player.shape, position, center, graphics);
... | code_fim | hard | {
"lang": "rust",
"repo": "spiveeworks/spell-craft_demo",
"path": "/src/game/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Allocates a port for testing purpose.
pub fn alloc_port() -> u16 {
let p = INITIAL_PORT.load(Ordering::Relaxed);
if p == 0 {
let _ = INITIAL_PORT.compare_exchange(
0,
rand::thread_rng().gen_range(10240..MIN_LOCAL_PORT),
Ordering::SeqCst,
... | code_fim | hard | {
"lang": "rust",
"repo": "BusyJay/tikv",
"path": "/components/test_util/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BusyJay/tikv path: /components/test_util/src/lib.rs
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
#![feature(test)]
extern crate test;
#[macro_use]
extern crate slog_global;
pub mod encryption;
mod kv_generator;
mod logging;
mod macros;
mod runner;
mod security;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "BusyJay/tikv",
"path": "/components/test_util/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WisartArfun/Divisionaries path: /scr_v1/http_server/mod.rs
pub mod game_service_provider;
pub mod http_utils;
use std::thread;
use std::sync::Arc;
use actix_web::{web, App, HttpServer};
use log;
pub trait ProvideService: Send + Sync {
fn configure_services(cfg: &mut web::ServiceConfig);
}... | code_fim | hard | {
"lang": "rust",
"repo": "WisartArfun/Divisionaries",
"path": "/scr_v1/http_server/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> thread::spawn(move || -> std::io::Result<()> {
log::debug!("started new thread for HttpGameServer");
HttpServer::new(move || {
App::new()
.configure(P::configure_services)
})
.bind(format!("{}:{}", &ip, &port))
... | code_fim | hard | {
"lang": "rust",
"repo": "WisartArfun/Divisionaries",
"path": "/scr_v1/http_server/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod t12_double_escaped_interpolated_value_todo;
mod t22_double_escaped_interpolated_variable;
mod t32_double_escaped_literal;<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/non_conformant/parser/interpolate/t44_selector/double_escape/mod.rs
//! Tests auto-converted from "sass-spec/spec/non_con... | code_fim | easy | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/non_conformant/parser/interpolate/t44_selector/double_escape/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/non_conformant/parser/interpolate/t44_selector/double_escape/mod.rs
//! Tests auto-converted from "sass-spec/spec/non_conformant/parser/interpolate/44_selector/double_escape"
<|fim_suffix|> super::runner().with_cwd("double_escape")
}
mod t12_double_escaped_... | code_fim | easy | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/non_conformant/parser/interpolate/t44_selector/double_escape/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nfk93/shamir path: /src/field_instance.rs
use crate::field::Field;
const P: u32 = 1613;
#[derive(Debug, Clone, Copy)]
pub struct G1613(u32);
impl G1613 {
pub fn new(v: u32) -> Self {
G1613(v % P)
}
}
impl Field for G1613 {
fn one() -> Self {
G1613(1)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "nfk93/shamir",
"path": "/src/field_instance.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::fmt;
impl fmt::Display for G1613 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
use rand::Rng;
impl rand::Rand for G1613 {
fn rand<R: Rng>(rng: &mut R) -> G1613 {
let u = rng.gen_range::<u32>(0, 1613);
G1613(u)
... | code_fim | hard | {
"lang": "rust",
"repo": "nfk93/shamir",
"path": "/src/field_instance.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivardb/AdventOfCode2020 path: /src/days/day22/part1.rs
use std::collections::VecDeque;
use crate::days::day22::{parse_input, default_input};
pub fn run() {
println!("{}", combat_str(default_input()).unwrap())
}
<|fim_suffix|>pub fn combat(mut p1: VecDeque<i64>, mut p2 : VecDeque<i64>) -> R... | code_fim | medium | {
"lang": "rust",
"repo": "ivardb/AdventOfCode2020",
"path": "/src/days/day22/part1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
pub fn part1_answer() {
assert_eq!(combat_str(default_input()).unwrap(), 35202)
}
}<|fim_prefix|>// repo: ivardb/AdventOfCode2020 path: /src/days/day22/part1.rs
use std::collections::VecDeque;
use crate::days::day22::{parse_input, default_input};
pub fn run() {
println!("... | code_fim | medium | {
"lang": "rust",
"repo": "ivardb/AdventOfCode2020",
"path": "/src/days/day22/part1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: im-0/gotham path: /gotham/src/router/route/matcher/content_type.rs
//! Defines the `ContentTypeHeaderRouteMatcher`.
use hyper::header::{ContentType, Headers};
use hyper::StatusCode;
use mime;
use router::non_match::RouteNonMatch;
use router::route::RouteMatcher;
use state::{request_id, FromSta... | code_fim | hard | {
"lang": "rust",
"repo": "im-0/gotham",
"path": "/gotham/src/router/route/matcher/content_type.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace!(
"[{}] did not specify a Content-Type with a media type supported by this Route",
request_id(&state)
);
Err(RouteNonMatch::new(StatusCode::UnsupportedMediaType))
}
// The client has not s... | code_fim | hard | {
"lang": "rust",
"repo": "im-0/gotham",
"path": "/gotham/src/router/route/matcher/content_type.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: julianschick/schnyder-woods path: /src/graph/indices.rs
use crate::graph::index_store::Index;
use core::fmt;
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct VertexI(pub usize);
impl From<usize> for VertexI {
fn from(n: usize) -> Self {
VertexI(n)
}
}
impl Into<usize> for... | code_fim | hard | {
"lang": "rust",
"repo": "julianschick/schnyder-woods",
"path": "/src/graph/indices.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct FaceI(pub usize);
impl From<usize> for FaceI {
fn from(n: usize) -> Self {
FaceI(n)
}
}
impl Into<usize> for FaceI {
fn into(self) -> usize {
self.0
}
}
impl Index for FaceI {}
impl fmt::Display for FaceI {
... | code_fim | hard | {
"lang": "rust",
"repo": "julianschick/schnyder-woods",
"path": "/src/graph/indices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0
}
}
impl Index for FaceI {}
impl fmt::Display for FaceI {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "f_{}", self.0)
}
}<|fim_prefix|>// repo: julianschick/schnyder-woods path: /src/graph/indices.rs
use crate::graph::index_store::Index;
use cor... | code_fim | hard | {
"lang": "rust",
"repo": "julianschick/schnyder-woods",
"path": "/src/graph/indices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn send_response<R: serde::Serialize>(&mut self, id: i64, result: R) {
let mut buf = Vec::new();
serde_json::to_writer(
&mut buf,
&LspResponse::<R> {
jsonrpc: "2.0".to_string(),
id,
result,
}... | code_fim | hard | {
"lang": "rust",
"repo": "vain0x/hsp3-ginger",
"path": "/hsp3-analyzer-mini/ham-core/src/lsp_server/lsp_sender.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vain0x/hsp3-ginger path: /hsp3-analyzer-mini/ham-core/src/lsp_server/lsp_sender.rs
use super::{LspError, LspErrorResponse, LspNotification, LspRequest, LspResponse};
use serde_json::Value;
use std::io::{self, Write as _};
pub(super) struct LspSender<W: io::Write> {
out: io::BufWriter<W>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "vain0x/hsp3-ginger",
"path": "/hsp3-analyzer-mini/ham-core/src/lsp_server/lsp_sender.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/lisbeth path: /lisbeth-tuple-tools/src/lib.rs
//! Some tools to manipulate tuples.
//!
//! Most traits in this crate are implemented for tuples with an arity inferior
//! or equal to eight.
//!
//! # `TupleAppend`
//!
//! There is no simple way to append a value of type `C` to a tuple of... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/lisbeth",
"path": "/lisbeth-tuple-tools/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> `TupleMap*` trait:
//!
//! ```rust
//! use lisbeth_tuple_tools::TupleMap1;
//!
//! let t = ('a', 0, "foo");
//! let t = t.map_1(char::len_utf8);
//!
//! assert_eq!(t, (1, 0, "foo"));
//! ```
#![deny(warnings)]
mod append;
mod map;
pub use append::TupleAppend;
pub use map::*;<|fim_prefix|>// repo: iCod... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/lisbeth",
"path": "/lisbeth-tuple-tools/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn part_one(input: &str) -> Option<usize> {
let mut root = Node::new(Type::Dir, 0);
{
let (tree, _, root_size) = build_tree(aoc::utils::read_list(input).as_slice(), 1);
root.size = root_size;
root.content.get_mut().extend(tree);
}
Some(filter_dir(&root, 100000))
}
... | code_fim | hard | {
"lang": "rust",
"repo": "amarzial/advent_of_code",
"path": "/src/bin/2022_07.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amarzial/advent_of_code path: /src/bin/2022_07.rs
use std::cell::RefCell;
use std::collections::HashMap;
#[derive(Debug)]
enum Type {
Dir,
File,
}
type Content = HashMap<String, Node>;
#[derive(Debug)]
struct Node {
t: Type,
size: usize,
content: RefCell<Content>,
}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "amarzial/advent_of_code",
"path": "/src/bin/2022_07.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut root = Node::new(Type::Dir, 0);
{
let (tree, _, root_size) = build_tree(aoc::utils::read_list(input).as_slice(), 1);
root.size = root_size;
root.content.get_mut().extend(tree);
}
let disk_size = 70000000;
let needed_space = 30000000 - (disk_size - root.... | code_fim | hard | {
"lang": "rust",
"repo": "amarzial/advent_of_code",
"path": "/src/bin/2022_07.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for object in &self.objects {
let temp_option = object.hit(r, t_min, closest_so_far);
if let Some(rec) = temp_option {
rec_option = temp_option;
closest_so_far = rec.t;
}
}
rec_option
}
}
pub trait Hittable {
fn hit(&self, r: &Ray, t_min: f64, t_max: f64)... | code_fim | hard | {
"lang": "rust",
"repo": "kaaniboy/rust-raytracing",
"path": "/src/hittable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaaniboy/rust-raytracing path: /src/hittable.rs
use super::vec3::{Point3, Vec3};
use super::ray::Ray;
use super::material::Material;
#[derive(Copy, Clone)]
pub struct HitRecord<'a> {
pub p: Point3,
pub normal: Vec3,
pub material: &'a dyn Material,
pub t: f64,
pub front_face: bool,
}
... | code_fim | medium | {
"lang": "rust",
"repo": "kaaniboy/rust-raytracing",
"path": "/src/hittable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! unwrap_or_map_return {
($result:expr, $on_err:expr) => {
match $result {
Ok(res) => res,
Err(err) =>
{
#[allow(clippy::redundant_closure_call)]
return ($on_err)(err)
}
}
};
}
macro_rules! ... | code_fim | hard | {
"lang": "rust",
"repo": "hyperledger/indy-vdr",
"path": "/libindy_vdr/src/utils/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.