text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: mucompilers/project path: /pa3/tests-p2/13-funcall.rs
struct Some { a : [i32; 3], b : bool }
fn foo(x : i32, y : i32, z : i32) -> i32 {
let x = 5;
return x + y + z;
}
fn bar(x : [i32;3], y : Some) -> i32 {
return x[1] + y.a[1];
}
fn baz() -> [i32;3] { [1, 2, 3] }
fn cats() ... | code_fim | medium | {
"lang": "rust",
"repo": "mucompilers/project",
"path": "/pa3/tests-p2/13-funcall.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wissemriahi/nym path: /sfw-provider/src/provider/presence.rs
use crate::built_info;
use crate::provider::ClientLedger;
use directory_client::presence::providers::MixProviderPresence;
use directory_client::requests::presence_providers_post::PresenceMixProviderPoster;
use directory_client::Directo... | code_fim | hard | {
"lang": "rust",
"repo": "wissemriahi/nym",
"path": "/sfw-provider/src/provider/presence.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn start(self, handle: &Handle) -> JoinHandle<()> {
handle.spawn(async move {
loop {
// set the deadline in the future
let sending_delay = tokio::time::delay_for(self.sending_delay);
let presence = self.make_presence().await;
... | code_fim | hard | {
"lang": "rust",
"repo": "wissemriahi/nym",
"path": "/sfw-provider/src/provider/presence.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn solve_part_1() -> Result<(), ()> {
let bags = parse_input(&fs::read_to_string("./inputs/day7.txt").unwrap());
let bag_map = hashmap_from_list(bags);
println!(
"{}",
bag_map
.iter()
.filter(|(_, v)| expand_until_or_fail(v, "shiny gold", &bag_map))
... | code_fim | hard | {
"lang": "rust",
"repo": "Eosis/AoC2020",
"path": "/src/day_7/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eosis/AoC2020 path: /src/day_7/mod.rs
use itertools::Itertools;
use lazy_static::lazy_static;
use regex::Regex;
use std::fs;
use anyhow::Result;
use std::collections::HashMap;
#[derive(PartialEq, Eq, Clone, Debug)]
struct Bag {
description: String,
held: Vec<(i32, Bag)>,
}
fn bags_fro... | code_fim | hard | {
"lang": "rust",
"repo": "Eosis/AoC2020",
"path": "/src/day_7/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Account {
pub fn new(storage_escrow_fee: YoctoNear) -> Self {
Self {
storage_escrow: TimestampedNearBalance::new(storage_escrow_fee),
near: None,
stake: None,
stake_batch: None,
next_stake_batch: None,
redeem_stake_ba... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/oysterpack-near-stake-token",
"path": "/contract/src/domain/account.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evgenykuzyakov/oysterpack-near-stake-token path: /contract/src/domain/account.rs
use crate::core::Hash;
use crate::domain::stake_batch::StakeBatch;
use crate::domain::{
BatchId, RedeemStakeBatch, TimestampedNearBalance, TimestampedStakeBalance, YoctoNear,
YoctoStake,
};
use near_sdk::bor... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/oysterpack-near-stake-token",
"path": "/contract/src/domain/account.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rokob/aoc-2019 path: /22/advent/src/main.rs
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
enum Step {
Deal,
Incr(usize),
Cut(isize),
}
const N: usize = 119315717514047;
const RUNS: usize = 10174158207... | code_fim | hard | {
"lang": "rust",
"repo": "rokob/aoc-2019",
"path": "/22/advent/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match step {
Step::Deal => size - 1 - current,
Step::Incr(i) => {
let a = *i;
let m = size;
let b = current;
solve_lce(a as isize, m, b)
}
Step::Cut(i) => {
if *i > 0 {
if current < size - *i {
... | code_fim | hard | {
"lang": "rust",
"repo": "rokob/aoc-2019",
"path": "/22/advent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn translate(step: &Step, size: isize, a: &mut isize, b: &mut isize) {
match step {
Step::Deal => {
*a = -*a;
*b = (size - 1 - *b) % size;
},
Step::Incr(i) => {
let inv = mod_inv(*i as isize, size);
*a = ((*a as i128 * inv as i128... | code_fim | hard | {
"lang": "rust",
"repo": "rokob/aoc-2019",
"path": "/22/advent/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juaby/rhai path: /src/packages/utils.rs
use super::PackageStore;
use crate::any::{Dynamic, Variant};
use crate::calc_fn_hash;
use crate::engine::FnCallArgs;
use crate::result::EvalAltResult;
use crate::token::Position;
use crate::stdlib::{
any::TypeId,
boxed::Box,
mem,
string::... | code_fim | hard | {
"lang": "rust",
"repo": "juaby/rhai",
"path": "/src/packages/utils.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut drain = args.iter_mut();
let x: &mut A = drain.next().unwrap().downcast_mut().unwrap();
let y = mem::take(*drain.next().unwrap()).cast::<B>();
let r = func(x, y);
map_result(r, pos)
});
lib.functions.insert(hash, f);
}
/// Add a function with thre... | code_fim | hard | {
"lang": "rust",
"repo": "juaby/rhai",
"path": "/src/packages/utils.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'next_p);
}
}
// next_p:p:=link(p);
'next_p <-
);
$p = link!($globals, $p);
// end
use crate::section_0095::confusion;
use crate::section_0118::link;
use crate::section_0134::is_char_node;
}}
}<|fim_prefix|>// repo: harps... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_0630.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:this can't happen vlistout}{\quad vlistout@>
// else @<Output the non-|char_node| |p| for |vlist_out|@>;
else {
crate::section_0631::Output_the_non_char_node_p_for_vlist_out!($globals, $p, $left_edge, $this_box, $cur_glue, $cur_g, $g_sign, $g_order, 'next_p);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_0630.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0630.rs
//! ` `
// @<Output node |p| for |vlist_out|...@>=
pub(crate) macro Output_node_p_for_vlist_out_and_move_to_the_next_node__maintaining_the_condition_cur_h_eq_left_edge {
($globals:expr, $p:expr, $left_edge:expr, $this_box:expr, $cu... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_0630.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: resonancellc/NEruSt path: /src/cpu/opcode_logic.rs
OpcodeOperand::Address(adr) => cpu_map.set(adr, cpu.acc),
};
// no flags to be set
}
pub fn stx(cpu: &Cpu, cpu_map: &mut GetSet, opop: OpcodeOperand) {
match opop {
OpcodeOperand::Implied => unreachable!(),
OpcodeOp... | code_fim | hard | {
"lang": "rust",
"repo": "resonancellc/NEruSt",
"path": "/src/cpu/opcode_logic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Branching
pub fn bpl(cpu: &mut Cpu, opop: OpcodeOperand) -> bool {
let negative = cpu.get_processor_status_flag(ProcessorStatusFlag::Negative);
if !negative {
match opop {
OpcodeOperand::Immediate(v) => {
cpu.pc = (cpu.pc as i16 + v as i16) as u16;
... | code_fim | hard | {
"lang": "rust",
"repo": "resonancellc/NEruSt",
"path": "/src/cpu/opcode_logic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: resonancellc/NEruSt path: /src/cpu/opcode_logic.rs
ldx(cpu: &mut Cpu, cpu_map: &GetSet, opop: OpcodeOperand) {
match opop {
OpcodeOperand::Implied => unreachable!(),
OpcodeOperand::Immediate(val) => cpu.x = val,
OpcodeOperand::Address(adr) => cpu.x = cpu_map.get(adr)... | code_fim | hard | {
"lang": "rust",
"repo": "resonancellc/NEruSt",
"path": "/src/cpu/opcode_logic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0x192/iced_aw path: /examples/web/src/modal_section.rs
use crate::Section;
use iced::{button, Align, Button, Column, Element, Length, Text};
pub struct ModalSection {
open_button: button::State,
}
<|fim_suffix|> fn header(&self) -> String {
String::from("Modal")
}
fn co... | code_fim | medium | {
"lang": "rust",
"repo": "0x192/iced_aw",
"path": "/examples/web/src/modal_section.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn content(&mut self) -> Element<'_, Self::Message> {
Column::new()
.align_items(Align::Center)
.width(Length::Fill)
.push(
Button::new(&mut self.open_button, Text::new("Open modal!"))
.on_press(crate::Message::OpenPrimary... | code_fim | hard | {
"lang": "rust",
"repo": "0x192/iced_aw",
"path": "/examples/web/src/modal_section.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KristianWahlroos/interledger-rs path: /crates/interledger-spsp/src/client.rs
use super::{Error, SpspResponse};
use futures::TryFutureExt;
use interledger_rates::ExchangeRateStore;
use interledger_service::{Account, IncomingService};
use interledger_stream::{send_money, StreamDelivery};
use reqwe... | code_fim | hard | {
"lang": "rust",
"repo": "KristianWahlroos/interledger-rs",
"path": "/crates/interledger-spsp/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut url: String = if payment_pointer.starts_with('$') {
let mut url = "https://".to_string();
url.push_str(&payment_pointer[1..]);
url
} else {
payment_pointer.to_string()
};
let num_slashes = url.matches('/').count();
if num_slashes == 2 {
... | code_fim | hard | {
"lang": "rust",
"repo": "KristianWahlroos/interledger-rs",
"path": "/crates/interledger-spsp/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laopeng2021/datafuse path: /fusequery/query/src/datasources/remote/remote_database.rs
// Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
use std::sync::Arc;
use common_exception::ErrorCode;
use common_exception::Result;
use common_infallible::RwLock;
use co... | code_fim | hard | {
"lang": "rust",
"repo": "laopeng2021/datafuse",
"path": "/fusequery/query/src/datasources/remote/remote_database.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.tables.read().name2meta.get(table_name) {
Some(tbl) => Ok(tbl.clone()),
None => Err(ErrorCode::UnknownTable(format!(
"Unknown table: '{}'",
table_name
))),
}
}
fn get_table_by_id(
&self,
... | code_fim | hard | {
"lang": "rust",
"repo": "laopeng2021/datafuse",
"path": "/fusequery/query/src/datasources/remote/remote_database.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>C" {
pub fn napi_define_properties(
env: napi_env,
object: napi_value,
property_count: usize,
properties: *const napi_property_descriptor,
) -> napi_status;
}
extern "C" {
pub fn napi_is_array(env: napi_env, value: napi_value, result: *mut bool) -> napi_status;
... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/nj-sys/src/binding.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinyon/node-bindgen path: /nj-sys/src/binding.rs
eld: ",
stringify!(napi_property_descriptor),
"::",
stringify!(utf8name)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<napi_property_descriptor>())).name as *const _ as usize },
... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/nj-sys/src/binding.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
::std::mem::size_of::<napi_extended_error_info>(),
24usize,
concat!("Size of: ", stringify!(napi_extended_error_info))
);
assert_eq!(
::std::mem::align_of::<napi_extended_error_info>(),
8usize,
concat!("Alignment of ", stringify!(napi... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/node-bindgen",
"path": "/nj-sys/src/binding.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inyourarms/near-voting-example path: /contract/src/lib.rs
use borsh::{BorshDeserialize, BorshSerialize};
use near_sdk::{env, near_bindgen};
use std::collections::HashMap;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[near_bindgen]
#[derive(Default, Borsh... | code_fim | hard | {
"lang": "rust",
"repo": "inyourarms/near-voting-example",
"path": "/contract/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let context = get_context(vec![], false);
testing_env!(context);
let mut contract = Voting::new();
contract.add_candidate("Jeff".to_string());
assert_eq!(0, contract.get_total_votes_for("Jeff".to_string()).unwrap());
}
#[test]
fn test_get_total_votes_fo... | code_fim | hard | {
"lang": "rust",
"repo": "inyourarms/near-voting-example",
"path": "/contract/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod controller;
pub mod base;
pub mod model;<|fim_prefix|>// repo: allwefantasy/mlsql-store path: /src/lib.rs
#![feature(proc_macro_hygiene, decl_macro, async_await)]
#![feature(fn_traits)]
#![feature(async_closure)]
<|fim_middle|>extern crate clap;
extern crate reqwest;
extern crate rocket;
extern ... | code_fim | medium | {
"lang": "rust",
"repo": "allwefantasy/mlsql-store",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: allwefantasy/mlsql-store path: /src/lib.rs
#![feature(proc_macro_hygiene, decl_macro, async_await)]
#![feature(fn_traits)]
#![feature(async_closure)]
<|fim_suffix|>pub mod controller;
pub mod base;
pub mod model;<|fim_middle|>extern crate clap;
extern crate reqwest;
extern crate rocket;
extern ... | code_fim | medium | {
"lang": "rust",
"repo": "allwefantasy/mlsql-store",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuillaumeGomez/sysinfo path: /tests/cpu.rs
// Take a look at the license at the top of the repository in the LICENSE file.
// This test is used to ensure that the CPUs are not loaded by default.
#[test]
fn test_cpu() {
use sysinfo::{CpuExt, SystemExt};
if sysinfo::System::IS_SUPPORTED... | code_fim | medium | {
"lang": "rust",
"repo": "GuillaumeGomez/sysinfo",
"path": "/tests/cpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn upsert_differentiates_imposters_with_different_ids() {
let list = ImposterList::new();
list.upsert(Imposter::from_json(r#"{"id": 1, "stubs": []}"#));
list.upsert(Imposter::from_json(r#"{"id": 2, "stubs": []}"#));
assert_eq!(2, list.get_all().len());
... | code_fim | hard | {
"lang": "rust",
"repo": "thoughtworks/candouble",
"path": "/src/controller.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thoughtworks/candouble path: /src/controller.rs
use std::borrow::BorrowMut;
use std::sync::{Arc, Mutex};
use std::thread;
use gotham_derive::*;
use crate::imposter;
use crate::imposter::Imposter;
use crate::webapi;
#[derive(Clone, StateData)]
pub struct ImposterList {
inner: Arc<Mutex<Vec... | code_fim | hard | {
"lang": "rust",
"repo": "thoughtworks/candouble",
"path": "/src/controller.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
true,
rstr.setex("whb2", &mut "abc".to_string().into_bytes(), 10)
);
assert_eq!(0, rstr.setnx("whb2", "abc"));
}<|fim_prefix|>// repo: fly542/arnl path: /src/libredis/tests/redis_string.rs
use redis::redis_client::RedisClient;
use redis::redis_string::RedisString;
... | code_fim | hard | {
"lang": "rust",
"repo": "fly542/arnl",
"path": "/src/libredis/tests/redis_string.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fly542/arnl path: /src/libredis/tests/redis_string.rs
use redis::redis_client::RedisClient;
use redis::redis_string::RedisString;
<|fim_suffix|> let addr = "127.0.0.1:6379";
let conn_timeout = 0u64;
let rw_timeout = 3u64;
let mut stream = RedisClient::new(addr, &conn_timeout, &rw... | code_fim | medium | {
"lang": "rust",
"repo": "fly542/arnl",
"path": "/src/libredis/tests/redis_string.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..num {
// create witness
let mut witness: [Vec<Fp>; COLUMNS] =
array_init(|_| vec![Fp::zero(); MUL_GATES + ADD_GATES]);
for row in 0..MUL_GATES {
witness[LEFT][row] = 3u32.into();
witness[RIGHT][row] = 5u32.into();
wit... | code_fim | hard | {
"lang": "rust",
"repo": "gpestana/proof-systems",
"path": "/dlog/kimchi/src/bench.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // previous opening for recursion
let prev = {
let k = ceil_log2(index.srs.g.len());
let chals: Vec<_> = (0..k).map(|_| Fp::rand(rng)).collect();
let comm = {
let coeffs = b_poly_coefficients(&chals);
let b = DensePolynomi... | code_fim | hard | {
"lang": "rust",
"repo": "gpestana/proof-systems",
"path": "/dlog/kimchi/src/bench.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gpestana/proof-systems path: /dlog/kimchi/src/bench.rs
use crate::{index::Index, prover::ProverProof};
use ark_ff::{One, UniformRand, Zero};
use ark_poly::{univariate::DensePolynomial, UVPolynomial};
use array_init::array_init;
use commitment_dlog::{
commitment::{b_poly_coefficients, ceil_lo... | code_fim | hard | {
"lang": "rust",
"repo": "gpestana/proof-systems",
"path": "/dlog/kimchi/src/bench.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>TTER_KEY_KP_Prior: c_int = 65434;
pub const CLUTTER_KEY_KP_Right: c_int = 65432;
pub const CLUTTER_KEY_KP_Separator: c_int = 65452;
pub const CLUTTER_KEY_KP_Space: c_int = 65408;
pub const CLUTTER_KEY_KP_Subtract: c_int = 65453;
pub const CLUTTER_KEY_KP_Tab: c_int = 65417;
pub const CLUTTER_KEY_KP_Up: c_i... | code_fim | hard | {
"lang": "rust",
"repo": "angular-rust/clutter-rs",
"path": "/sys/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //=========================================================================
// ClutterBoxLayout
//=========================================================================
pub fn clutter_box_layout_get_type() -> GType;
pub fn clutter_box_layout_new() -> *mut ClutterLayoutManager;
p... | code_fim | hard | {
"lang": "rust",
"repo": "angular-rust/clutter-rs",
"path": "/sys/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: angular-rust/clutter-rs path: /sys/src/lib.rs
LUTTER_KEY_Thai_moma: c_int = 3521;
pub const CLUTTER_KEY_Thai_ngongu: c_int = 3495;
pub const CLUTTER_KEY_Thai_nikhahit: c_int = 3565;
pub const CLUTTER_KEY_Thai_nonen: c_int = 3507;
pub const CLUTTER_KEY_Thai_nonu: c_int = 3513;
pub const CLUTTER_K... | code_fim | hard | {
"lang": "rust",
"repo": "angular-rust/clutter-rs",
"path": "/sys/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>low();
}
Color::Yellow => {
self.red.set_low();
self.green.set_low();
self.blue.set_high();
}
Color::White => {
self.red.set_low();
self.green.set_low();
self.blu... | code_fim | hard | {
"lang": "rust",
"repo": "fmckeogh/navio2",
"path": "/src/led.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fmckeogh/navio2 path: /src/led.rs
use embedded_hal::digital::v2::OutputPin;
pub struct Led<R, G, B> {
red: R,
green: G,
blue: B,
}
// Allow unused results until I decide on std/nostd
#[allow(unused_must_use)]
impl<R, G, B> Led<R, G, B>
where
R: OutputPin,
G: OutputPin,
... | code_fim | hard | {
"lang": "rust",
"repo": "fmckeogh/navio2",
"path": "/src/led.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
Color::Blue => {
self.red.set_high();
self.green.set_high();
self.blue.set_low();
}
Color::Cyan => {
self.red.set_high();
self.green.set_low();
self.blue.set_low();
... | code_fim | hard | {
"lang": "rust",
"repo": "fmckeogh/navio2",
"path": "/src/led.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rustops/dwarf_seeks_fortune path: /dsf_checks/src/states/movement_test.rs
use amethyst::prelude::WorldExt;
use amethyst::StateEvent;
use amethyst::{
animation::{
get_animation_set, AnimationCommand, AnimationControlSet, AnimationSet, EndControl,
},
ecs::{Entities, Join, Read... | code_fim | hard | {
"lang": "rust",
"repo": "Rustops/dwarf_seeks_fortune",
"path": "/dsf_checks/src/states/movement_test.rs",
"mode": "psm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> MovementTestState {
dispatcher: DispatcherBuilder::new()
.with(
systems::TestSetupSystem::default(),
"test_setup_system",
&[],
)
.build(),
}
}
}
impl SimpleState for... | code_fim | hard | {
"lang": "rust",
"repo": "Rustops/dwarf_seeks_fortune",
"path": "/dsf_checks/src/states/movement_test.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.dispatcher.dispatch(data.world);
// Execute a pass similar to a system
data.world.exec(
|(entities, animation_sets, mut control_sets): (
Entities<'_>,
ReadStorage<'_, AnimationSet<AnimationId, SpriteRender>>,
WriteSto... | code_fim | hard | {
"lang": "rust",
"repo": "Rustops/dwarf_seeks_fortune",
"path": "/dsf_checks/src/states/movement_test.rs",
"mode": "spm",
"license": "BlueOak-1.0.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> },
recv(stop_rx) -> _ =>{
debug!("deadlock_detection received exit signal, stopped");
return;
}
}
}
});
register_thread("dead_lock_detect", dead_lock_jh);
}
pub fn prompt(msg: &str) -> Stri... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/ckb-bin/src/helper.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nervosnetwork/ckb path: /ckb-bin/src/helper.rs
use ckb_logger::info;
use std::io::{stdin, stdout, Write};
#[cfg(not(feature = "deadlock_detection"))]
pub fn deadlock_detection() {}
#[cfg(feature = "deadlock_detection")]
pub fn deadlock_detection() {
use ckb_channel::select;
use ckb_lo... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/ckb-bin/src/helper.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input
}
/// Raise the soft open file descriptor resource limit to the hard resource
/// limit.
///
/// # Panics
///
/// Panics if [`libc::getrlimit`], [`libc::setrlimit`], [`libc::sysctl`], [`libc::getrlimit`] or [`libc::setrlimit`]
/// fail.
///
/// darwin_fd_limit exists to work around an issue whe... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/ckb-bin/src/helper.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryanhossain9797/snips-nlu-rs path: /src/entity_parser/utils.rs
use std::hash::Hash;
use lru_cache::LruCache;
use crate::errors::*;
<|fim_suffix|> pub fn try_cache<F: Fn(&K) -> Result<V>>(&mut self, key: &K, producer: F) -> Result<V> {
let cached_value = self.0.get_mut(key).cloned()... | code_fim | hard | {
"lang": "rust",
"repo": "ryanhossain9797/snips-nlu-rs",
"path": "/src/entity_parser/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<K, V> Cache<K, V>
where
K: Eq + Hash + Clone,
V: Clone,
{
pub fn new(capacity: usize) -> Self {
Cache(LruCache::new(capacity))
}
pub fn try_cache<F: Fn(&K) -> Result<V>>(&mut self, key: &K, producer: F) -> Result<V> {
let cached_value = self.0.get_mut(key).cloned(... | code_fim | medium | {
"lang": "rust",
"repo": "ryanhossain9797/snips-nlu-rs",
"path": "/src/entity_parser/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YushiOMOTE/toio-con path: /src/main.rs
use anyhow::{anyhow, Result};
use gilrs::{Axis, Button, Event, EventType, Gilrs};
use log::*;
use toio::Cube;
#[derive(Debug, Clone, Default)]
struct ButtonState {
north: bool,
south: bool,
east: bool,
west: bool,
x: f32,
y: f32,
... | code_fim | hard | {
"lang": "rust",
"repo": "YushiOMOTE/toio-con",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let w = state.boost;
if state.x.abs() / 2.0 > state.y.abs() {
let x = state.x * (10.0 + w * 10.0);
s.speed.r = (-1.0 * x) as isize;
s.speed.l = (1.0 * x) as isize;
} else {
let x = state.x * (80.0 - (20.0 *... | code_fim | hard | {
"lang": "rust",
"repo": "YushiOMOTE/toio-con",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern "C" fn search_neighbours_f32(hnsw_api : *const HnswApif32, len:usize, data : *const f32,
knbn : usize, ef_search : usize) -> *const Neighbourhood_api {
//
log::trace!("entering search_neighbours , vec len is {:?}, id : {:?} e... | code_fim | hard | {
"lang": "rust",
"repo": "jean-pierreBoth/hnswlib-rs",
"path": "/src/libext.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jean-pierreBoth/hnswlib-rs path: /src/libext.rs
og::trace!("entering insert, type {:?} vec len is {:?}, id : {:?} ", stringify!($type_val), len, id);
// construct vector: Rust clones and take ownership.
let data_v : Vec<$type_val>;
unsafe {
let slice = std::s... | code_fim | hard | {
"lang": "rust",
"repo": "jean-pierreBoth/hnswlib-rs",
"path": "/src/libext.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
generate_parallel_search_neighbours!(parallel_search_neighbours_f32, HnswApif32, f32);
generate_file_dump!(file_dump_f32, HnswApif32, f32);
//=============== implementation for i32
#[no_mangle]
pub extern "C" fn init_hnsw_i32(max_nb_conn : usize, ef_const:usize, namelen: usize, cdistname : *const u... | code_fim | hard | {
"lang": "rust",
"repo": "jean-pierreBoth/hnswlib-rs",
"path": "/src/libext.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut i = 0;
let mut j = 0;
let mut nxt_a = Vec::new();
while i < m || j < m {
let status = if i == m {
1
} else if j == m {
0
} else {
match a[i].0... | code_fim | hard | {
"lang": "rust",
"repo": "wisest30/AlgoStudy",
"path": "/source/HackerCup/2021_Round_2/A/hyo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wisest30/AlgoStudy path: /source/HackerCup/2021_Round_2/A/hyo.rs
#[allow(unused_imports)]
use std::{
io::{BufWriter, stdin, stdout, Write},
str::FromStr, cmp::{min,max,Ordering},
collections::HashMap,
};
#[derive(Default)]
struct Scanner {
buffer: Vec<String>
}
#[allow(dead_cod... | code_fim | hard | {
"lang": "rust",
"repo": "wisest30/AlgoStudy",
"path": "/source/HackerCup/2021_Round_2/A/hyo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match status {
0 => {
ans -= if a[i].1 {1} else {0};
i += 1;
}
1 => {
ans += 1;
nxt_a.push((b[j], false));
j +... | code_fim | hard | {
"lang": "rust",
"repo": "wisest30/AlgoStudy",
"path": "/source/HackerCup/2021_Round_2/A/hyo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
// paint_pink();
paint_image(proof_gen.clone(), Pos::new(100 - 35, 100 - 35), "images/insalgo-30-rouge.png");
}
}<|fim_prefix|>// repo: MathisHammel/pixelwar path: /totorigolo-rs/src/main.rs
use pixelwar_client_rs::{Pos, proof, paint_image};
fn main() {
<|fim_middle|> e... | code_fim | hard | {
"lang": "rust",
"repo": "MathisHammel/pixelwar",
"path": "/totorigolo-rs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MathisHammel/pixelwar path: /totorigolo-rs/src/main.rs
use pixelwar_client_rs::{Pos, proof, paint_image};
fn main() {
env_logger::init();
println!("pixelwar.h25.io client from totorigolo.");
<|fim_suffix|> loop {
// paint_pink();
paint_image(proof_gen.clone(), Pos::n... | code_fim | medium | {
"lang": "rust",
"repo": "MathisHammel/pixelwar",
"path": "/totorigolo-rs/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let assert_device_name = opt
.assert_device_name
.as_ref()
.map(AsRef::as_ref)
.map(to_name_type)
.transpose()?;
tx.send(Cmd::StartPulses)?;
let cb = Box::new(|tm| {
println!("got new time model: {:?}", tm);
});
let query_dt = std::tim... | code_fim | hard | {
"lang": "rust",
"repo": "liatli/triggerbox_straw",
"path": "/braid-triggerbox-rs/src/bin/standalone-triggerbox-demo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liatli/triggerbox_straw path: /braid-triggerbox-rs/src/bin/standalone-triggerbox-demo.rs
#[macro_use]
extern crate log;
use braid_triggerbox::{
launch_background_thread, make_trig_fps_cmd, name_display, to_name_type, Cmd,
};
use structopt::StructOpt;
#[cfg(target_os = "macos")]
const DEFAU... | code_fim | hard | {
"lang": "rust",
"repo": "liatli/triggerbox_straw",
"path": "/braid-triggerbox-rs/src/bin/standalone-triggerbox-demo.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: io12/pwninit path: /src/solvepy.rs
use crate::opts::Opts;
use crate::patch_bin;
use crate::set_exec;
use std::path::Path;
use std::string;
use colored::Colorize;
use ex::fs;
use ex::io;
use maplit::hashmap;
use snafu::ResultExt;
use snafu::Snafu;
use strfmt::strfmt;
#[derive(Debug, Snafu)]
#[... | code_fim | hard | {
"lang": "rust",
"repo": "io12/pwninit",
"path": "/src/solvepy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let templ = match &opts.template_path {
Some(path) => {
let data = fs::read(path).context(ReadSnafu)?;
String::from_utf8(data).context(Utf8Snafu)?
}
None => include_str!("template.py").to_string(),
};
strfmt(
&templ,
&hashmap! {
... | code_fim | hard | {
"lang": "rust",
"repo": "io12/pwninit",
"path": "/src/solvepy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: miukki/rust-quessing-game path: /src/main.rs
use std::io;
use rand::{thread_rng, Rng};
use std::cmp::Ordering;
use std::mem;
use self::foo::say_foo;
use self::something::Foo; // Ok.
//use library
use guessing_game::GREETING;
use guessing_game::say_hi;
mod foo {
pub fn say_foo() {
... | code_fim | hard | {
"lang": "rust",
"repo": "miukki/rust-quessing-game",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let y: f64 = thread_rng().gen(); // generates a float between 0 and 1
println!("char f64: {}", y);
loop {
println!("Please input your guess.");
let mut guess = String::new(); // UTF-8 encoded bit of text. Static method
io::stdin()
.read_line(&mut guess)... | code_fim | hard | {
"lang": "rust",
"repo": "miukki/rust-quessing-game",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prostoiChelovek/rusty-jam-2021 path: /src/character_body.rs
use rg3d::{
core::{
algebra::Vector3,
pool::Handle,
},
physics::{
dynamics::{RigidBodyBuilder, RigidBodyType},
geometry::ColliderBuilder,
},
engine::{RigidBodyHandle, ColliderHandle},
... | code_fim | hard | {
"lang": "rust",
"repo": "prostoiChelovek/rusty-jam-2021",
"path": "/src/character_body.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
body,
model,
pivot,
spine,
collider,
size
}
}
pub fn has_ground_contact(&self, physics: &Physics) -> bool {
let body = physics.bodies.get(&self.body).unwrap();
for contact in physics.nar... | code_fim | hard | {
"lang": "rust",
"repo": "prostoiChelovek/rusty-jam-2021",
"path": "/src/character_body.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl DBAccessor for DBAccess {
async fn fetch_todos(&self) -> Result<Vec<Todo>> {
let con = self.get_db_con().await?;
let query = "SELECT id, name, checked FROM todo ORDER BY id ASC";
let q = con.query(query, &[]).await;
let rows = q.map_err(DBQueryError)... | code_fim | hard | {
"lang": "rust",
"repo": "zupzup/rust-web-e2e-testing",
"path": "/src/db.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zupzup/rust-web-e2e-testing path: /src/db.rs
use crate::{error, error::Error::*, DBCon, DBPool};
use mobc::async_trait;
use mobc::Pool;
use mobc_postgres::{tokio_postgres, PgConnectionManager};
use serde::Deserialize;
use std::fs;
use std::str::FromStr;
use tokio_postgres::{Config, Error, NoTls,... | code_fim | hard | {
"lang": "rust",
"repo": "zupzup/rust-web-e2e-testing",
"path": "/src/db.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: noeddl/rustfst path: /rustfst/src/tests_openfst/algorithms/shortest_distance.rs
use std::f32;
use failure::Fallible;
use serde_derive::{Deserialize, Serialize};
use crate::algorithms::shortest_distance;
use crate::fst_traits::MutableFst;
use crate::fst_traits::TextParser;
use crate::semirings:... | code_fim | medium | {
"lang": "rust",
"repo": "noeddl/rustfst",
"path": "/rustfst/src/tests_openfst/algorithms/shortest_distance.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ShorestDistanceOperationResult {
pub fn parse<W: Semiring<Type = f32>>(&self) -> ShortestDistanceTestData<W> {
let inf = "Infinity".to_string();
let r = self
.result
.iter()
.map(|v| {
if v == &inf {
f32::INFI... | code_fim | hard | {
"lang": "rust",
"repo": "noeddl/rustfst",
"path": "/rustfst/src/tests_openfst/algorithms/shortest_distance.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("par filter 1m", |b| {
b.iter(|| par_filter(black_box(source_items_1m.clone()), &matcher, &query))
});
let ctags_cmd =
build_recursive_ctags_cmd("/home/xlc/src/github.com/paritytech/substrate".into());
c.bench_function("parallel recursive ctags", |b| {
... | code_fim | hard | {
"lang": "rust",
"repo": "michalhonc/dot-files",
"path": "/config/.vim/.cache/.vimrc/.dein/crates/maple_cli/benches/benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("par filter 100k", |b| {
b.iter(|| par_filter(black_box(source_items_100k.clone()), &matcher, &query))
});
c.bench_function("filter 1m", |b| {
b.iter(|| filter(black_box(source_items_1m.clone()), &matcher, &query))
});
c.bench_function("par filter 1m"... | code_fim | hard | {
"lang": "rust",
"repo": "michalhonc/dot-files",
"path": "/config/.vim/.cache/.vimrc/.dein/crates/maple_cli/benches/benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michalhonc/dot-files path: /config/.vim/.cache/.vimrc/.dein/crates/maple_cli/benches/benchmark.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use filter::{FilteredItem, Query, SourceItem};
use matcher::{FuzzyAlgorithm, MatchType, Matcher};
use maple_cli::command::ct... | code_fim | hard | {
"lang": "rust",
"repo": "michalhonc/dot-files",
"path": "/config/.vim/.cache/.vimrc/.dein/crates/maple_cli/benches/benchmark.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vulkan_data
.get_swapchain_loader_ref()
.destroy_swapchain(vulkan_data.swapchain, None);
vulkan_data.swapchain = vk::SwapchainKHR::null();
}
}<|fim_prefix|>// repo: nikitablack/rust_vulkan_imgui path: /src/app/vulkan_init/clear.rs
use crate::app;
use ash::versi... | code_fim | hard | {
"lang": "rust",
"repo": "nikitablack/rust_vulkan_imgui",
"path": "/src/app/vulkan_init/clear.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nikitablack/rust_vulkan_imgui path: /src/app/vulkan_init/clear.rs
use crate::app;
use ash::version::DeviceV1_0;
use ash::vk;
pub fn clear_vulkan_data(mut vulkan_data: &mut app::VulkanInitData) {
unsafe {
let _ = vulkan_data.get_device_ref().device_wait_idle();
}
clear_swapc... | code_fim | hard | {
"lang": "rust",
"repo": "nikitablack/rust_vulkan_imgui",
"path": "/src/app/vulkan_init/clear.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfdeakin/gwt path: /src/engine/buildings.rs
use serde::{Deserialize, Serialize};
use crate::actions::{ActionTag, ActionValues, DiscardCardOpts};
use crate::deck::CowColor;
use crate::logical::{And, Or, XOr};
use crate::player::Employee;
#[derive(Copy, Clone, Eq, PartialEq, Serialize, Deseriali... | code_fim | hard | {
"lang": "rust",
"repo": "mfdeakin/gwt",
"path": "/src/engine/buildings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 4 => Or::new(&[
XOr::new(&[And::new(&[
ActionTag::DiscardCard(DiscardCardOpts::Color(CowColor::Angus)),
ActionTag::MoveCertificate(ActionValues::Exact(2)),
]), ]),
... | code_fim | hard | {
"lang": "rust",
"repo": "mfdeakin/gwt",
"path": "/src/engine/buildings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/overnet/lib/core/src/router/routes.rs
// Copyright 2020 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 crate::future_help::{Observable, Observer};
use ... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/overnet/lib/core/src/router/routes.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[fuchsia::test]
async fn test_merge_links_removes_routes() {
const NODE_ID: u64 = 42;
const FOREIGN_NODE_ID: u64 = 23;
const UNRELATED_NODE_ID: u64 = 82;
const NODE_LINK_ID: u64 = 99;
let routes = Arc::new(Routes::new());
routes
.db
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/overnet/lib/core/src/router/routes.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn is_via(&self, node_id: NodeId) -> bool {
self.intermediate_hops.iter().find(|&&n| n == node_id).is_some()
}
pub(crate) fn score(&self) -> impl PartialOrd {
score_rtt(self.round_trip_time)
}
fn is_significantly_different_to(&self, other: &Self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/overnet/lib/core/src/router/routes.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("a = {}", a);
println!("b = {}", b);
println!("a + b = {}", a + b);
println!("a * b = {}", a * b);
println!("1 / a = {}", Complex{re: 1.0, im: 0.0} / a);
println!("-a = {}", -a);
println!("conj a = {}", a.conj());
}<|fim_prefix|>// repo: JIghtuse/rosetta path: /comple... | code_fim | medium | {
"lang": "rust",
"repo": "JIghtuse/rosetta",
"path": "/complex/rust/complex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JIghtuse/rosetta path: /complex/rust/complex.rs
extern crate num;
use num::complex::Complex;
fn main() {
<|fim_suffix|> println!("a = {}", a);
println!("b = {}", b);
println!("a + b = {}", a + b);
println!("a * b = {}", a * b);
println!("1 / a = {}", Complex{re: 1.0, im: 0.0}... | code_fim | medium | {
"lang": "rust",
"repo": "JIghtuse/rosetta",
"path": "/complex/rust/complex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/os_str_bytes/v6/crate/src/pattern.rs
use super::private;
pub trait Encoded {
fn __get(&self) -> &[u8];
}
#[derive(Clone)]
pub struct EncodedChar {
buffer: [u8; 4],
length: usize,
}
impl Encoded for EncodedChar {
#[inline]
fn __get(... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/os_str_bytes/v6/crate/src/pattern.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self
}
}
impl<'a> Pattern for &'a String {
#[doc(hidden)]
type __Encoded = <&'a str as Pattern>::__Encoded;
#[doc(hidden)]
fn __encode(self) -> Self::__Encoded {
(**self).__encode()
}
}<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/os_str_bytes/... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/os_str_bytes/v6/crate/src/pattern.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_array<T: std::string::ToString>(array: &Vec<T>) {
println!(
"{}",
array
.iter()
.map(|ref x| x.to_string())
.collect::<Vec<_>>()
.join(" ")
);
}
fn main() {
assert_eq!(char_to_digit('a'), 0);
assert_eq!(char_to_digit... | code_fim | medium | {
"lang": "rust",
"repo": "fukatani/rust-ant-book",
"path": "/lib/num_char.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fukatani/rust-ant-book path: /lib/num_char.rs
fn char_to_digit(ch: char) -> usize {
ch.to_digit(36).unwrap() as usize - 10
}
<|fim_suffix|>fn print_array<T: std::string::ToString>(array: &Vec<T>) {
println!(
"{}",
array
.iter()
.map(|ref x| x.to_s... | code_fim | medium | {
"lang": "rust",
"repo": "fukatani/rust-ant-book",
"path": "/lib/num_char.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let size = self.coeffs.len() + rhs.coeffs.len() - 1;
let mut out = Vec::with_capacity(size);
out.resize(size, Default::default());
for j in 0 .. rhs.coeffs.len() {
for i in 0 .. self.coeffs.len() {
out[i + j] = out[i + j] + self.coeffs[i] * rhs.c... | code_fim | hard | {
"lang": "rust",
"repo": "hestati63/my-ctf-challenges",
"path": "/codegate2020/RS/prob_src/src/poly.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hestati63/my-ctf-challenges path: /codegate2020/RS/prob_src/src/poly.rs
use std::ops::{Add, Mul, Index};
#[derive(Debug, Clone, PartialEq, Eq)]
#[repr(transparent)]
pub struct Poly<T> {
// a0 + a1 * x^0 + ...
// storing [a0, a1, ...]
coeffs : Vec<T>,
}
impl<T> Poly<T> {
pub con... | code_fim | medium | {
"lang": "rust",
"repo": "hestati63/my-ctf-challenges",
"path": "/codegate2020/RS/prob_src/src/poly.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ipoemigmail/rust-study path: /reqwest-json/src/main.rs
use serde_json::Value;
use std::collections::HashMap;
#[derive(Debug)]
struct Record {
pub ppkey: i64,
pub keyword: String,
pub image_url: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
... | code_fim | medium | {
"lang": "rust",
"repo": "ipoemigmail/rust-study",
"path": "/reqwest-json/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn show_first(v: Value) {
v.as_object()
.unwrap()
.get("serviced")
.unwrap()
.as_array()
.unwrap()
.iter()
.take(1)
.for_each(|v| println!("{:?}", v))
}
fn read_record(v: Value) -> Option<Vec<Record>> {
v.as_object()?
.get("s... | code_fim | hard | {
"lang": "rust",
"repo": "ipoemigmail/rust-study",
"path": "/reqwest-json/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new(user_id: uuid::Uuid, token: String) -> Self {
Self {
user_id,
token,
expires_at: chrono::Utc::now() + Self::lifetime(),
}
}
/// Check, is session token expired from current time
pub fn is_expired(&self) -> bool {
chron... | code_fim | medium | {
"lang": "rust",
"repo": "azinit/backend",
"path": "/core/src/models/session_token.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azinit/backend path: /core/src/models/session_token.rs
use chrono::{DateTime, Utc};
/// TODO: how to guarantee model validity
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SessionToken {
/// cardbox user
pub user_id: uuid::Uuid,
pub token: String,
pub expires_at: DateT... | code_fim | hard | {
"lang": "rust",
"repo": "azinit/backend",
"path": "/core/src/models/session_token.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Check, is session token expired from current time
pub fn is_expired(&self) -> bool {
chrono::Utc::now() > self.expires_at
}
}<|fim_prefix|>// repo: azinit/backend path: /core/src/models/session_token.rs
use chrono::{DateTime, Utc};
/// TODO: how to guarantee model validity
#[deri... | code_fim | hard | {
"lang": "rust",
"repo": "azinit/backend",
"path": "/core/src/models/session_token.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/freecell path: /src/components/cell.rs
use crate::card::{Card, CARD_HEIGHT, CARD_WIDTH};
use crate::game::Collision;
use crate::tileset::{TileParams, TileSet};
use ggez::event::EventHandler;
use ggez::{Context, GameResult};
use nalgebra::Vector2;
use std::sync::{Arc, Mutex};
pub struct ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/freecell",
"path": "/src/components/cell.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.tileset
.lock()
.unwrap()
.queue_tile(self.card.clone(), self.pos, None::<TileParams>)
.unwrap();
Ok(())
}
}
impl Collision for Cell {
fn inside(&self, pos: Vector2<i32>) -> bool {
pos[0] >= self.pos[0]
&& po... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/freecell",
"path": "/src/components/cell.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.