text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: gistia/rust-hl7 path: /examples/demo.rs
/*!
A short example demonstrating one way to use this library for HL7 processing.
*/
use rusthl7::{EscapeSequence, Message};
use std::{convert::TryFrom, error::Error};
fn main() -> Result<(), Box<dyn Error>> {
// Normally message would come over the... | code_fim | hard | {
"lang": "rust",
"repo": "gistia/rust-hl7",
"path": "/examples/demo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // If you have the potential for escape sequences in your data you can process those using `EscapeSequence`
let charge_to_practice = message.query("OBR.F23");
assert_eq!(charge_to_practice, r#"Joes Obs \T\ Gynae"#);
let decoder = EscapeSequence::new(message.get_separators());
let char... | code_fim | hard | {
"lang": "rust",
"repo": "gistia/rust-hl7",
"path": "/examples/demo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> NodePointer::from_memory_address(self.to_non_null_u8())
}
}
impl NonNullU8NodePointer for NonNull<u8> {}<|fim_prefix|>// repo: bastion-rs/allocator-suite path: /src/extensions/non_null_u8_node_pointer.rs
use crate::allocators::binary_search_trees::red_black_tree::node_pointer::NodePointer;
u... | code_fim | medium | {
"lang": "rust",
"repo": "bastion-rs/allocator-suite",
"path": "/src/extensions/non_null_u8_node_pointer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bastion-rs/allocator-suite path: /src/extensions/non_null_u8_node_pointer.rs
use crate::allocators::binary_search_trees::red_black_tree::node_pointer::NodePointer;
use crate::extensions::non_null_u8_ext::NonNullU8Ext;
use std::ptr::NonNull;
<|fim_suffix|> NodePointer::from_memory_address... | code_fim | medium | {
"lang": "rust",
"repo": "bastion-rs/allocator-suite",
"path": "/src/extensions/non_null_u8_node_pointer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> chip8.debug_print_registers();
stdout().flush().expect("Failed to flush stdout");
chip8.run_instruction();
}
}<|fim_prefix|>// repo: agsimmons/chip8rs path: /src/main.rs
extern crate minifb;
use minifb::Key;
use std::env;
use std::io::stdout;
use std::io::Write;
use std::pro... | code_fim | hard | {
"lang": "rust",
"repo": "agsimmons/chip8rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agsimmons/chip8rs path: /src/main.rs
extern crate minifb;
use minifb::Key;
use std::env;
use std::io::stdout;
use std::io::Write;
use std::process;
use chip8rs::Config;
mod chip8;
use chip8::Chip8;
fn main() {
let config = Config::new(env::args()).unwrap_or_else(|err| {
eprintln!... | code_fim | medium | {
"lang": "rust",
"repo": "agsimmons/chip8rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let line = "11D0B..11D36 ; 10.0 # [44] MASARAM GONDI LETTER AU..MASARAM GONDI VOWEL SIGN VOCALIC R\n";
let row: Age = line.parse().unwrap();
assert_eq!(row.codepoints, (0x11D0B, 0x11D36));
assert_eq!(row.age, "10.0");
}
}<|fim_prefix|>// repo: BurntSushi/ucd-generate ... | code_fim | hard | {
"lang": "rust",
"repo": "BurntSushi/ucd-generate",
"path": "/ucd-parse/src/age.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let line = "2BD2 ; 10.0 # GROUP MARK\n";
let row: Age = line.parse().unwrap();
assert_eq!(row.codepoints, 0x2BD2);
assert_eq!(row.age, "10.0");
}
#[test]
fn parse_range() {
let line = "11D0B..11D36 ; 10.0 # [44] MASARAM GONDI LETTER AU.... | code_fim | hard | {
"lang": "rust",
"repo": "BurntSushi/ucd-generate",
"path": "/ucd-parse/src/age.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BurntSushi/ucd-generate path: /ucd-parse/src/age.rs
use std::path::Path;
use crate::{
common::{
parse_codepoint_association, CodepointIter, Codepoints, UcdFile,
UcdFileByCodepoint,
},
error::Error,
};
/// A single row in the `DerivedAge.txt` file.
#[derive(Clone, De... | code_fim | medium | {
"lang": "rust",
"repo": "BurntSushi/ucd-generate",
"path": "/ucd-parse/src/age.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/alsa/src/seq.rs
/
/
/
Call
this
function
to
obtain
an
instance
of
Input
to
access
the
functions
event_input
/
/
/
event_input_pending
and
set_input_buffer_size
.
See
the
documentation
of
Input
for
details
.
pub
fn
input
(
&
self
)
-
>
Input
{
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/alsa/src/seq.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>as_data
(
e
:
EventType
)
-
>
bool
{
matches
!
(
e
EventType
:
:
Note
|
EventType
:
:
Noteon
|
EventType
:
:
Noteoff
|
EventType
:
:
Keypress
)
}
fn
set_data
(
&
self
ev
:
&
mut
Event
)
{
let
z
:
&
mut
alsa
:
:
snd_seq_ev_note_t
=
unsafe
{
&
mut
*
(
&
mut
ev
.
0
.
data
as
*
mut
alsa
:
:
snd_seq_event__bin... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/alsa/src/seq.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>(
if
relative
{
alsa
:
:
SND_SEQ_TIME_MODE_REL
}
else
{
alsa
:
:
SND_SEQ_TIME_MODE_ABS
}
)
;
self
.
0
.
queue
=
queue
as
u8
;
let
t
=
unsafe
{
&
mut
self
.
0
.
time
.
tick
}
;
*
t
=
ttime
as
c_uint
;
}
pub
fn
set_direct
(
&
mut
self
)
{
self
.
0
.
queue
=
alsa
:
:
SND_SEQ_QUEUE_DIRECT
}
pub
fn
get_relativ... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/alsa/src/seq.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hoanhsota/protocol-substrate path: /pallets/linkable-tree/src/benchmarking.rs
// This file is part of Webb.
// Copyright (C) 2021 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except... | code_fim | medium | {
"lang": "rust",
"repo": "hoanhsota/protocol-substrate",
"path": "/pallets/linkable-tree/src/benchmarking.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>benchmarks! {
create {
let i in 1..MAX_EDGES;
let d in 1..<T as pallet_mt::Config>::MaxTreeDepth::get() as u32;
}: _(RawOrigin::Root, i, d as u8)
set_maintainer {
let caller: T::AccountId = whitelisted_caller();
let new_maintainer: T::AccountId = account("maintainer", 0, SEED);
Maintainer... | code_fim | medium | {
"lang": "rust",
"repo": "hoanhsota/protocol-substrate",
"path": "/pallets/linkable-tree/src/benchmarking.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> create {
let i in 1..MAX_EDGES;
let d in 1..<T as pallet_mt::Config>::MaxTreeDepth::get() as u32;
}: _(RawOrigin::Root, i, d as u8)
set_maintainer {
let caller: T::AccountId = whitelisted_caller();
let new_maintainer: T::AccountId = account("maintainer", 0, SEED);
Maintainer::<T>::put::<T:... | code_fim | hard | {
"lang": "rust",
"repo": "hoanhsota/protocol-substrate",
"path": "/pallets/linkable-tree/src/benchmarking.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
link,
props,
}
}
fn update(&mut self, msg: Self::Message) -> bool {
match msg {
CheckBoxMessage::OnToggle => {
let value = !self.value();
self.set_value(value);
self.props.ontoggle.e... | code_fim | hard | {
"lang": "rust",
"repo": "cellarpub/yew_form",
"path": "/yew_form/src/checkbox.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cellarpub/yew_form path: /yew_form/src/checkbox.rs
use crate::{Model, Form};
use yew::{Callback, ComponentLink, Component, Html, html, Properties};
pub enum CheckBoxMessage {
OnToggle,
}
#[derive(Properties, Clone)]
pub struct CheckBoxProperties<T: Model> {
pub field_name: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "cellarpub/yew_form",
"path": "/yew_form/src/checkbox.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MMXVII/mmix path: /src/machine/behavior/is/other/puti.rs
use machine::state::State;
use machine::state::sr::R;
pub fn puti(state: &mut St<|fim_suffix|>t allowed"),
_ => x.into(),
};
state.sr[sr] = (z as u64).into()
}<|fim_middle|>ate, x: u8, _y: u8, z: u8) {
// Store result... | code_fim | medium | {
"lang": "rust",
"repo": "MMXVII/mmix",
"path": "/src/machine/behavior/is/other/puti.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>t allowed"),
_ => x.into(),
};
state.sr[sr] = (z as u64).into()
}<|fim_prefix|>// repo: MMXVII/mmix path: /src/machine/behavior/is/other/puti.rs
use machine::state::State;
use machine::state::sr::R;
pub fn puti(state: &mut St<|fim_middle|>ate, x: u8, _y: u8, z: u8) {
// Store result... | code_fim | medium | {
"lang": "rust",
"repo": "MMXVII/mmix",
"path": "/src/machine/behavior/is/other/puti.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfoote/binaryen-rs path: /binaryen-sys/build.rs
extern crate bindgen;
extern crate cmake;
extern crate cc;
use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
fn gen_bindings() {
let bindings = bindgen::Builder::default()
.header("wrapper.h")
// See htt... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/binaryen-rs",
"path": "/binaryen-sys/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cfg = cc::Build::new();
cfg.file("Shim.cpp")
.include("binaryen/src")
.cpp_link_stdlib(None)
.warnings(false)
.cpp(true)
.flag("-std=c++11")
.compile("binaryen_shim");
}
// See https://github.com/alexcrichton/gcc-rs/blob/88ac58e25/src/lib.rs... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/binaryen-rs",
"path": "/binaryen-sys/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukaspustina/luftpost path: /src/check.rs
use measurement::{Measurement, Value};
#[derive(Debug, Deserialize, Serialize)]
pub struct CheckedMeasurement {
pub measurement: Measurement,
pub has_violations: bool,
pub violations: Vec<Value>,
}
pub fn check_measurement(measurement: Meas... | code_fim | medium | {
"lang": "rust",
"repo": "lukaspustina/luftpost",
"path": "/src/check.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn check_measurement_okay() -> () {
let sensor = Sensor {
name: "A Sensor".to_string(),
id: "123456789".to_string(),
ui_uri: "http://localhost".to_string(),
data_uri: "http://localhost".to_string(),
threshold_pm10: Some(10... | code_fim | hard | {
"lang": "rust",
"repo": "lukaspustina/luftpost",
"path": "/src/check.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (next_pc_addr, additional_cycles) = (inst_prop.func)(self, inst_prop, bus);
self.pc = next_pc_addr.unwrap_or_else(|| self.next_pc(inst_prop));
// if let Some(addr) = next_pc_addr {
// self.pc = addr;
// } else {
// self.step_pc_to_next(inst_prop)... | code_fim | hard | {
"lang": "rust",
"repo": "shunichi/nesto",
"path": "/src/cpu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shunichi/nesto path: /src/cpu.rs
pub mod disasm;
mod instructions;
use self::disasm::disasm_one_inst_and_status;
pub use self::instructions::InstProp;
use self::instructions::*;
use crate::bus::Bus;
use crate::utils::{crossing_page_cycle, offset_addr, wrap_add16, wrap_sub8};
struct Flags {
... | code_fim | hard | {
"lang": "rust",
"repo": "shunichi/nesto",
"path": "/src/cpu.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(clippy::unit_arg)]
async fn submit_seal(&self, seal: SealEvent) -> Result<()> {
let srv = self.stratum_cli_srv.clone();
let mut n = Vec::new();
n.write_u32::<LittleEndian>(seal.nonce)?;
let nonce = hex::encode(n);
let mint_extra = seal
.e... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/cmd/miner_client/src/stratum_client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: starcoinorg/starcoin path: /cmd/miner_client/src/stratum_client.rs
use crate::stratum_client_service::{ShareRequest, StratumClientService, SubmitSealRequest};
use crate::{JobClient, SealEvent};
use anyhow::Result;
use async_std::sync::Arc;
use async_trait::async_trait;
use byteorder::{LittleEndi... | code_fim | hard | {
"lang": "rust",
"repo": "starcoinorg/starcoin",
"path": "/cmd/miner_client/src/stratum_client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brooks-builds/bbecs path: /src/components/helpers.rs
#[macro_export]
/// Helper to query for components in the world. We have to give a query variable that will last longer
/// than the macro for this to work.
///
/// ```
/// use bbecs::query;
/// use bbecs::world::{World, ENTITY_ID, WorldMethod... | code_fim | hard | {
"lang": "rust",
"repo": "brooks-builds/bbecs",
"path": "/src/components/helpers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>unwrap();
///
/// assert_eq!(*size.borrow(), 15.0);
/// assert_eq!(*entity_id.borrow(), 0);
/// }
/// ```
macro_rules! query {
($world:expr, $query:expr, $($name:expr),*) => {{
$query = $world.query(vec![$($name,)*]).unwrap();
(
$($query.get($name).unwrap(),)*
... | code_fim | hard | {
"lang": "rust",
"repo": "brooks-builds/bbecs",
"path": "/src/components/helpers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> model child_a {
id String @id
name String?
parent parent[] @relation("child")
}
model child_b {
id String @id
name String?
parent parent[] @relation("child")
}
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/relations/rel_names.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: balroggg/leetcode_rust path: /src/easy/p1672_richest_customer_wealth.rs
pub fn maximum_wealth(accounts: Vec<Vec<i32>>) -> i32 {
accounts.iter().map(|x| x.iter().sum()).max().unwrap()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test1() {
<|fim_suffix|> // Input: a... | code_fim | hard | {
"lang": "rust",
"repo": "balroggg/leetcode_rust",
"path": "/src/easy/p1672_richest_customer_wealth.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test1() {
// Input: accounts = [[1,2,3],[3,2,1]]
// Output: 6
assert_eq!(
maximum_wealth([[1, 2, 3].to_vec(), [3, 2, 1].to_vec()].to_vec()),
6
);
// Input: accounts = [[1,5],[7,3],[3,5]]
// Output: 10
asser... | code_fim | medium | {
"lang": "rust",
"repo": "balroggg/leetcode_rust",
"path": "/src/easy/p1672_richest_customer_wealth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Input: accounts = [[1,2,3],[3,2,1]]
// Output: 6
assert_eq!(
maximum_wealth([[1, 2, 3].to_vec(), [3, 2, 1].to_vec()].to_vec()),
6
);
// Input: accounts = [[1,5],[7,3],[3,5]]
// Output: 10
assert_eq!(
maximum_we... | code_fim | medium | {
"lang": "rust",
"repo": "balroggg/leetcode_rust",
"path": "/src/easy/p1672_richest_customer_wealth.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(::std::mem::size_of::<B_Segment>() , 8usize);
assert_eq!(::std::mem::align_of::<B_Segment>() , 4usize);
}
impl Clone for B_Segment {
fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_B() {
assert_eq!(::std::mem::size_of::<B>() , 4usize);
assert_eq!(::std::me... | code_fim | hard | {
"lang": "rust",
"repo": "mgjc/rust-bindgen",
"path": "/tests/expectations/class_with_inner_struct.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgjc/rust-bindgen path: /tests/expectations/class_with_inner_struct.rs
/* automatically generated by rust-bindgen */
#![allow(non_snake_case)]
#[derive(Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
#[inline]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "mgjc/rust-bindgen",
"path": "/tests/expectations/class_with_inner_struct.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43 {
pub mStepSyntax: StepSyntax,
pub mSteps: ::std::os::raw::c_uint,
}
#[test]
fn bindgen_test_layout_C__bindgen_ty_bindgen_id_31__bindgen_ty_bindgen_id_43() {
assert_eq!(::std::mem::size_of::<C_... | code_fim | hard | {
"lang": "rust",
"repo": "mgjc/rust-bindgen",
"path": "/tests/expectations/class_with_inner_struct.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: revsic/AlphaZero-Connect6 path: /Connect6/libconnect6/src/policy/alphazero_policy/augment_tests.rs
use super::*;
use rand;
#[test]
fn test_rotate_left() {
let mut board = [[Player::None; BOARD_SIZE]; BOARD_SIZE];
board[0][0] = Player::Black;
board[0][1] = Player::Black;
board[0]... | code_fim | hard | {
"lang": "rust",
"repo": "revsic/AlphaZero-Connect6",
"path": "/Connect6/libconnect6/src/policy/alphazero_policy/augment_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_sum_board() {
let max = BOARD_SIZE * BOARD_SIZE;
let mut board1 = [[0; BOARD_SIZE]; BOARD_SIZE];
let mut board2 = [[0; BOARD_SIZE]; BOARD_SIZE];
for i in 0..BOARD_SIZE {
for j in 0..BOARD_SIZE {
board1[i][j] = i * BOARD_SIZE + j;
board2[i][j]... | code_fim | hard | {
"lang": "rust",
"repo": "revsic/AlphaZero-Connect6",
"path": "/Connect6/libconnect6/src/policy/alphazero_policy/augment_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> quote!(
#parsers
)
}
}
impl Transpile<TokenStream> for ASTParsecRule {
fn transpile(&self) -> TokenStream {
let Self {
name,
input,
returns,
body,
} = self;
let name = syn::Ident::new(name.as_str(... | code_fim | hard | {
"lang": "rust",
"repo": "d-plaindoux/celma",
"path": "/lang/src/meta/transpiler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (None, quote!(#lt.or(#rt)))
}
PNot(p) => {
let (_, pt) = p.transpile_body();
(None, quote!(#pt.not()))
}
PTry(p) => {
let (_, pt) = p.transpile_body();
(None, quote!(a_try(#pt)))... | code_fim | hard | {
"lang": "rust",
"repo": "d-plaindoux/celma",
"path": "/lang/src/meta/transpiler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: d-plaindoux/celma path: /lang/src/meta/transpiler.rs
/*
Copyright 2019-2023 Didier Plaindoux
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.ap... | code_fim | hard | {
"lang": "rust",
"repo": "d-plaindoux/celma",
"path": "/lang/src/meta/transpiler.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn fail_tap_kdf() {
let result = LegacyKdf::new(6).derive(&b"x"[..], 10000);
assert!(result.is_err());
}
#[test]
fn clearbox_ntor1_kdf() {
// Calculate Ntor1Kdf, and make sure we get the same result by
// following the calculation in the spec.
let input = b"another example key seed... | code_fim | hard | {
"lang": "rust",
"repo": "bitcoinmw/rust-tor",
"path": "/tor-proto/src/crypto/ll/kdf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t_key = b"ntor-curve25519-sha256-1:key_extract";
let m_expand = b"ntor-curve25519-sha256-1:key_expand";
Ntor1Kdf::new(&t_key[..], &m_expand[..])
.derive(b, 100)
.unwrap()
}
let expect = hex!(
"5521492a85139a8d9107a2d5c0d9c91610d0f95989975ebee6
c02a4f8d622a6cfdf9b7... | code_fim | hard | {
"lang": "rust",
"repo": "bitcoinmw/rust-tor",
"path": "/tor-proto/src/crypto/ll/kdf.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bitcoinmw/rust-tor path: /tor-proto/src/crypto/ll/kdf.rs
//! Key derivation functions
//!
//! Tor has three relevant key derivation functions that we use for
//! deriving keys used for relay encryption.
//!
//! The *KDF-TOR* KDF (implemented by `LegacyKdf`) is used with the old
//! TAP handshake... | code_fim | hard | {
"lang": "rust",
"repo": "bitcoinmw/rust-tor",
"path": "/tor-proto/src/crypto/ll/kdf.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qwfy/dge path: /dge-example/src/behaviour/mod.rs
pub mod accept_failure;
pub mod double;
pub mod square;
pub mod error;
pub mod multiply;
pub mod data;
pub mod rest_call;
<|fim_suffix|> fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
... | code_fim | medium | {
"lang": "rust",
"repo": "qwfy/dge",
"path": "/dge-example/src/behaviour/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn setup_logger() {
use fern;
use chrono;
fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{} [{}] [{}] {}",
chrono::Local::now().format("[%Y-%m-%d] [%H:%M:%S]"),
record.target(),
... | code_fim | medium | {
"lang": "rust",
"repo": "qwfy/dge",
"path": "/dge-example/src/behaviour/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alexey-Ivanensky/Rainicorn path: /src/parse_describe.rs
// Copyright 2015 Bruno Medeiros
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.... | code_fim | hard | {
"lang": "rust",
"repo": "Alexey-Ivanensky/Rainicorn",
"path": "/src/parse_describe.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn outputString_Level(lvl : &Severity, writer : &mut TokenWriter) -> Void {
try!(writer.writeRawToken(lvl.to_string()));
Ok(())
}
pub fn outputString_SourceRange(sr : &SourceRange, tw : &mut TokenWriter) -> Void {
try!(tw.writeRaw("{ "));
{
let mut out = tw.getCharOut();
try!(... | code_fim | hard | {
"lang": "rust",
"repo": "Alexey-Ivanensky/Rainicorn",
"path": "/src/parse_describe.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn emsa_pss_openssl() {
let sig = vec![
0x95u8, 0x59, 0x6f, 0xd3, 0x10, 0xa2, 0xe7, 0xa2, 0x92, 0x9d,
0x4a, 0x07, 0x2e, 0x2b, 0x27, 0xcc, 0x06, 0xc2, 0x87, 0x2c,
0x52, 0xf0, 0x4a, 0xcc, 0x05, 0x94, 0xf2, 0xc3, 0x2e, 0x20,
0xd7, 0x3e, 0x66, 0x62, 0xb5, 0x95, 0x2b... | code_fim | hard | {
"lang": "rust",
"repo": "mengsuenyan/rcrypto",
"path": "/src/rsa/pss_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mengsuenyan/rcrypto path: /src/rsa/pss_test.rs
use std::str::FromStr;
use crate::rsa::{PrivateKey, PSS, KeyPair, SignatureContent};
use crate::{sha, Signature};
use rmath::bigint::BigInt;
use rmath::rand::{DefaultSeed, CryptoRand};
fn emsa_get_private_key() -> PrivateKey {
let n = BigInt::f... | code_fim | hard | {
"lang": "rust",
"repo": "mengsuenyan/rcrypto",
"path": "/src/rsa/pss_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(em, expected);
emsa.emsa_pss_verify(em.as_slice(), msg.as_slice(), 1023).unwrap();
}
#[test]
fn emsa_pss_openssl() {
let sig = vec![
0x95u8, 0x59, 0x6f, 0xd3, 0x10, 0xa2, 0xe7, 0xa2, 0x92, 0x9d,
0x4a, 0x07, 0x2e, 0x2b, 0x27, 0xcc, 0x06, 0xc2, 0x87, 0x2c,
0x5... | code_fim | hard | {
"lang": "rust",
"repo": "mengsuenyan/rcrypto",
"path": "/src/rsa/pss_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[lang = "panic_fmt"]
#[linkage = "weak"]
#[no_mangle]
pub extern "C" fn rust_begin_unwind(_msg: core::fmt::Arguments,
_file: &'static str,
_line: u32,
_col: u32) -> ! {
let mut s = String::new();
let _ = s... | code_fim | hard | {
"lang": "rust",
"repo": "jeizsm/relibc",
"path": "/src/todo/oldlib/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>libc_fn!(unsafe initialize_standard_library() {
let mut buf = file_read_all("env:").unwrap();
let size = buf.len();
buf.push(0);
let mut vars = Vec::new();
vars.push(&mut buf[0] as *mut u8 as *mut c_char);
for i in 0..size {
if buf[i] == b'\n' {
if i != size -... | code_fim | hard | {
"lang": "rust",
"repo": "jeizsm/relibc",
"path": "/src/todo/oldlib/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeizsm/relibc path: /src/todo/oldlib/lib.rs
#![no_std]
#![feature(
alloc,
allocator_api,
alloc_system,
compiler_builtins_lib,
const_fn,
const_ptr_null,
core_intrinsics,
global_allocator,
lang_items,
linkage,
const_size_of,
const_cell_new,
)]
#[mac... | code_fim | hard | {
"lang": "rust",
"repo": "jeizsm/relibc",
"path": "/src/todo/oldlib/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// GET /logsのハンドラ
pub fn handle_get_logs(
_server: State<Server>,
range: Query<api::logs::get::Query>,
) -> Result<HttpResponse, Error> {
debug!("{:?}", range);
// CSVはバイナリで返す
let csv: Vec<u8> = vec![];
Ok(HttpResponse::Ok()
.header("Content-Type", "text/csv")
.bo... | code_fim | hard | {
"lang": "rust",
"repo": "TakeZNt/log-manager",
"path": "/server/src/handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TakeZNt/log-manager path: /server/src/handler.rs
use actix_web::{HttpResponse, Json, Query, State};
use failure::Error;
use log::debug;
use crate::Server;
/// POST /csvのハンドラ
pub fn handle_post_csv(_server: State<Server>) -> Result<HttpResponse, Error> {
// POSTされたCSVデータは現時点では無視する
<|fim_su... | code_fim | hard | {
"lang": "rust",
"repo": "TakeZNt/log-manager",
"path": "/server/src/handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrxiaozhuox/dorea path: /examples/hello-world.rs
/// 在你运行这个 Demo 之前,请确保 Dorea 服务已经正常启动!
use dorea::{client::DoreaClient, value::DataValue};
<|fim_suffix|> println!("foo: {:?}.", db.get("foo").await.unwrap_or(DataValue::None));
Ok(())
}<|fim_middle|>#[tokio::main]
async fn main() -> anyh... | code_fim | hard | {
"lang": "rust",
"repo": "mrxiaozhuox/dorea",
"path": "/examples/hello-world.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fileglass/fg-translate path: /src/publish/entry.rs
use crate::utils::shared::readCli;
use crate::utils::terminal;
use crate::utils::reader::readPath;
use crate::utils::validator::isCodeValid;
use crate::publish::fromname::getLocaleFromName;
use crate::publish::request::uploadFile;
use crate::uti... | code_fim | hard | {
"lang": "rust",
"repo": "fileglass/fg-translate",
"path": "/src/publish/entry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn publishLocale() {
let mut path = String::new();
terminal::cyan("Please input the path to your translation file.");
readCli(&mut path);
path = path.trim().to_string();
if !isPathAndTsFile(&path) {
terminal::red(&format!("{} is not a TypeScript file!", path));
retu... | code_fim | hard | {
"lang": "rust",
"repo": "fileglass/fg-translate",
"path": "/src/publish/entry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if file.contains("''") {
terminal::yellow("WARNING! Your file contains empty entries.")
}
terminal::cyan(&format!("Locale code: {} (if you don't see the correct shorthand code here, then your file is not named correctly).", name));
upload(&path);
}<|fim_prefix|>// repo: fileglass/... | code_fim | hard | {
"lang": "rust",
"repo": "fileglass/fg-translate",
"path": "/src/publish/entry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mod opcode;
pub mod register;
mod opcodes;<|fim_prefix|>// repo: dpchamps/WASMBoi path: /src/spec/mod.rs
pub mod cartridge_header;
pub mod clock;
pub mod cpu;
pub mod gameboy;
pub mod jump_co<|fim_middle|>ndition;
pub mod mmu;
pub mod mnemonic;
pub | code_fim | easy | {
"lang": "rust",
"repo": "dpchamps/WASMBoi",
"path": "/src/spec/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dpchamps/WASMBoi path: /src/spec/mod.rs
pub mod cartridge_header;
pub mod clock;
pu<|fim_suffix|> mod opcode;
pub mod register;
mod opcodes;<|fim_middle|>b mod cpu;
pub mod gameboy;
pub mod jump_condition;
pub mod mmu;
pub mod mnemonic;
pub | code_fim | medium | {
"lang": "rust",
"repo": "dpchamps/WASMBoi",
"path": "/src/spec/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ndition;
pub mod mmu;
pub mod mnemonic;
pub mod opcode;
pub mod register;
mod opcodes;<|fim_prefix|>// repo: dpchamps/WASMBoi path: /src/spec/mod.rs
pub mod cartridge_header;
pub mod clock;
pu<|fim_middle|>b mod cpu;
pub mod gameboy;
pub mod jump_co | code_fim | easy | {
"lang": "rust",
"repo": "dpchamps/WASMBoi",
"path": "/src/spec/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hhandika/yap path: /src/qc/mod.rs
mod parser;
mod runner;
mod tag;
use std::path::{Path, PathBuf};
use crate::qc::parser::RawSeq;
pub fn dry_run(input: &Path, is_id: bool, is_rename: bool) {
let reads: Vec<RawSeq> = parser::parse_input(input, is_id, is_rename);
println!();
reads.i... | code_fim | medium | {
"lang": "rust",
"repo": "hhandika/yap",
"path": "/src/qc/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!();
});
}
pub fn process_input(
input: &Path,
is_id: bool,
is_rename: bool,
params: &Option<String>,
outdir: &Option<PathBuf>,
) {
let reads: Vec<RawSeq> = parser::parse_input(input, is_id, is_rename);
runner::clean_reads(&reads, params, outdir);
}<|fim_pre... | code_fim | medium | {
"lang": "rust",
"repo": "hhandika/yap",
"path": "/src/qc/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theseusyang/swim-kernel path: /sys/c-sys/src/lib/apple/errno.rs
use crate::int;
// ISO/IEC 9899
// 7.5 Errors
pub const EPERM: int = 1;
pub const ENOENT: int = 2;
pub const ESRCH: int = 3;
pub const EINTR: int = 4;
pub const EIO: int = 5;
pub const ENXIO: int = 6;
pub const E2BIG: int = 7;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "theseusyang/swim-kernel",
"path": "/sys/c-sys/src/lib/apple/errno.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>nt = 80;
pub const ENEEDAUTH: int = 81;
pub const EPWROFF: int = 82;
pub const EDEVERR: int = 83;
pub const EOVERFLOW: int = 84;
pub const EBADEXEC: int = 85;
pub const EBADARCH: int = 86;
pub const ESHLIBVERS: int = 87;
pub const EBADMACHO: int = 88;
pub const ECANCELED: int = 89;
pub const EIDRM: int = ... | code_fim | hard | {
"lang": "rust",
"repo": "theseusyang/swim-kernel",
"path": "/sys/c-sys/src/lib/apple/errno.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn run_buf_read() -> Result<(), std::io::Error> {
let ws = WebsocketIO::new("localhost:8000").await?;
let (mut reader, mut writer) = ws.split();
writer.write_all(&[0, 1, 2, 3]).await?;
writer.write_all(&[42, 34]).await?;
writer.write_all(&[0, 0, 1, 2]).await?;
writer.flush()... | code_fim | hard | {
"lang": "rust",
"repo": "jakobhellermann/websocket-async-io",
"path": "/examples/read_write.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> Result<(), JsValue> {
console_error_panic_hook::set_once();
wasm_bindgen_futures::spawn_local(async move {
console_log!("AsyncRead:");
run().await.unwrap();
console_log!("AsyncBufRead:");
run_buf_read().await.unwrap();
});
Ok(())
}
async fn run... | code_fim | medium | {
"lang": "rust",
"repo": "jakobhellermann/websocket-async-io",
"path": "/examples/read_write.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakobhellermann/websocket-async-io path: /examples/read_write.rs
use futures_util::io::AsyncBufReadExt;
use futures_util::io::AsyncWriteExt;
use futures_util::AsyncReadExt;
use wasm_bindgen::prelude::*;
use websocket_async_io::WebsocketIO;
macro_rules! console_log {
($($t:tt)*) => (log(&for... | code_fim | hard | {
"lang": "rust",
"repo": "jakobhellermann/websocket-async-io",
"path": "/examples/read_write.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libp2p/rust-libp2p path: /swarm/src/stream.rs
use futures::{AsyncRead, AsyncWrite};
use libp2p_core::muxing::SubstreamBox;
use libp2p_core::Negotiated;
use std::io::{IoSlice, IoSliceMut};
use std::pin::Pin;
use std::task::{Context, Poll};
#[derive(Debug)]
pub struct Stream(Negotiated<SubstreamB... | code_fim | hard | {
"lang": "rust",
"repo": "libp2p/rust-libp2p",
"path": "/swarm/src/stream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<std::io::Result<usize>> {
Pin::new(&mut self.get_mut().0).poll_write(cx, buf)
}
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
... | code_fim | medium | {
"lang": "rust",
"repo": "libp2p/rust-libp2p",
"path": "/swarm/src/stream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osvim/algorithm path: /divide_and_conquer/lottery/src/main.rs
use std::io;
use std::process;
use std::cmp::Ordering;
fn main() {
let (segments_number, points_number) = read_segments_points_number();
let mut values: Vec<Value> = Vec::with_capacity(2 * segments_number + points_number);
... | code_fim | hard | {
"lang": "rust",
"repo": "osvim/algorithm",
"path": "/divide_and_conquer/lottery/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("must be provided 2 values");
process::exit(1)
}
fn read_segments(values: &mut Vec<Value>, number: usize) {
let mut input = String::new();
for _ in 0..number {
io::stdin()
.read_line(&mut input)
.expect("can't read number");
let mut slice... | code_fim | hard | {
"lang": "rust",
"repo": "osvim/algorithm",
"path": "/divide_and_conquer/lottery/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_points(values: &mut Vec<Value>, number: usize) {
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("can't read number");
let mut i: usize = 0;
for val in input.trim().split_whitespace() {
let value: isize = val.parse().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "osvim/algorithm",
"path": "/divide_and_conquer/lottery/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value: u32 = match count_of_bytes {
1 => {
let value = cursor.read_u8()?;
if value < 128 {
return Err(ParseError::BadLengthEncoding(
pos_after,
count_of_bytes,
value as u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "ptyspawn/ssp21-rs-core",
"path": "/src/length.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ptyspawn/ssp21-rs-core path: /src/length.rs
use crate::cursor::Cursor;
use crate::error::ParseError;
const TOP_BIT: u8 = 0b1000_0000;
const BOTTOM_BITS: u8 = !TOP_BIT;
pub fn read(cursor: &mut Cursor) -> Result<u32, ParseError> {
let pos_before = cursor.pos();
let first = cursor.read_u... | code_fim | hard | {
"lang": "rust",
"repo": "ptyspawn/ssp21-rs-core",
"path": "/src/length.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn value(&self) -> NumType {
if self.valid() {
self.ival
} else {
panic!("invalid key");
}
}
}<|fim_prefix|>// repo: nicholasbishop/flexmesh path: /src/key.rs
use std::marker::PhantomData;
pub type NumType = u32;
#[derive(Clone, Copy, Debug, E... | code_fim | medium | {
"lang": "rust",
"repo": "nicholasbishop/flexmesh",
"path": "/src/key.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn valid(&self) -> bool {
self.ival == 0xffffffff
}
pub fn value(&self) -> NumType {
if self.valid() {
self.ival
} else {
panic!("invalid key");
}
}
}<|fim_prefix|>// repo: nicholasbishop/flexmesh path: /src/key.rs
use std::mark... | code_fim | medium | {
"lang": "rust",
"repo": "nicholasbishop/flexmesh",
"path": "/src/key.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicholasbishop/flexmesh path: /src/key.rs
use std::marker::PhantomData;
pub type NumType = u32;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Key<T> {
ival: NumType,
phantom: PhantomData<T>
}
impl<T> Key<T> {
pub fn invalid() -> Key<T> {
Key { ival: 0xfffff... | code_fim | medium | {
"lang": "rust",
"repo": "nicholasbishop/flexmesh",
"path": "/src/key.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<C: Curve> Mul<BigInt> for Point<C> {
type Output = Point<C>;
fn mul(self, mut other: BigInt) -> Point<C> {
assert!(other >= BigInt::zero());
if other == BigInt::zero() {
Self::infinity()
} else {
let mut ret = self.clone();
other -... | code_fim | hard | {
"lang": "rust",
"repo": "sorpaas/ec-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn b() -> BigInt;
}
#[cfg(test)]
mod tests {
use super::*;
use num_traits::Num;
#[derive(Clone, Eq, PartialEq, Debug)]
/// Testing curve defined by y^2 = x^3 + 1x + 7
struct TestCurve;
impl Curve for TestCurve {
fn p() -> BigInt { BigInt::from(13u32) }
fn a()... | code_fim | hard | {
"lang": "rust",
"repo": "sorpaas/ec-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sorpaas/ec-rs path: /src/lib.rs
mod utils;
use num_bigint::BigInt;
use num_traits::{Zero, One};
use num_integer::Integer;
use core::ops::{Add, Mul};
use core::marker::PhantomData;
use core::fmt::Debug;
/// A point value.
#[derive(Clone, Eq, PartialEq, Debug)]
pub enum PointValue {
Infinit... | code_fim | hard | {
"lang": "rust",
"repo": "sorpaas/ec-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(format!("DROP VIEW {}", self.view.sql()))
}
fn object_name(&self) -> Option<String> {
Some(self.view.sql())
}
}<|fim_prefix|>// repo: isgasho/pg-schema-diff path: /src/nodes/view_stmt.rs
use crate::schema_set::{Diff, Len, Sql, SqlList};
use postgres_parser::nodes::ViewSt... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/pg-schema-diff",
"path": "/src/nodes/view_stmt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/pg-schema-diff path: /src/nodes/view_stmt.rs
use crate::schema_set::{Diff, Len, Sql, SqlList};
use postgres_parser::nodes::ViewStmt;
use postgres_parser::Node;
impl Sql for ViewStmt {
fn sql(&self) -> String {
<|fim_suffix|> Some(format!("DROP VIEW {}", self.view.sql()))
... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/pg-schema-diff",
"path": "/src/nodes/view_stmt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let keyword_cbb_store_root = "-cbb-store-root";
let keyword_parent_notincludes = "-parent-notincludes";
let mut cmdRegister = CCmd::new();
let root = cmdRegister.register_with_desc("-root", ".", "cmake search root");
let libRoot = cmdRegister.register_with_desc("-lib-root", ".", "lib s... | code_fim | medium | {
"lang": "rust",
"repo": "MwlLj/rust-tools",
"path": "/cmakelists_manager/cmake_depencies/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !cmdRegister.has(keyword_cbb_store_root) {
*cbbStoreRoot.borrow_mut() = libRoot.borrow().to_string();
}
let root = root.borrow();
let libRoot = libRoot.borrow();
let cbbStoreRoot = cbbStoreRoot.borrow();
let parentPathIsnotIncluded = parentPathIsnotIncluded.borrow();
... | code_fim | hard | {
"lang": "rust",
"repo": "MwlLj/rust-tools",
"path": "/cmakelists_manager/cmake_depencies/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MwlLj/rust-tools path: /cmakelists_manager/cmake_depencies/src/main.rs
use cmake_depencies::replace::{CReplace, keyword_cmake_file};
use cmake_depencies::structs;
use rust_parse::cmd::CCmd;
use path::walk;
fn start(root: &str, libRoot: &str, cbbStoreRoot: &str, searchFilter: &structs::param::CS... | code_fim | hard | {
"lang": "rust",
"repo": "MwlLj/rust-tools",
"path": "/cmakelists_manager/cmake_depencies/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32h7/src/stm32h753/sai4/ch/frcr.rs
#[doc = "Reader of register FRCR"]
pub type R = crate::R<u32, super::FRCR>;
#[doc = "Writer for register FRCR"]
pub type W = crate::W<u32, super::FRCR>;
#[doc = "Register FRCR `reset()`'s with value 0x07"]
impl crate::... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h753/sai4/ch/frcr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `FSOFF`"]
pub type FSOFF_R = crate::R<bool, FSOFF_A>;
impl FSOFF_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> FSOFF_A {
match self.bits {
false => FSOFF_A::ONFIRST,
... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h753/sai4/ch/frcr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dwarkeshsp/voldemorts-soul path: /src/xor_tree.rs
use crate::xor;
pub struct Tree {
pub nodes: Vec<Node>,
}
#[derive(Debug, Clone)]
pub struct Node {
pub xor: Vec<u8>,
}
<|fim_suffix|> let mut cursor = 0;
let mut len = nodes.len();
// keep going until cursor reaches root (l... | code_fim | hard | {
"lang": "rust",
"repo": "dwarkeshsp/voldemorts-soul",
"path": "/src/xor_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cursor = 0;
let mut len = nodes.len();
// keep going until cursor reaches root (last) node
while cursor < len - 1 {
for index in cursor..len {
// xoring the even nodes with the node after
if index % 2 == 0 {
if index + 1 < len {
... | code_fim | hard | {
"lang": "rust",
"repo": "dwarkeshsp/voldemorts-soul",
"path": "/src/xor_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Techno-coder/lexica path: /src/declaration/path.rs
use std::fmt;
use std::sync::Arc;
#[derive(Clone, Hash, Eq, PartialEq)]
pub struct ModulePath {
pub parent: Option<Arc<ModulePath>>,
pub identifier: Arc<str>,
}
impl ModulePath {
const UNRESOLVED: &'static str = "<?>";
pub fn new(parent: ... | code_fim | hard | {
"lang": "rust",
"repo": "Techno-coder/lexica",
"path": "/src/declaration/path.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{}", self)
}
}
#[derive(Clone, Hash, Eq, PartialEq)]
pub struct FunctionPath(pub DeclarationPath);
impl FunctionPath {
pub fn method(structure: StructurePath, identifier: Arc<str>) -> Self {
let StructurePath(module_path) = structure;
let module_path = module_path.module_path.push(mod... | code_fim | hard | {
"lang": "rust",
"repo": "Techno-coder/lexica",
"path": "/src/declaration/path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aQaTL/advent_of_code_2019 path: /day_2/src/main.rs
fn main() {
let input = std::fs::read_to_string("day_2/input.txt")
.unwrap()
.split(",")
.map(|e| e.parse::<i64>().unwrap())
.collect::<Vec<_>>();
println!("Part 1: {}", solve(input.clone(), 12, 2));
'loop_: for i in 0..=99 {
for ... | code_fim | medium | {
"lang": "rust",
"repo": "aQaTL/advent_of_code_2019",
"path": "/day_2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in (0..).step_by(4) {
let (input_1, input_2, output) = (
input[i + 1] as usize,
input[i + 2] as usize,
input[i + 3] as usize,
);
match input[i] {
1 => input[output] = input[input_1] + input[input_2],
2 => input[output] = input[input_1] * input[input_2],
_ => break,
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "aQaTL/advent_of_code_2019",
"path": "/day_2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JetonNetwork/JtonConnectFour path: /pallets/connectfour/src/connectfour.rs
// use rand::Rng;
pub struct Logic {
}
impl Logic {
pub fn full(board: [[u8; 6]; 7]) -> bool {
let y_pos = board[0].len() - 1;
for x_pos in 0..board.len() {
if board[x_pos][y_pos] == 0 {... | code_fim | hard | {
"lang": "rust",
"repo": "JetonNetwork/JtonConnectFour",
"path": "/pallets/connectfour/src/connectfour.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // pub fn print_board(board: [[u8; 6]; 7]) {
// println!(" c0 c1 c2 c3 c4 c5 c6 ");
// println!(" + - + - + - + - + - + - + - +");
// for y in 0..board[0].len() {
// print!("r{:?}|", y);
// for x in 0..board.len() {
// match boa... | code_fim | hard | {
"lang": "rust",
"repo": "JetonNetwork/JtonConnectFour",
"path": "/pallets/connectfour/src/connectfour.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akaswenwilk/advent_of_code_2020 path: /src/day_four.rs
use reqwest::header::COOKIE;
use regex::Regex;
const PUZZLE_INPUT_URL: &str = "https://adventofcode.com/2020/day/4/input";
pub async fn solve() -> Result<(), reqwest::Error> {
let input = puzzle_input().await.unwrap();
println!("so... | code_fim | hard | {
"lang": "rust",
"repo": "akaswenwilk/advent_of_code_2020",
"path": "/src/day_four.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_works() {
let input: Vec<String> = vec![
String::from("ecl:gry pid:860033327 eyr:2020 hcl:#fffffd"),
String::from("byr:1937 iyr:2017 cid:147 hgt:183cm"),
String::from(""),
String::from("iyr:2013 ecl:amb cid:350 eyr:2023 pid:0280... | code_fim | hard | {
"lang": "rust",
"repo": "akaswenwilk/advent_of_code_2020",
"path": "/src/day_four.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.