text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> // NOTE: swapping the bytes here, the HAL should be able to handle such a thing
let mut buffer = [0u8; 2];
// bits 11 through 0: data
buffer[1] = (data.val() & 0x00FF) as _;
buffer[0] = ((data.val() >> 8) & (0x000F as u16)) as u8
// bit 12: shutdown bit.... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/oxcc",
"path": "/src/dac_mcp4922.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> crc = state.calc(&buffer[..], read as i32, crc);
}
hash_string(&[crc])
}<|fim_prefix|>// repo: oli-obk/checksums path: /src/hashing/crc8.rs
use self::super::hash_string;
use std::path::PathBuf;
use std::fs::File;
use std::io::Read;
use crc8::Crc8;
<|fim_middle|>pub fn hash(path: &PathB... | code_fim | hard | {
"lang": "rust",
"repo": "oli-obk/checksums",
"path": "/src/hashing/crc8.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oli-obk/checksums path: /src/hashing/crc8.rs
use self::super::hash_string;
use std::path::PathBuf;
use std::fs::File;
use std::io::Read;
use crc8::Crc8;
pub fn hash(path: &PathBuf) -> String {
let mut file = File::open(path).unwrap();
let mut buffer = vec![0; 1024];
let mut state ... | code_fim | medium | {
"lang": "rust",
"repo": "oli-obk/checksums",
"path": "/src/hashing/crc8.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: miracl/core path: /rust/rom_brainpool_32.rs
/*
* Copyright (c) 2012-2020 MIRACL UK Ltd.
*
* This file is part of MIRACL Core
* (see https://github.com/miracl/core).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with th... | code_fim | medium | {
"lang": "rust",
"repo": "miracl/core",
"path": "/rust/rom_brainpool_32.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// brainpool Curve
pub const CURVE_COF_I: isize = 1;
pub const CURVE_B_I: isize = 0;
pub const CURVE_COF: [Chunk; NLEN] = [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0];
pub const CURVE_B: [Chunk; NLEN] = [
0xEE92B04, 0xE58101F, 0xF49256A, 0xEBC4AF2, 0x6B7BF93, 0x733D0B7, 0x4FE66A7, 0x30D84EA,
... | code_fim | hard | {
"lang": "rust",
"repo": "miracl/core",
"path": "/rust/rom_brainpool_32.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>PrimaryCivQuestPartA,
SolvingPrimaryCivQuestPartB,
UnlockingInvitationPathA,
UnlockingInvitationPathB,
DialogueBalanceA,
DialogueBalanceB,
SolvingSecondaryQuestA,
SolvingSecondaryQuestB,
AllDone,
}<|fim_prefix|>// repo: jakmeier/paddlers-browser-game path: /paddlers-shared... | code_fim | hard | {
"lang": "rust",
"repo": "jakmeier/paddlers-browser-game",
"path": "/paddlers-shared-lib/src/story/story_state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakmeier/paddlers-browser-game path: /paddlers-shared-lib/src/story/story_state.rs
use serde::{Deserialize, Serialize};
#[cfg(feature = "sql_db")]
use ::diesel_derive_enum::DbEnum;
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_... | code_fim | hard | {
"lang": "rust",
"repo": "jakmeier/paddlers-browser-game",
"path": "/paddlers-shared-lib/src/story/story_state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lluchs/libthread_db path: /src/proc_service.rs
/// Callback interface for libthread_db.
///
/// See /usr/include/proc_service.h
use std::ffi::CStr;
use std::collections::HashMap;
use errno::{errno, set_errno, Errno};
pub type PsAddr = libc::c_void;
const TRACE_CALLS: bool = true;
macro_rules... | code_fim | hard | {
"lang": "rust",
"repo": "lluchs/libthread_db",
"path": "/src/proc_service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let copy_str = "abcdefghijklmnopqrstuvwxyz123456879";
let mut u64_result = 0;
let mut u32_result = 0;
let mut str_result = vec![0u8; copy_str.len()];
let str_result_ptr = str_result.as_mut_slice().as_mut_ptr();
let parent_pid = std::process::id();
... | code_fim | hard | {
"lang": "rust",
"repo": "lluchs/libthread_db",
"path": "/src/proc_service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for &g_c in gcs.iter() {
params.insert("g_c", g_c);
for i in 0..10 {
neurons.push(Neuron::new(¶ms));
save = save + ",g_c=" + &(g_c.to_string()) + "|clamp=" + &((i * 10).to_string());
}
}
save = save + "\n";
for t in 0..20*1100 { // 1... | code_fim | hard | {
"lang": "rust",
"repo": "doraneko94/CA3-Rust",
"path": "/pinsky-rinzel/examples/fig1b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doraneko94/CA3-Rust path: /pinsky-rinzel/examples/fig1b.rs
use std::collections::HashMap;
use pinsky_rinzel::*;
use rayon::prelude::*;
fn main() {
let mut params = HashMap::new();
params.insert("n_neuron", 1.0);
params.insert("n_connect", 0.0);
let dt = 0.05;
let mut neuron... | code_fim | hard | {
"lang": "rust",
"repo": "doraneko94/CA3-Rust",
"path": "/pinsky-rinzel/examples/fig1b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for t in 0..20*1100 { // 1.1 s
neurons.par_iter_mut()
.enumerate()
.map(|(i, n)| {
n.soma.v = -10.0;
if t >= 20*1010 && t < 20*1013 {
n.soma.v = ((i % 10) * 10) as f64;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "doraneko94/CA3-Rust",
"path": "/pinsky-rinzel/examples/fig1b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Window {
window,
size_x: screen_size_x,
size_y: screen_size_y
}
}
pub fn update(&mut self) {
self.window.swap_buffers();
}
}<|fim_prefix|>// repo: EldarionDev/Third-Age-Standalone path: /src/engine/window.rs
use std::sync::mpsc::R... | code_fim | medium | {
"lang": "rust",
"repo": "EldarionDev/Third-Age-Standalone",
"path": "/src/engine/window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EldarionDev/Third-Age-Standalone path: /src/engine/window.rs
use std::sync::mpsc::Receiver;
use glfw::Context;
pub struct Window {
window: glfw::Window,
pub size_x: u32,
pub size_y: u32
}
impl Window {
pub fn new(screen_size_x: u32, screen_size_y: u32, window_event: &mut Optio... | code_fim | hard | {
"lang": "rust",
"repo": "EldarionDev/Third-Age-Standalone",
"path": "/src/engine/window.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> select_latest_hire(&session).expect("selected employee name")
});
workers.push(handle);
}
for handle in workers {
let name = handle.join().expect("select result");
assert_eq!(name, "Amit Banda was h... | code_fim | hard | {
"lang": "rust",
"repo": "quietboil/sibyl",
"path": "/src/pool/session/blocking.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quietboil/sibyl path: /src/pool/session/blocking.rs
//! Session pool blocking mode implementation
use super::{SessionPool, SPool};
use crate::{Result, oci::{self, *}, Environment, Session};
use std::{ptr, marker::PhantomData, sync::Arc};
impl SPool {
pub(crate) fn new(env: &Environment, db... | code_fim | hard | {
"lang": "rust",
"repo": "quietboil/sibyl",
"path": "/src/pool/session/blocking.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DCIanus/proc_macro_helper path: /src/variant.rs
use crate::{attribute::Attribute, field::Field};
use syn;
#[derive(Debug, Default, Eq, PartialEq, Clone)]
pub struct Variant {
pub name: String,
pub fields: Vec<Field>,
pub attributes: Vec<Attribute>,
}
<|fim_suffix|> result.fi... | code_fim | hard | {
"lang": "rust",
"repo": "DCIanus/proc_macro_helper",
"path": "/src/variant.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result.name = source.ident.to_string();
result.attributes = source
.attrs
.iter()
.map(|x| x.interpret_meta().unwrap())
.map(|x| Attribute::parse(&x))
.collect();
result.fields = match source.fields {
syn::Fi... | code_fim | medium | {
"lang": "rust",
"repo": "DCIanus/proc_macro_helper",
"path": "/src/variant.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kolmodin/advent-of-code-2020 path: /src/bin/day05.rs
extern crate nom;
use std::fs;
fn range(input: &str, low: i32, high: i32) -> i32 {
let mut lo = low;
let mut hi = high;
for ch in input.chars().into_iter() {
match ch {
'F' | 'L' => {
hi = lo + ... | code_fim | medium | {
"lang": "rust",
"repo": "kolmodin/advent-of-code-2020",
"path": "/src/bin/day05.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let my_seat_id = all_seats
.windows(2)
.find_map(|w| {
if w[0] != w[1] - 1 {
Some(w[0] + 1)
} else {
None
}
})
.unwrap();
println!("Part 2: {}", my_seat_id);
}<|fim_prefix|>// repo: kolmodin/advent... | code_fim | hard | {
"lang": "rust",
"repo": "kolmodin/advent-of-code-2020",
"path": "/src/bin/day05.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Part 1: {}", max_seat_id);
let my_seat_id = all_seats
.windows(2)
.find_map(|w| {
if w[0] != w[1] - 1 {
Some(w[0] + 1)
} else {
None
}
})
.unwrap();
println!("Part 2: {}", my_seat_id... | code_fim | hard | {
"lang": "rust",
"repo": "kolmodin/advent-of-code-2020",
"path": "/src/bin/day05.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Which means we can now call do_thing(). Magic!
info!("{}", my_trait.do_thing());
// This works because the #[reflect(MyTrait)] we put on MyType informed the Reflect derive to
// insert a new instance of ReflectDoThing into MyType's registration. The instance knows
// how to cast &d... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/examples/reflection/trait_reflection.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bevyengine/bevy path: /examples/reflection/trait_reflection.rs
//! Allows reflection with trait objects.
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.register_type::<MyType>()
.add_systems(Startup, setup)
.run();
}
<|fim_suffix... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/examples/reflection/trait_reflection.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/corda-rpc path: /oasis-amqp/src/sasl.rs
use oasis_amqp_macros::amqp;
use serde::{self, Deserialize, Serialize};
use serde_bytes::Bytes;
use crate::Described;
#[amqp]
#[derive(Debug, PartialEq, Serialize)]
pub enum Frame<'a> {
Mechanisms(Mechanisms),
Init(Init<'a>),
Outcome(... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/corda-rpc",
"path": "/oasis-amqp/src/sasl.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Mechanism {
Anonymous,
Plain,
ScramSha1,
}
#[amqp(descriptor("amqp:sasl-outcome:list", 0x0000_0000_0000_0044))]
#[derive(Debug, Deserialize, PartialEq, Serialize)]
pub struct Outcome<'a>... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/corda-rpc",
"path": "/oasis-amqp/src/sasl.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nebocco/MyGiri-backend path: /sql-client/tests/utils/mod.rs
use sql_client::PgPool;
use sqlx::Executor;
use std::fs::File;
use std::io::prelude::*;
<|fim_suffix|>async fn initialize_pool(pool: &PgPool) {
let mut file = File::open(SQL_FILE).unwrap();
let mut sql = String::new();
file... | code_fim | hard | {
"lang": "rust",
"repo": "nebocco/MyGiri-backend",
"path": "/sql-client/tests/utils/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn initialize_pool(pool: &PgPool) {
let mut file = File::open(SQL_FILE).unwrap();
let mut sql = String::new();
file.read_to_string(&mut sql).unwrap();
let mut conn = pool.acquire().await.unwrap();
conn.execute(sql.as_str()).await.unwrap();
}<|fim_prefix|>// repo: nebocco/MyGiri-b... | code_fim | hard | {
"lang": "rust",
"repo": "nebocco/MyGiri-backend",
"path": "/sql-client/tests/utils/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> info!("Settings: {:?}", settings);
let server_join = thread::spawn(move || {
App::start_up(settings_ref);
});
let server_addr = format!("{}:{}", settings.server.host, settings.server.port).parse::<SocketAddr>().unwrap();
let any_addr = "127.0.0.1:0".to_string().parse::<Socket... | code_fim | hard | {
"lang": "rust",
"repo": "cspinetta/jon-listen",
"path": "/examples/send_via_udp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let now = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards");
let filename = format!("writer_test_{}.log", now.subsec_nanos());
let server = ServerConfig { protocol: ProtocolType::UDP, host: "0.0.0.0".to_string(), port: 9999 };
let rotation_policy_config = RotationP... | code_fim | hard | {
"lang": "rust",
"repo": "cspinetta/jon-listen",
"path": "/examples/send_via_udp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cspinetta/jon-listen path: /examples/send_via_udp.rs
#![feature(test)]
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
#[macro_use]
extern crate matches;
extern crate test;
extern crate tokio_core;
#[macro_use]
extern crate tokio_io;
extern crate futures;
extern crate jon_lis... | code_fim | hard | {
"lang": "rust",
"repo": "cspinetta/jon-listen",
"path": "/examples/send_via_udp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn input_files_content_to_digest(context: Context, args: Vec<Value>) -> NodeFuture<Value> {
let file_values = externs::project_multi(&args[0], "dependencies");
let digests: Vec<_> = file_values
.iter()
.map(|file| {
let filename = externs::project_str(&file, "path");
let path: Path... | code_fim | hard | {
"lang": "rust",
"repo": "haominhu1216-houzz/pants",
"path": "/src/rust/engine/src/intrinsics.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let core = context.core;
Box::pin(async move {
let input_digest = lift_digest(&externs::project_ignoring_type(&args[0], "digest"))?;
let prefix = externs::project_str(&args[0], "prefix");
let digest =
store::Snapshot::add_prefix(core.store(), input_digest, PathBuf::from(prefix)).awai... | code_fim | hard | {
"lang": "rust",
"repo": "haominhu1216-houzz/pants",
"path": "/src/rust/engine/src/intrinsics.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haominhu1216-houzz/pants path: /src/rust/engine/src/intrinsics.rs
use crate::context::Context;
use crate::core::{throw, Value};
use crate::externs;
use crate::nodes::MultiPlatformExecuteProcess;
use crate::nodes::{lift_digest, DownloadedFile, NodeFuture, Snapshot};
use crate::tasks::Intrinsic;
u... | code_fim | hard | {
"lang": "rust",
"repo": "haominhu1216-houzz/pants",
"path": "/src/rust/engine/src/intrinsics.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Decodes ABI contract answer from `SliceData` into type values
pub fn decode_response_from_slice(response: SliceData) -> Result<(u32, TOut::Out), Exception> {
let (version, remainder) = u8::read_from(response)
.map_err(|e| Exception::TypeDeserializationError(e))?;
... | code_fim | hard | {
"lang": "rust",
"repo": "PillarDevelopment/TON-SDK",
"path": "/abi/abi_core/src/abi_response.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PillarDevelopment/TON-SDK path: /abi/abi_core/src/abi_response.rs
use std::marker::PhantomData;
use std::io::Cursor;
use tvm::cells_serialization::deserialize_cells_tree;
use tvm::stack::SliceData;
use tvm::error::TvmError as InnerBagOfCellsDeserializationException;
use types::{
ABIOutPara... | code_fim | hard | {
"lang": "rust",
"repo": "PillarDevelopment/TON-SDK",
"path": "/abi/abi_core/src/abi_response.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut actual = s.to_string();
let _ = normalize_newlines(&mut actual);
assert_eq!(
s.replace("\r", "").replace("\r", "\n"),
actual.replace("\r", "").replace("\r", "\n"),
);
}
}<|fim_prefix|>// repo: matklad/normalize-newlines path: /tests/test... | code_fim | hard | {
"lang": "rust",
"repo": "matklad/normalize-newlines",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matklad/normalize-newlines path: /tests/tests.rs
use proptest::prelude::*;
use normalize_newlines::normalize_newlines;
#[test]
fn test_normalize_newlines() {
fn check(before: &str, after: &str, ok: bool) {
<|fim_suffix|> let mut actual = s.to_string();
let _ = normalize_newl... | code_fim | hard | {
"lang": "rust",
"repo": "matklad/normalize-newlines",
"path": "/tests/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>proptest! {
#[test]
fn doesnt_crash(s in "(\r\nabЫ)*") {
let mut actual = s.to_string();
let _ = normalize_newlines(&mut actual);
assert_eq!(
s.replace("\r", "").replace("\r", "\n"),
actual.replace("\r", "").replace("\r", "\n"),
);
}
}<|f... | code_fim | hard | {
"lang": "rust",
"repo": "matklad/normalize-newlines",
"path": "/tests/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn four_equal_bytes() {
let mut uncompressed = Vec::new();
let mut d = LZ78Decompressor::new(&mut uncompressed);
let data = vec![0b0110_0001, 0b1011_0000, 0b1010_0000];
let expected = b"aaaa";
assert_eq!(d.read(&data[..]).unwrap(), 4);
assert... | code_fim | hard | {
"lang": "rust",
"repo": "favilo/kompression",
"path": "/src/lz78/decompress.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut uncompressed = Vec::new();
let mut d = LZ78Decompressor::new(&mut uncompressed);
let data = vec![0b0110_0001, 0b1011_0000, 0b1000_0000];
let expected = b"aaa";
assert_eq!(d.read(&data[..]).unwrap(), 3);
let _ = d.finalize();
assert_eq!(uncomp... | code_fim | hard | {
"lang": "rust",
"repo": "favilo/kompression",
"path": "/src/lz78/decompress.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: favilo/kompression path: /src/lz78/decompress.rs
use std::{collections::HashMap, io::Write};
use bitvec::{field::BitField, order::Msb0, prelude::BitVec};
use crate::{error::Error, lz78::code::Code};
pub struct LZ78Decompressor<W> {
table: HashMap<Code, Vec<u8>>,
writer: W,
// seq... | code_fim | hard | {
"lang": "rust",
"repo": "favilo/kompression",
"path": "/src/lz78/decompress.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1695-Maximum Erasure Value/Two Pointers.rs
use std::collections::HashMap;
impl Solution {
pub fn maximum_unique_subarray(nums: Vec<i32>) -> i32 {
let mut i = 0;
let mut<|fim_suffix|>or_insert(0) += 1;
sum += nums[j];
w... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1695-Maximum Erasure Value/Two Pointers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unwrap() -= 1;
sum -= nums[i];
i += 1;
}
ret = ret.max(sum);
}
ret
}
}<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1695-Maximum Erasure Value/Two Pointers.rs
use std::collections::HashMap;
impl Solution {
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1695-Maximum Erasure Value/Two Pointers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> composite.fields().map(|f| field::map_output_field(ctx, f)).collect()
}<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/schema/src/build/output_types/objects/composite.rs
#![allow(clippy::unnecessary_to_owned)]
use super::*;
use prisma_models::CompositeType;
pub(crate) fn composite_... | code_fim | medium | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/schema/src/build/output_types/objects/composite.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/schema/src/build/output_types/objects/composite.rs
#![allow(clippy::unnecessary_to_owned)]
use super::*;
use prisma_models::CompositeType;
pub(crate) fn composite_object_type(ctx: &'_ QuerySchema, composite: CompositeType) -> ObjectType<'_> {
Objec... | code_fim | medium | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/schema/src/build/output_types/objects/composite.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: COLDTURNIP/raphanus_leetcode path: /rust/src/p738.rs
/*
Problem 738. Monotone Increasing Digits
=======================================
https://leetcode.com/problems/monotone-increasing-digits/
Given a non-negative integer N, find the largest number that is less than or equal to N with
monoton... | code_fim | hard | {
"lang": "rust",
"repo": "COLDTURNIP/raphanus_leetcode",
"path": "/rust/src/p738.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::monotone_increasing_digits(9), 9);
assert_eq!(Solution::monotone_increasing_digits(7), 7);
}
#[bench]
fn bench(b: &mut test::Bencher) {
b.iter(|| Solution::monotone_increasing_digits(1294));
}
}<|fim_prefix|>// repo: COLDTURNIP/raphanus_leetcod... | code_fim | hard | {
"lang": "rust",
"repo": "COLDTURNIP/raphanus_leetcode",
"path": "/rust/src/p738.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let resp_stream = read_json
.map_err(KvsError::from)
.and_then(
move |req| -> Box<dyn Future<Item = Response, Error = KvsError> + Send> {
match req {
Request::Get { key } => Box::new(engine.get(key).map(Response::Get)),
... | code_fim | hard | {
"lang": "rust",
"repo": "XiaoLuoA/my-learn",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XiaoLuoA/my-learn path: /src/server.rs
use crate::common::{Request, Response};
use crate::{KvsEngine, KvsError, Result};
use std::net::SocketAddr;
use tokio::codec::{FramedRead, FramedWrite, LengthDelimitedCodec};
use tokio::net::{TcpListener, TcpStream};
use tokio::prelude::*;
use tokio_serde_j... | code_fim | hard | {
"lang": "rust",
"repo": "XiaoLuoA/my-learn",
"path": "/src/server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn serve<E: KvsEngine>(engine: E, tcp: TcpStream) -> impl Future<Item = (), Error = KvsError> {
let (read_half, write_half) = tcp.split();
let read_json = ReadJson::new(FramedRead::new(read_half, LengthDelimitedCodec::new()));
let resp_stream = read_json
.map_err(KvsError::from)
... | code_fim | hard | {
"lang": "rust",
"repo": "XiaoLuoA/my-learn",
"path": "/src/server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (
ticker_id,
contract,
&contract.combo_legs,
has_delta_neutral_contract,
//&contract.delta_neutral_contract,
generic_tick_list,
snapshot,
regulatory_snapshot,
mkt_data_options
).serialize(s)
}
//1-11-1-383430121-ESTC-OPT-2020... | code_fim | hard | {
"lang": "rust",
"repo": "yangbin/ibapi",
"path": "/src/ib/request.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yangbin/ibapi path: /src/ib/request.rs
use serde::{Deserialize, Serialize, Serializer};
use smart_default::SmartDefault;
use crate::ib::{Contract, TagValue};
/// Outgoing messages. We use serde rename to the right ID + Version.
/// Also see EClient.h / EClient.cpp
#[derive(Debug, Deserialize, ... | code_fim | hard | {
"lang": "rust",
"repo": "yangbin/ibapi",
"path": "/src/ib/request.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p = Point { x: 1, y: 2 };
assert_eq!(1, p.x());
assert_eq!(2, p.y());
let p = Point { x: 1, y: 2.0 };
assert_eq!(1, p.x());
assert_eq!(2.0, p.y());
let p = Point { x: "one", y: "two" };
assert_eq!("one", p.x());
assert_eq!("two", p.y());
}<|fim_prefix|>// repo: vkil... | code_fim | easy | {
"lang": "rust",
"repo": "vkill/books-rs",
"path": "/book/examples/ch10-point.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vkill/books-rs path: /book/examples/ch10-point.rs
//! [Generic Data Types]
//!
//! [generic data types]: https://doc.rust-lang.org/book/ch10-01-syntax.html
use the_book::ch10::Point;
<|fim_suffix|> let p = Point { x: 1, y: 2 };
assert_eq!(1, p.x());
assert_eq!(2, p.y());
let p = ... | code_fim | easy | {
"lang": "rust",
"repo": "vkill/books-rs",
"path": "/book/examples/ch10-point.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Drexen/AdventOfCode path: /2019/day-16.rs
use std::iter;
static BASE_PATTERN: [i32; 4] = [0, 1, 0, -1];
static RAW_INPUT: &str= "5976463579747371805248637671814240834635767681847850359963367005988574819596609110309776901260855064568693299654603047652126452121119203523130379186845687771795748200... | code_fim | hard | {
"lang": "rust",
"repo": "Drexen/AdventOfCode",
"path": "/2019/day-16.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut reversed_input = input.clone();
reversed_input.reverse();
for _ in 0..100 {
reversed_input = calculate_phase_reverse(&reversed_input);
}
println!(
"Part two: {:?}",
reversed_input.iter().rev().take(8).collect::<Vec<_>>()
)
}
fn calculate_phase_rev... | code_fim | hard | {
"lang": "rust",
"repo": "Drexen/AdventOfCode",
"path": "/2019/day-16.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/session/examples/graphical-session/src/graphics_util.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use fidl_fuchsia_ui_gfx::{Quaternion, Vec3};
/... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/session/examples/graphical-session/src/graphics_util.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn quaternion_from_90_degrees_y() {
let expected_quat = Quaternion { x: 0.0, y: SIN_45_DEG, z: 0.0, w: SIN_45_DEG };
let actual_quat =
quaternion_from_axis_angle(Vec3 { x: 0.0, y: 1.0, z: 0.0 }, RADS_FROM_90_DEG);
compare_quaternions(&expected_quat, &act... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/session/examples/graphical-session/src/graphics_util.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: discord/tokio path: /tokio-codec/src/lib.rs
#![doc(html_root_url = "https://docs.rs/tokio-codec/0.2.0-alpha.1")]
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unreachable_pub
)]
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
//! Utilities ... | code_fim | medium | {
"lang": "rust",
"repo": "discord/tokio",
"path": "/tokio-codec/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use crate::bytes_codec::BytesCodec;
pub use crate::decoder::Decoder;
pub use crate::encoder::Encoder;
pub use crate::framed::{Framed, FramedParts};
pub use crate::framed_read::FramedRead;
pub use crate::framed_write::FramedWrite;
pub use crate::length_delimited::{LengthDelimitedCodec, LengthDelimitedC... | code_fim | medium | {
"lang": "rust",
"repo": "discord/tokio",
"path": "/tokio-codec/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>DashboardScreen),
/// Updates the dashboard with the latest data
Tick,
}<|fim_prefix|>// repo: mdzik/hyperqueue path: /crates/hyperqueue/src/dashboard/events.rs
use crate::dashboard::state::DashboardScreen;
use termion::event::Key;
pub enu<|fim_middle|>m DashboardEvent {
/// The event when a... | code_fim | medium | {
"lang": "rust",
"repo": "mdzik/hyperqueue",
"path": "/crates/hyperqueue/src/dashboard/events.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mdzik/hyperqueue path: /crates/hyperqueue/src/dashboard/events.rs
use crate::dashboard::state::DashboardScreen;
use termion::event::Key;
pub enu<|fim_suffix|>DashboardScreen),
/// Updates the dashboard with the latest data
Tick,
}<|fim_middle|>m DashboardEvent {
/// The event when a... | code_fim | medium | {
"lang": "rust",
"repo": "mdzik/hyperqueue",
"path": "/crates/hyperqueue/src/dashboard/events.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main_poly(args: impl Iterator<Item = String>) {
println!("Polynomials. Input: 'from to tries'");
let nums = read_nums(args);
for good_prime in nums[0]..nums[1] {
if is_good_prime(good_prime) {
if let Some(PolynomialEncryption {
good_prime,
... | code_fim | hard | {
"lang": "rust",
"repo": "TurtlePU/ecc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TurtlePU/ecc path: /src/main.rs
use std::env::args;
use itertools::Itertools;
use polynomials::Poly;
use primes::{prime_encryptions, PrimeEncryption};
use rand::{prelude::ThreadRng, thread_rng};
use rayon::{iter::ParallelIterator, ThreadPoolBuilder};
use crate::{
elliptic_curves::{create_c... | code_fim | hard | {
"lang": "rust",
"repo": "TurtlePU/ecc",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> poly.coefs().into_iter().map(|x| x.to_string()).join(" ")
}
fn main_ell(args: impl Iterator<Item = String>) {
println!("Elliptic curves. Input: 'from to deg tries'");
let nums = read_nums(args);
for prime in nums[0]..nums[1] {
if is_prime(prime as u128) {
if let Some(C... | code_fim | hard | {
"lang": "rust",
"repo": "TurtlePU/ecc",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LegNeato/asciinema-rs path: /src/output_formats/asciicast.rs
use super::{LoopAction, Msg, Output};
use failure::Error;
use std::fs::File;
use std::io::Write;
use std::sync::mpsc::{channel, Receiver, Sender};
pub struct AsciicastOutput {
rx: Receiver<Msg>,
tx: Sender<Msg>,
output: Fi... | code_fim | hard | {
"lang": "rust",
"repo": "LegNeato/asciinema-rs",
"path": "/src/output_formats/asciicast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match message {
Msg::Finish => Ok(LoopAction::Stop),
Msg::Header(d) => {
let mut file_copy = self.output.try_clone()?;
let j = serde_json::to_string(&d)? + "\n";
file_copy.write_all(j.as_bytes())?;
Ok(LoopActio... | code_fim | hard | {
"lang": "rust",
"repo": "LegNeato/asciinema-rs",
"path": "/src/output_formats/asciicast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let entry = Entry {
event_type: EventType::Output,
event_data: "Hello world".to_string(),
time: 5.0,
};
let line = first_line_for_message!(AsciicastOutput, Msg::Output(Box::new(entry.clone())));
assert!(line.is_some());
assert_eq!... | code_fim | hard | {
"lang": "rust",
"repo": "LegNeato/asciinema-rs",
"path": "/src/output_formats/asciicast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yoshinari-nomura/bomberhuman path: /src/actors/fire.rs
use crate::actors::*;
use crate::geometry::*;
use crate::*;
/// Fire
pub struct Fire {
actor_id: ActorId,
action: u32,
ttl: i32,
pub pnt: Point,
}
<|fim_suffix|> pub fn draw(&self) {
screen_put_sprite(self.pnt.x... | code_fim | hard | {
"lang": "rust",
"repo": "yoshinari-nomura/bomberhuman",
"path": "/src/actors/fire.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn draw(&self) {
screen_put_sprite(self.pnt.x, self.pnt.y, self.actor_id, self.action)
}
pub fn update(&mut self, _delta: i32) {
// XXX: action is 0-5 for the sake of sprites.png should FIX it.
self.action = (20 - self.ttl as u32) * 15 / 20;
self.ttl -= 1;
... | code_fim | medium | {
"lang": "rust",
"repo": "yoshinari-nomura/bomberhuman",
"path": "/src/actors/fire.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.cache_data.read()?.test(leaf_reader)
}
fn cache(
&self,
leaf_reader: &LeafReaderContext<'_, C>,
query_key: &str,
) -> Result<Option<CachedDocIdSetIterEnum>> {
match self.weight.create_scorer(leaf_reader)? {
Some(mut scorer) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "jobdeng/rucene",
"path": "/src/core/search/cache/query_cache.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jobdeng/rucene path: /src/core/search/cache/query_cache.rs
tring(), query_key.to_string());
query_key.to_string()
};
let key = leaf_reader.reader.core_cache_key();
let new_entry = if self.cache.contains_key(key) {
false
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "jobdeng/rucene",
"path": "/src/core/search/cache/query_cache.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jobdeng/rucene path: /src/core/search/cache/query_cache.rs
sh_map::DefaultHasher;
use std::collections::HashMap;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use core::index::reader::LeafReaderContext;
use core::search... | code_fim | hard | {
"lang": "rust",
"repo": "jobdeng/rucene",
"path": "/src/core/search/cache/query_cache.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adimit/sicp path: /src/tokenisation.rs
use crate::errors::{Position, ReplError, ReplResult};
use std::fmt;
#[derive(Debug, Eq, Clone, Copy, PartialEq)]
pub struct Span {
pub begin: usize,
pub end: usize,
}
impl fmt::Display for Span {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fm... | code_fim | hard | {
"lang": "rust",
"repo": "adimit/sicp",
"path": "/src/tokenisation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if string.len() > 0 {
let start: usize = lastpos - (string.len() - 1);
match string.parse::<i64>() {
Ok(num) => Some(Token::create(start, lastpos, TokenData::Number(num))),
Err(_) => Some(Token::create(start, lastpos, TokenData::Symbol(string))),
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "adimit/sicp",
"path": "/src/tokenisation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_symbol(tape: &mut Tape) -> Option<Token> {
let mut string = String::new();
let mut lastpos = 0;
while let Some((pos, c)) = tape.next_if(|(_, c)| !(c.is_whitespace() || *c == '(' || *c == ')'))
{
string.push(c);
lastpos = pos;
}
if string.len() > 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "adimit/sicp",
"path": "/src/tokenisation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mark-Simulacrum/advent-of-code path: /y2018/src/bin/day12.rs
use aoc_macro::{generator, solution};
aoc_macro::day!();
type Out = (Set, Patterns);
#[generator]
fn generator((input, patterns): (&'static str, &'static str)) -> Out {
let input = input.trim();
let patterns = patterns
... | code_fim | hard | {
"lang": "rust",
"repo": "Mark-Simulacrum/advent-of-code",
"path": "/y2018/src/bin/day12.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn count(&self) -> isize {
self.0.iter().sum::<isize>()
}
pub fn clear(&mut self) {
self.0.clear()
}
}
}
use self::set::Set;
#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
struct Window {
center: isize,
range: u8,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Mark-Simulacrum/advent-of-code",
"path": "/y2018/src/bin/day12.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benbromhead/ioplayground path: /src/protocols/redis1.rs
use anyhow::{anyhow, Result};
use bytes::{Buf, Bytes, BytesMut};
use itertools::Itertools;
use redis_protocol::prelude::*;
use std::collections::HashMap;
use tokio_util::codec::{Decoder, Encoder};
use tracing::{debug, info, trace, warn};
... | code_fim | hard | {
"lang": "rust",
"repo": "benbromhead/ioplayground",
"path": "/src/protocols/redis1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Decoder for RedisCodec {
type Item = Vec<Frame>;
type Error = anyhow::Error;
fn decode(
&mut self,
src: &mut BytesMut,
) -> std::result::Result<Option<Self::Item>, Self::Error> {
self.decode_raw(src)
}
}
impl Encoder<Vec<Frame>> for RedisCodec {
type ... | code_fim | hard | {
"lang": "rust",
"repo": "benbromhead/ioplayground",
"path": "/src/protocols/redis1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arturkow2000/rust-psutil path: /src/sensors/temperature_sensor.rs
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::Temperature;
#[cfg_attr(feature = "serde", serde(crate = "renamed_serde"))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug,... | code_fim | medium | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/sensors/temperature_sensor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns high trip point for sensor if available.
pub fn high(&self) -> Option<&Temperature> {
self.max.as_ref()
}
/// Returns critical trip point for sensor if available.
pub fn critical(&self) -> Option<&Temperature> {
self.crit.as_ref()
}
}<|fim_prefix|>// repo: arturkow2000/rust-psutil ... | code_fim | hard | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/sensors/temperature_sensor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns sensor label.
pub fn label(&self) -> Option<&str> {
self.label.as_deref()
}
/// Returns current temperature reported by sensor.
pub fn current(&self) -> &Temperature {
&self.current
}
/// Returns high trip point for sensor if available.
pub fn high(&self) -> Option<&Temperature> ... | code_fim | medium | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/sensors/temperature_sensor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arielmakestuff/safesec path: /src/storage/mod.rs
// storage.rs
// Copyright (C) 2017 authors and contributors (see AUTHORS file)
//
// This file is released under the MIT License.
// ===========================================================================
// Imports
// ======================... | code_fim | medium | {
"lang": "rust",
"repo": "arielmakestuff/safesec",
"path": "/src/storage/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// ===========================================================================
// Types
// ===========================================================================
#[derive(Debug)]
pub enum KeyFileError {
Key(Vec<u8>),
Other,
}
pub type KeyFileResult<V> = Result<V, KeyFileError>;
// ====... | code_fim | medium | {
"lang": "rust",
"repo": "arielmakestuff/safesec",
"path": "/src/storage/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait KeyFileBuilder {
fn new(name: &str, envpath: Option<&Path>) -> Self;
}
pub trait KeyFileStore {
fn exists(&self, k: &Vec<u8>) -> bool;
fn get(&self, k: &Vec<u8>) -> KeyFileResult<Vec<u8>>;
fn set(&mut self, k: &Vec<u8>, file: &Vec<u8>) -> KeyFileResult<()>;
fn delete(&mut s... | code_fim | hard | {
"lang": "rust",
"repo": "arielmakestuff/safesec",
"path": "/src/storage/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// This element specifies the size of the bounding box enclosing the referenced object.
pub extents: Option<PositiveSize2D>,
}
impl Transform2D {
pub fn from_xml_element(xml_node: &XmlNode) -> Result<Self> {
xml_node
.attributes
.iter()
.try_fold(D... | code_fim | hard | {
"lang": "rust",
"repo": "dam4rus/msoffice-shared-rs",
"path": "/src/drawingml/coordsys.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dam4rus/msoffice-shared-rs path: /src/drawingml/coordsys.rs
use crate::drawingml::simpletypes::{Angle, Coordinate, PositiveCoordinate};
use crate::error::MissingAttributeError;
use crate::xml::{parse_xml_bool, XmlNode};
pub type Result<T> = ::std::result::Result<T, Box<dyn (::std::error::Error)... | code_fim | hard | {
"lang": "rust",
"repo": "dam4rus/msoffice-shared-rs",
"path": "/src/drawingml/coordsys.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iggy-rs/iggy path: /server/src/binary/client_context.rs
use std::fmt::Display;
// This might be extended with more fields in the future e.g. custom name, permissions etc.
#[derive(Debug)]
pub struct ClientContext {
pub client_id: u32,
}
<|fim_suffix|> write!(f, "Client ID: {}", self... | code_fim | medium | {
"lang": "rust",
"repo": "iggy-rs/iggy",
"path": "/server/src/binary/client_context.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "Client ID: {}", self.client_id)
}
}<|fim_prefix|>// repo: iggy-rs/iggy path: /server/src/binary/client_context.rs
use std::fmt::Display;
// This might be extended with more fields in the future e.g. custom name, permissions etc.
#[derive(Debug)]
pub struct ClientContext {
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "iggy-rs/iggy",
"path": "/server/src/binary/client_context.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wuranbo/tantivy path: /src/postings/segment_postings.rs
use compression::{NUM_DOCS_PER_BLOCK, BlockDecoder, VIntDecoder};
use DocId;
use postings::{Postings, FreqHandler, DocSet, HasLen};
use std::num::Wrapping;
use fastfield::DeleteBitSet;
const EMPTY_DATA: [u8; 0] = [0u8; 0];
/// `SegmentPo... | code_fim | hard | {
"lang": "rust",
"repo": "wuranbo/tantivy",
"path": "/src/postings/segment_postings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.block_decoder.output(self.index_within_block())
}
}
impl<'a> HasLen for SegmentPostings<'a> {
fn len(&self) -> usize {
self.len
}
}
impl<'a> Postings for SegmentPostings<'a> {
fn term_freq(&self) -> u32 {
self.freq_handler.freq(self.index_within_block())
... | code_fim | hard | {
"lang": "rust",
"repo": "wuranbo/tantivy",
"path": "/src/postings/segment_postings.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if is_evenly_divisible {
break;
}
}
println!("Smallest number: {}", smallest_num);
}<|fim_prefix|>// repo: nulltone/project-euler path: /problem_005/src/main.rs
fn main() {
let mut smallest_num = 20;
let increment = smallest_num;
let dividers = [20, 19, 18... | code_fim | hard | {
"lang": "rust",
"repo": "nulltone/project-euler",
"path": "/problem_005/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for div in dividers.iter() {
if (smallest_num % *div) != 0 {
smallest_num += increment;
is_evenly_divisible = false;
break;
}
}
if is_evenly_divisible {
break;
}
}
println!("Smalle... | code_fim | medium | {
"lang": "rust",
"repo": "nulltone/project-euler",
"path": "/problem_005/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nulltone/project-euler path: /problem_005/src/main.rs
fn main() {
let mut smallest_num = 20;
let increment = smallest_num;
let dividers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2];
<|fim_suffix|> if is_evenly_divisible {
break;
}... | code_fim | hard | {
"lang": "rust",
"repo": "nulltone/project-euler",
"path": "/problem_005/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HyeonuPark/Nal path: /nalc_parser/src/literal.rs
use super::prelude::*;
use nom::digit;
named!{parse_bool_literal(Src) -> Node<Literal>, node!(alt!(
value!(Literal::Bool(true), word!("true")) |
value!(Literal::Bool(false), word!("false"))
))}
<|fim_suffix|>named!{parse_str_char(Src) ->... | code_fim | hard | {
"lang": "rust",
"repo": "HyeonuPark/Nal",
"path": "/nalc_parser/src/literal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!{pub parse_literal(Src) -> Node<Literal>, alt!(
parse_bool_literal
| parse_num_literal
| parse_str_literal
)}<|fim_prefix|>// repo: HyeonuPark/Nal path: /nalc_parser/src/literal.rs
use super::prelude::*;
use nom::digit;
named!{parse_bool_literal(Src) -> Node<Literal>, node!(alt!(
v... | code_fim | hard | {
"lang": "rust",
"repo": "HyeonuPark/Nal",
"path": "/nalc_parser/src/literal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamransom/barely_os path: /src/time.rs
//! Functions relating to time.
pub const M<|fim_suffix|>S_PER_SEC: u32 = 1_000;
pub const MICROS_PER_SEC: u32 = MILLIS_PER_SEC * MICROS_PER_MILLI;<|fim_middle|>ICROS_PER_MILLI: u32 = 1_000;
pub const MILLI | code_fim | easy | {
"lang": "rust",
"repo": "adamransom/barely_os",
"path": "/src/time.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>S_PER_SEC: u32 = 1_000;
pub const MICROS_PER_SEC: u32 = MILLIS_PER_SEC * MICROS_PER_MILLI;<|fim_prefix|>// repo: adamransom/barely_os path: /src/time.rs
//! Functions relating to time.
pub const M<|fim_middle|>ICROS_PER_MILLI: u32 = 1_000;
pub const MILLI | code_fim | easy | {
"lang": "rust",
"repo": "adamransom/barely_os",
"path": "/src/time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LinAGKar/advent-of-code-2017-rust path: /day7b/src/main.rs
extern crate regex;
use regex::Regex;
use std::collections::HashMap;
use std::collections::HashSet;
use std::io;
use std::io::Read;
#[derive(Debug)]
struct Node {
name: String,
weight: i64,
own_weight: i64,
children: Ve... | code_fim | hard | {
"lang": "rust",
"repo": "LinAGKar/advent-of-code-2017-rust",
"path": "/day7b/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.