text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: kaedroho/sparrow path: /src/term_dictionary.rs
use std::collections::hash_map::HashMap;
use fnv::FnvHashMap;
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, serde_derive::Serialize, serde_derive::Deserialize)]
#[serde(transparent)]
pub struct TermId(pub u32);
<|fim_suffix|>impl TermDictionar... | code_fim | medium | {
"lang": "rust",
"repo": "kaedroho/sparrow",
"path": "/src/term_dictionary.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TermDictionary {
pub fn get_or_insert(&mut self, term: &str) -> TermId {
if let Some(term_id) = self.terms.get(term) {
term_id.clone()
} else {
let id = TermId(self.next_id);
self.next_id += 1;
self.terms.insert(term.to_owned(), id);... | code_fim | medium | {
"lang": "rust",
"repo": "kaedroho/sparrow",
"path": "/src/term_dictionary.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wolfgang/srl path: /src/_tests/feature/game_ends_when_all_enemies_are_dead.rs
use crate::_tests::_helpers::testable_game::TestableGame;
use crate::game::game::GameState::{AllEnemiesDied, Running};
use crate::input::move_direction::MoveDirection::Right;
<|fim_suffix|> let mut game = TestableG... | code_fim | medium | {
"lang": "rust",
"repo": "wolfgang/srl",
"path": "/src/_tests/feature/game_ends_when_all_enemies_are_dead.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut game = TestableGame::from_strings(vec![" . @ E E"]);
game.configure_combat(|combat_engine| {
combat_engine.say_is_hit((1, 0), (2, 0));
combat_engine.say_is_hit((2, 0), (3, 0));
combat_engine.say_damage((1, 0), TestableGame::default_enemy_hp()*10);
combat_eng... | code_fim | medium | {
"lang": "rust",
"repo": "wolfgang/srl",
"path": "/src/_tests/feature/game_ends_when_all_enemies_are_dead.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: ToString + Clone> Generator<T> for ConstantGenerator<T> {
fn next_value(&self, _rng: &mut SmallRng) -> T {
self.value.clone()
}
}<|fim_prefix|>// repo: skyzh/rust-ycsb path: /src/generator/constant_generator.rs
use rand::prelude::SmallRng;
use super::Generator;
pub struct Consta... | code_fim | medium | {
"lang": "rust",
"repo": "skyzh/rust-ycsb",
"path": "/src/generator/constant_generator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skyzh/rust-ycsb path: /src/generator/constant_generator.rs
use rand::prelude::SmallRng;
use super::Generator;
<|fim_suffix|>impl<T: ToString + Clone> Generator<T> for ConstantGenerator<T> {
fn next_value(&self, _rng: &mut SmallRng) -> T {
self.value.clone()
}
}<|fim_middle|>pub... | code_fim | medium | {
"lang": "rust",
"repo": "skyzh/rust-ycsb",
"path": "/src/generator/constant_generator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbknapp/rust-cli-template path: /src/cli.rs
use clap::{crate_authors, Clap};
static VERSION: &str = env!("VERSION_WITH_GIT_HASH");
static AUTHORS: &str = crate_authors!();
static DESCRIPTION: &str = crate_description!();
#[derive(Clap)]
#[clap(author = AUTHORS, version = VERSION, about = DESCR... | code_fim | medium | {
"lang": "rust",
"repo": "kbknapp/rust-cli-template",
"path": "/src/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>er. -q: INFO, -qq: WARN, -qqq: ERROR (i.e. everything)
#[clap(long, short, overrides_with = "verbose", parse(from_occurrences))]
pub(crate) quiet: u8,
}<|fim_prefix|>// repo: kbknapp/rust-cli-template path: /src/cli.rs
use clap::{crate_authors, Clap};
static VERSION: &str = env!("VERSION_WITH_GI... | code_fim | medium | {
"lang": "rust",
"repo": "kbknapp/rust-cli-template",
"path": "/src/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(Ok(r)) = excel.worksheet_range(sheet) {
for (i, row) in r.rows().enumerate() {
if i == 0 {
continue;
}
if let DataType::String(key) = &row[0] {
match &row[column] {
DataType::String(val) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "HummerHead87/xlsx-to-json",
"path": "/src/xlsx.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let DataType::String(key) = &row[0] {
match &row[column] {
DataType::String(val) => {
let keys = key
.split(".")
.map(|v| v.to_string())
.collect()... | code_fim | hard | {
"lang": "rust",
"repo": "HummerHead87/xlsx-to-json",
"path": "/src/xlsx.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HummerHead87/xlsx-to-json path: /src/xlsx.rs
use std::error::Error;
use std::collections::HashMap;
use std::io::BufReader;
use std::fs::File;
use calamine::{Reader, Xlsx, open_workbook, DataType};
type Contents = HashMap<Vec<String>, String>;
pub fn read_file(filename: &str, sheet: &str, colum... | code_fim | hard | {
"lang": "rust",
"repo": "HummerHead87/xlsx-to-json",
"path": "/src/xlsx.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xdeafbeef/nekoton path: /src/crypto/ledger_key/mod.rs
use std::collections::hash_map::{self, HashMap};
use std::convert::TryInto;
use std::io::Read;
use std::sync::Arc;
use anyhow::Result;
use async_trait::async_trait;
use ed25519_dalek::PublicKey;
use serde::{Deserialize, Serialize};
use nek... | code_fim | hard | {
"lang": "rust",
"repo": "0xdeafbeef/nekoton",
"path": "/src/crypto/ledger_key/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub account_id: u16,
#[serde(with = "serde_public_key")]
pub public_key: PublicKey,
#[serde(with = "serde_public_key")]
pub master_key: PublicKey,
}
impl LedgerKey {
pub fn new(
name: String,
account_id: u16,
public_key: PublicKey,
master_key: Pub... | code_fim | hard | {
"lang": "rust",
"repo": "0xdeafbeef/nekoton",
"path": "/src/crypto/ledger_key/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[serde(with = "serde_public_key")]
pub master_key: PublicKey,
}
impl LedgerKey {
pub fn new(
name: String,
account_id: u16,
public_key: PublicKey,
master_key: PublicKey,
) -> Result<Self> {
Ok(Self {
name,
account_id,
... | code_fim | hard | {
"lang": "rust",
"repo": "0xdeafbeef/nekoton",
"path": "/src/crypto/ledger_key/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Newlifer/k1921vk01t-pac path: /src/nt_wdt/value.rs
#[doc = "Reader of register VALUE"]
pub type R = crate::R<u32, super::VALUE>;
<|fim_suffix|>pl R {
#[doc = "Bits 0:31"]
#[inline(always)]
pub fn wdtval(&self) -> WDTVAL_R {
WDTVAL_R::new((self.bits & 0xffff_ffff) as u32)
... | code_fim | medium | {
"lang": "rust",
"repo": "Newlifer/k1921vk01t-pac",
"path": "/src/nt_wdt/value.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> -> WDTVAL_R {
WDTVAL_R::new((self.bits & 0xffff_ffff) as u32)
}
}<|fim_prefix|>// repo: Newlifer/k1921vk01t-pac path: /src/nt_wdt/value.rs
#[doc = "Reader of register VALUE"]
pub type R = crate::R<u32, super::VALUE>;
<|fim_middle|>#[doc = "Reader of field `WDTVAL`"]
pub type WDTVAL_R = crate... | code_fim | medium | {
"lang": "rust",
"repo": "Newlifer/k1921vk01t-pac",
"path": "/src/nt_wdt/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut txt_again = String::new();
file_again.read_to_string(&mut txt_again).unwrap();
println!("{}", txt_again);
}<|fim_prefix|>// repo: nochat1205/DailySchedule_2020 path: /04-learn-rust-the-hard-way/ex15.rs
use std::env;
use std::io;
use std::fs::File;
use std::io::Write;
use std::pat... | code_fim | hard | {
"lang": "rust",
"repo": "nochat1205/DailySchedule_2020",
"path": "/04-learn-rust-the-hard-way/ex15.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nochat1205/DailySchedule_2020 path: /04-learn-rust-the-hard-way/ex15.rs
use std::env;
use std::io;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::io::prelude::*;
fn readln(s: &mut String) {
io::stdin().read_line(s).unwrap();
*s = s.trim().to_string();
}
<|fim_suff... | code_fim | medium | {
"lang": "rust",
"repo": "nochat1205/DailySchedule_2020",
"path": "/04-learn-rust-the-hard-way/ex15.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if ::std::env::var("RUST_LOG").is_err() {
::std::env::set_var("RUST_LOG", "actix_web=info");
}
env_logger::init();
let sys = actix::System::new("ws-example");
// load ssl keys
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
builder
... | code_fim | hard | {
"lang": "rust",
"repo": "pythoneer/examples",
"path": "/tls/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pythoneer/examples path: /tls/src/main.rs
#![allow(unused_variables)]
extern crate actix;
extern crate actix_web;
extern crate env_logger;
extern crate openssl;
use actix_web::{http, middleware, server, App, Error, HttpRequest, HttpResponse};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMeth... | code_fim | medium | {
"lang": "rust",
"repo": "pythoneer/examples",
"path": "/tls/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hermits-grove/hermitdb path: /src/encrypted_git_log.rs
use std::fmt::{self, Debug};
use std::marker::PhantomData;
/// An Encrypted Git Log
/// Implementation wraps the unencypted git log with an encryption layer.
use std::str::FromStr;
use std::string::ToString;
use serde_derive::{Deserialize, ... | code_fim | hard | {
"lang": "rust",
"repo": "hermits-grove/hermitdb",
"path": "/src/encrypted_git_log.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn push(&self, remote: &mut Self::Remote) -> Result<()> {
self.log.push(remote)
}
}
impl<A, C: CmRDT> Log<A, C>
where
C::Op: serde::Serialize + serde::de::DeserializeOwned,
A: Actor + serde::Serialize + serde::de::DeserializeOwned,
{
pub fn new(actor: A, repo: git2::Repository... | code_fim | hard | {
"lang": "rust",
"repo": "hermits-grove/hermitdb",
"path": "/src/encrypted_git_log.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hoangpq/minigame-rust path: /src/lib.rs
extern crate sdl2;
extern crate rand;
extern crate imgui;
extern crate stb_image;
#[cfg(feature = "hotload")]
extern crate dynamic_reload;
#[cfg(target_os="android")]
extern crate jni;
#[cfg(target_os="android")]
use jni::objects::JObject;
#[cfg(target_... | code_fim | hard | {
"lang": "rust",
"repo": "hoangpq/minigame-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> status = SDL_main(/*argc, argv*/);
/* Release the arguments. */
/*
for (i = 0; i < argc; ++i) {
SDL_free(argv[i]);
}
SDL_stack_free(argv);*/
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
/* exit(status); */
retur... | code_fim | hard | {
"lang": "rust",
"repo": "hoangpq/minigame-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yijie37/DaQiao path: /bridge/parity-ethereum/updater/src/types/version_info.rs
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/updater/src/types/version_info.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::fmt;
use semver::Version;
use ethereum_types::H160;
use version::raw_package_info;
use types::ReleaseTrack;
/// Version information of a particular release.
#[derive(Debug, Clone, PartialEq)]
pub struct VersionInfo {
/// The track on which it was released.
pub track: ReleaseTrack,
/// The ver... | code_fim | medium | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/updater/src/types/version_info.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>static INSPECT_NAME_FOR_OPTIONAL: &str = "optional";
impl TestState {
pub fn new() -> Arc<Mutex<TestState>> {
let mut integer_property_map: HashMap<u16, (String, i64)> = HashMap::new();
integer_property_map.insert(1, ("counter".to_string(), 0));
integer_property_map.insert(2, (... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/diagnostics/sampler/tests/test_component/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/diagnostics/sampler/tests/test_component/src/main.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 fidl_fuchsia_samplertestcontroller::*;
use fuc... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/diagnostics/sampler/tests/test_component/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: satylogin/leetcode path: /medium/1753. Maximum Score From Removing Stones.rs
use std::cmp::min;
impl Solution {
pub fn maximum_score(a: i32, b: i32, c: i32) -> i32 {
let mut v = vec![a, b, c];
v.sort();
let mut ans = v[1] - v[0];
<|fim_suffix|> x;
v[0] -=... | code_fim | medium | {
"lang": "rust",
"repo": "satylogin/leetcode",
"path": "/medium/1753. Maximum Score From Removing Stones.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x;
v[0] -= x;
v[1] -= x;
ans += min(v[0], v[1]);
ans
}
}<|fim_prefix|>// repo: satylogin/leetcode path: /medium/1753. Maximum Score From Removing Stones.rs
use std::cmp::min;
impl Solution {
pub fn maximum_score(a: i32, b: i32, c: i32) -> i32 {<|fim_middle|>
... | code_fim | medium | {
"lang": "rust",
"repo": "satylogin/leetcode",
"path": "/medium/1753. Maximum Score From Removing Stones.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>= &s);
println!("{}", if ans { "Yes" } else { "No" });
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc312/src/bin/a.rs
use proconio::input;
fn main() {
input! {
s: S<|fim_middle|>tring,
};
let ans = vec!["ACE", "BDF", "CEG", "DFA", "EGB", "FAC", "GB... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc312/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc312/src/bin/a.rs
use proconio::input;
fn main() {
input! {
s: S<|fim_suffix|>= &s);
println!("{}", if ans { "Yes" } else { "No" });
}<|fim_middle|>tring,
};
let ans = vec!["ACE", "BDF", "CEG", "DFA", "EGB", "FAC", "GB... | code_fim | medium | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc312/src/bin/a.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>, "EGB", "FAC", "GBD"]
.iter()
.any(|t| t == &s);
println!("{}", if ans { "Yes" } else { "No" });
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc312/src/bin/a.rs
use proconio::input;
fn main() {
input! {
s: S<|fim_middle|>tring,
};
l... | code_fim | easy | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc312/src/bin/a.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Iterate the transaction and add every item to the FP-Growth tree.
pub fn add_transaction(&mut self, transaction: Vec<T>) {
let mut cur_node = Rc::clone(&self.root_node.borrow());
for &item in transaction.iter() {
match cur_node.search(item) {
// Ther... | code_fim | hard | {
"lang": "rust",
"repo": "JmPotato/fp-growth-rs",
"path": "/src/tree.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JmPotato/fp-growth-rs path: /src/tree.rs
//! `Tree` implements the tree data struct in FP-Growth algorithm.
use std::{
cell::{Cell, RefCell},
collections::HashMap,
fmt::Debug,
rc::{Rc, Weak},
usize,
};
use crate::ItemType;
type RcNode<T> = Rc<Node<T>>;
type WeakRcNode<T> =... | code_fim | hard | {
"lang": "rust",
"repo": "JmPotato/fp-growth-rs",
"path": "/src/tree.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern {
fn GET_DMA_CONTROL_BLOCK() -> &'static dma::Descriptor;
}<|fim_prefix|>// repo: RustyGecko/emdrv path: /src/dmactrl.rs
use emlib::dma;
use core::intrinsics::transmute;
<|fim_middle|>pub fn dma_control_block() -> &'static dma::Descriptor {
unsafe { transmute(GET_DMA_CONTROL_BLOCK()) }
}
... | code_fim | medium | {
"lang": "rust",
"repo": "RustyGecko/emdrv",
"path": "/src/dmactrl.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustyGecko/emdrv path: /src/dmactrl.rs
use emlib::dma;
use core::intrinsics::transmute;
<|fim_suffix|>extern {
fn GET_DMA_CONTROL_BLOCK() -> &'static dma::Descriptor;
}<|fim_middle|>pub fn dma_control_block() -> &'static dma::Descriptor {
unsafe { transmute(GET_DMA_CONTROL_BLOCK()) }
}
... | code_fim | medium | {
"lang": "rust",
"repo": "RustyGecko/emdrv",
"path": "/src/dmactrl.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomc1998/rust-2d-game-engine path: /src/engine/renderer/mod.rs
extern crate glium;
use engine;
<|fim_suffix|>pub struct Renderer {
}
impl Renderer {
pub fn new() -> Renderer {
Renderer {}
}
pub fn render(engine: engine::Engine) {
}
}<|fim_middle|>/// Trait which defines something... | code_fim | medium | {
"lang": "rust",
"repo": "tomc1998/rust-2d-game-engine",
"path": "/src/engine/renderer/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub struct Renderer {
}
impl Renderer {
pub fn new() -> Renderer {
Renderer {}
}
pub fn render(engine: engine::Engine) {
}
}<|fim_prefix|>// repo: tomc1998/rust-2d-game-engine path: /src/engine/renderer/mod.rs
extern crate glium;
use engine;
<|fim_middle|>/// Trait which defines someth... | code_fim | medium | {
"lang": "rust",
"repo": "tomc1998/rust-2d-game-engine",
"path": "/src/engine/renderer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn render(engine: engine::Engine) {
}
}<|fim_prefix|>// repo: tomc1998/rust-2d-game-engine path: /src/engine/renderer/mod.rs
extern crate glium;
use engine;
/// Trait which defines something that can render to the screen
pub trait Renderable {
fn render(&self, x: f32, y: f32, w: f32, h: f32);... | code_fim | medium | {
"lang": "rust",
"repo": "tomc1998/rust-2d-game-engine",
"path": "/src/engine/renderer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> elements += cluster_size;
n += cluster_size;
};
}
(commands, elements)
}
impl<T: Arbitrary> Arbitrary for InsertRemoveClusteredEmpty<T> {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
// Delete 1/3 of the time to ensure some items in the structure
... | code_fim | hard | {
"lang": "rust",
"repo": "astahfrom/piecetable",
"path": "/benches/generators.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::collections::Bound::*;
let x = g.size();
let recipe: InsertRemoveScatteredEmpty<T> = Arbitrary::arbitrary(g);
let n = recipe.elements;
let mut ranges = Vec::with_capacity(n);
for _ in (0 .. x) {
let from_idx = g.gen_range(0, n-1);
... | code_fim | hard | {
"lang": "rust",
"repo": "astahfrom/piecetable",
"path": "/benches/generators.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astahfrom/piecetable path: /benches/generators.rs
#![allow(unused_attributes)]
#![feature(collections_bound)]
extern crate rand;
extern crate quickcheck;
use std::cmp;
use std::collections::Bound;
use self::rand::{Rng, SeedableRng, StdRng};
use self::quickcheck::{Arbitrary, Gen, StdGen};
#[al... | code_fim | hard | {
"lang": "rust",
"repo": "astahfrom/piecetable",
"path": "/benches/generators.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut vec = Vec::new();
for c in 1..5 {
let response = show_msg_user_input("hey", &format!("number {}", c), "ya");
vec.push(response);
}
for a in vec {
show_msgbox("look what you did", &a, "k");
}
0
}
#[lang = "eh_personality"]
#[no_mangle]
pub extern "C... | code_fim | hard | {
"lang": "rust",
"repo": "coolreader18/rsspire",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// This function may be needed based on the compilation target.
// #[lang = "eh_unwind_resume"]
// #[no_mangle]
// pub extern "C" fn rust_eh_unwind_resume() {}
#[lang = "panic_impl"]
#[no_mangle]
pub extern "C" fn rust_begin_panic(_info: &PanicInfo) -> ! {
core::intrinsics::abort()
}
// #[lang = "oo... | code_fim | hard | {
"lang": "rust",
"repo": "coolreader18/rsspire",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coolreader18/rsspire path: /src/main.rs
#![feature(
alloc_prelude,
lang_items,
core_intrinsics,
alloc_error_handler,
never_type,
start
)]
#![no_std]
#[macro_use]
extern crate alloc;
extern crate nspire_sys as sys;
mod cstr;
mod global_allocator;
use core::panic::PanicI... | code_fim | hard | {
"lang": "rust",
"repo": "coolreader18/rsspire",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ntains all necessary structures for REST communication.
//! Each endpoint has it's own module.
pub mod model;
pub mod options;
pub use model::*;
pub mod client;
mod apis;
mod requests;<|fim_prefix|>// repo: drodil/op-api-rust-sdk path: /src/lib.rs
//! Provides clients and data structures to work with
/... | code_fim | medium | {
"lang": "rust",
"repo": "drodil/op-api-rust-sdk",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drodil/op-api-rust-sdk path: /src/lib.rs
//! Provides clients and data structures to work with
//! [OP API](https://op-developer.fi)
//!
//! # Client
//!
//! All available API functions can be found from the *client* module.
/<|fim_suffix|> requested from the OP-Developer portal. For production ... | code_fim | medium | {
"lang": "rust",
"repo": "drodil/op-api-rust-sdk",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emerentius/ProjectEuler path: /p129_repunit_divisibility/src/main.rs
use euler_utils::num::pow_mod;
use euler_utils::prime::DivisorExt;
use euler_utils::prime::Phi32;
use num::Integer;
fn main() {
// Repunit of length k:
// (10^k - 1) / 9
//
// If it has to be divisible by `n`, ... | code_fim | hard | {
"lang": "rust",
"repo": "Emerentius/ProjectEuler",
"path": "/p129_repunit_divisibility/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let min_k = primes
.divisors(totient as usize)
.unwrap()
.into_iter()
.find(|&k| pow_mod(10, k as u32, (9 * n) as u64) == 1)
.unwrap();
if min_k > target_limit {
println!("n = {n}, min_k = {min_k}");
break;... | code_fim | hard | {
"lang": "rust",
"repo": "Emerentius/ProjectEuler",
"path": "/p129_repunit_divisibility/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heydabop/genetic path: /src/systems/rank_selection.rs
use crate::components::{Fitness, Score};
use crate::resources::{ResetInterval, Ticks};
use specs::{prelude::*, ReadExpect, ReadStorage, System, WriteStorage};
<|fim_suffix|> fn run(&mut self, (entities, scores, mut fitnesses, ticks, inter... | code_fim | hard | {
"lang": "rust",
"repo": "heydabop/genetic",
"path": "/src/systems/rank_selection.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, (entities, scores, mut fitnesses, ticks, interval): Self::SystemData) {
let interval = interval.0;
if ticks.get() % interval != 0 {
return;
}
// sort scores in ascending order and remove duplicates (so equal scores can tie and have equal fi... | code_fim | hard | {
"lang": "rust",
"repo": "heydabop/genetic",
"path": "/src/systems/rank_selection.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fluffware/helvar_cgi path: /src/fast_cgi/input_stream.rs
use bytes::BytesMut;
use core::task::{Context, Poll};
use core::pin::Pin;
use std::marker::Unpin;
use tokio::io::AsyncRead;
use bytes::Buf;
use super::records::Record;
use tokio::stream::{Stream};
use std::sync::Arc;
use tokio::sync::{Mute... | code_fim | hard | {
"lang": "rust",
"repo": "fluffware/helvar_cgi",
"path": "/src/fast_cgi/input_stream.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rt.block_on(async {
let blocks = vec![
Ok(Bytes::from_static(&[1u8,0x02, 0x00,0x03, 0x00])),
Ok(Bytes::from_static(&[0x05, 0x01, 0x00,
0x01,0x02])),
Ok(Bytes::from_static(&[0x03,0x04,0x05,
... | code_fim | hard | {
"lang": "rust",
"repo": "fluffware/helvar_cgi",
"path": "/src/fast_cgi/input_stream.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
use tokio::runtime::Runtime;
#[cfg(test)]
use bytes::Bytes;
#[cfg(test)]
use tokio::stream::{self,StreamExt};
#[test]
fn test_input_stream()
{
let mut rt = Runtime::new().unwrap();
rt.block_on(async {
let blocks = vec![
Ok(Bytes::from_static(&[1u8,0x02, 0x00,... | code_fim | hard | {
"lang": "rust",
"repo": "fluffware/helvar_cgi",
"path": "/src/fast_cgi/input_stream.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> "start"
}
async fn run_fn(&self, _matches: &ArgMatches<'_>) {
let result = run_start().await;
match result {
Ok(_) => {
println!("Successfully started instance");
}
Err(err) => {
println!("Failed to start... | code_fim | hard | {
"lang": "rust",
"repo": "guydunton/aws-container-builder",
"path": "/src/cli/start.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guydunton/aws-container-builder path: /src/cli/start.rs
use clap::{App, ArgMatches, SubCommand};
use super::CLICommand;
use crate::subcommands::run_start;
pub struct StartCommand {}
impl StartCommand {
pub fn new() -> Self {
StartCommand {}
}
}
#[async_trait::async_trait]
imp... | code_fim | medium | {
"lang": "rust",
"repo": "guydunton/aws-container-builder",
"path": "/src/cli/start.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ComputeShader {
/// Creates a new `ComputeShader` from a source code.
pub fn new(context:&Context, source: &str) -> Result<Self, String> {
let shader = Shader::new(context, gl::COMPUTE_SHADER, source)?;
Ok(Self{shader})
}
}<|fim_prefix|>// repo: notdanilo/gpu path: /src/c... | code_fim | medium | {
"lang": "rust",
"repo": "notdanilo/gpu",
"path": "/src/code/shaders/compute_shader.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: notdanilo/gpu path: /src/code/shaders/compute_shader.rs
use crate::prelude::*;
use crate::code::shaders::shader::Shader;
use crate::Context;
<|fim_suffix|>impl ComputeShader {
/// Creates a new `ComputeShader` from a source code.
pub fn new(context:&Context, source: &str) -> Result<Self... | code_fim | medium | {
"lang": "rust",
"repo": "notdanilo/gpu",
"path": "/src/code/shaders/compute_shader.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: therealprof/mkw41z path: /src/mtbdwt/mod.rs
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - MTB DWT Control Register"]
pub ctrl: CTRL,
_reserved0: [u8; 28usize],
#[doc = "0x20 - MTB_DWT Comparator Register"]
pub comp0: COMP,
#[doc = "0x24... | code_fim | hard | {
"lang": "rust",
"repo": "therealprof/mkw41z",
"path": "/src/mtbdwt/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>1;
#[doc = "MTB_DWT Trace Buffer Control Register"]
pub struct TBCTRL {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "MTB_DWT Trace Buffer Control Register"]
pub mod tbctrl;
#[doc = "Device Configuration Register"]
pub struct DEVICECFG {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "Device C... | code_fim | hard | {
"lang": "rust",
"repo": "therealprof/mkw41z",
"path": "/src/mtbdwt/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self { cache }
}
fn index_krate_features(&self, name: &str, version: &semver::Version) -> Option<&FeaturesMap> {
self.cache.get(name).and_then(|ik| {
ik.as_ref().and_then(|ik| {
ik.versions
.iter()
.find_map(|ikv|... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/krates",
"path": "/src/builder/index.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EmbarkStudios/krates path: /src/builder/index.rs
use std::collections::{BTreeMap, BTreeSet};
use tame_index::index::ComboIndexCache;
pub type FeaturesMap = BTreeMap<String, Vec<String>>;
#[derive(Clone)]
pub struct IndexKrateVersion {
pub version: semver::Version,
pub features: Feature... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/krates",
"path": "/src/builder/index.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The index entry features might not have the `dep:<crate>`
// used with weak features if the crate version was
// published with cargo <1.60.0 version, so we need to
// manually fix that up since we depend on that format
let missing_deps: Vec<_> = krate
.features
.ite... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/krates",
"path": "/src/builder/index.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: querry43/rust-pca9685 path: /src/lib.rs
#![crate_type = "lib"]
#![crate_name = "pca9685"]
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_middle|>extern crate i2cdev;
pub mod pwm;
| code_fim | easy | {
"lang": "rust",
"repo": "querry43/rust-pca9685",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: querry43/rust-pca9685 path: /src/lib.rs
#![crate_type = "lib"]
#![crate_name = "pca9685"]
extern crate i2cdev;
pub mod pwm;
<|fim_middle|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
| code_fim | easy | {
"lang": "rust",
"repo": "querry43/rust-pca9685",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub fn add(a: u8, b: u8) -> u8 {
unsafe { before(a, b) };
let c = a + b;
unsafe { after(c) };
return c;
}<|fim_prefix|>// repo: DrSensor/rollup-plugin-rust path: /test/fixtures/hook_function/lib.rs
extern {
fn before(a: u8, b: u8);
<|fim_middle|> fn after(c: u8);
}
| code_fim | easy | {
"lang": "rust",
"repo": "DrSensor/rollup-plugin-rust",
"path": "/test/fixtures/hook_function/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[no_mangle]
pub fn add(a: u8, b: u8) -> u8 {
unsafe { before(a, b) };
let c = a + b;
unsafe { after(c) };
return c;
}<|fim_prefix|>// repo: DrSensor/rollup-plugin-rust path: /test/fixtures/hook_function/lib.rs
extern {
fn before(a: u8, b: u8);
<|fim_middle|> fn after(c: u8);
| code_fim | easy | {
"lang": "rust",
"repo": "DrSensor/rollup-plugin-rust",
"path": "/test/fixtures/hook_function/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DrSensor/rollup-plugin-rust path: /test/fixtures/hook_function/lib.rs
extern {
fn before(a: u8, b: u8);
<|fim_suffix|>#[no_mangle]
pub fn add(a: u8, b: u8) -> u8 {
unsafe { before(a, b) };
let c = a + b;
unsafe { after(c) };
return c;
}<|fim_middle|> fn after(c: u8);
}
| code_fim | easy | {
"lang": "rust",
"repo": "DrSensor/rollup-plugin-rust",
"path": "/test/fixtures/hook_function/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: henryweng03/karl path: /karl-controller/src/dashboard/mod.rs
//! Controller dashboard.
use std::sync::{Arc, Mutex};
use rocket_contrib::serve::StaticFiles;
use crate::controller::Controller;
<|fim_suffix|>pub fn start(controller: Controller) {
let hosts = controller.scheduler.clone();
l... | code_fim | medium | {
"lang": "rust",
"repo": "henryweng03/karl",
"path": "/karl-controller/src/dashboard/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn start(controller: Controller) {
let hosts = controller.scheduler.clone();
let controller = Arc::new(Mutex::new(controller));
tokio::spawn(async move {
rocket::ignite()
.manage(hosts)
.manage(controller)
.mount("/", StaticFiles::from("../karl-ui/dist"))
... | code_fim | medium | {
"lang": "rust",
"repo": "henryweng03/karl",
"path": "/karl-controller/src/dashboard/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_path_fd(&self, key: &CStr, fd: RawFd) -> Result<()> {
fsconfig_set_fd(self.fs_fd, key, fd)
}
pub fn create(&self) -> Result<()> {
fsconfig_cmd_create(self.fs_fd)
}
pub fn reconfigure(&self) -> Result<()> {
fsconfig_cmd_reconfigure(self.fs_fd)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/mount-api",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mahkoh/mount-api path: /src/lib.rs
00000040;
#[allow(dead_code)]
pub const MOVE_MOUNT__MASK: c_uint = 0x00000077;
pub const FSOPEN_CLOEXEC: c_uint = 0x00000001;
pub const FSPICK_CLOEXEC: c_uint = 0x00000001;
pub const FSPICK_SYMLINK_NOFOLLOW: c_uint = 0x00000002;
pub co... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/mount-api",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxtnuk/gluesql path: /storages/memory-storage/src/transaction.rs
use {
super::MemoryStorage,
async_trait::async_trait,
gluesql_core::{
result::{Error, Result},
store::Transaction,
},
};
<|fim_suffix|> Err(Error::StorageMsg(
"[MemoryStorage] tr... | code_fim | medium | {
"lang": "rust",
"repo": "maxtnuk/gluesql",
"path": "/storages/memory-storage/src/transaction.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Err(Error::StorageMsg(
"[MemoryStorage] transaction is not supported".to_owned(),
))
}
async fn rollback(&mut self) -> Result<()> {
Ok(())
}
async fn commit(&mut self) -> Result<()> {
Ok(())
}
}<|fim_prefix|>// repo: maxtnuk/gluesql path: ... | code_fim | medium | {
"lang": "rust",
"repo": "maxtnuk/gluesql",
"path": "/storages/memory-storage/src/transaction.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn commit(&mut self) -> Result<()> {
Ok(())
}
}<|fim_prefix|>// repo: maxtnuk/gluesql path: /storages/memory-storage/src/transaction.rs
use {
super::MemoryStorage,
async_trait::async_trait,
gluesql_core::{
result::{Error, Result},
store::Transaction,
... | code_fim | hard | {
"lang": "rust",
"repo": "maxtnuk/gluesql",
"path": "/storages/memory-storage/src/transaction.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: klnusbaum/walletvalue path: /src/lib.rs
extern crate reqwest;
#[macro_use(Serialize, Deserialize)]
extern crate serde_derive;
extern crate serde_j<|fim_suffix|> Result};
pub mod config;
pub mod fetcher;
mod error;<|fim_middle|>son;
extern crate serde_yaml;
pub use error::{Error, | code_fim | easy | {
"lang": "rust",
"repo": "klnusbaum/walletvalue",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Result};
pub mod config;
pub mod fetcher;
mod error;<|fim_prefix|>// repo: klnusbaum/walletvalue path: /src/lib.rs
extern crate reqwest;
#[macro_use(Serialize, Deserial<|fim_middle|>ize)]
extern crate serde_derive;
extern crate serde_json;
extern crate serde_yaml;
pub use error::{Error, | code_fim | medium | {
"lang": "rust",
"repo": "klnusbaum/walletvalue",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: klnusbaum/walletvalue path: /src/lib.rs
extern crate reqwest;
#[macro_use(Serialize, Deserial<|fim_suffix|>son;
extern crate serde_yaml;
pub use error::{Error, Result};
pub mod config;
pub mod fetcher;
mod error;<|fim_middle|>ize)]
extern crate serde_derive;
extern crate serde_j | code_fim | easy | {
"lang": "rust",
"repo": "klnusbaum/walletvalue",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/notification/icon_sync.rs
pub struct IconSync {
props: crate::Props,
}
impl yew::Component for IconSync {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelude::Component... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/notification/icon_sync.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>get the current visibility of a repo")]
Visible {
#[structopt(name = "visible", required = true)]
repo: String,
},
}
pub fn initialize() -> Cli {
Cli::from_args()
}<|fim_prefix|>// repo: SachinMaharana/toggit path: /src/cli.rs
use structopt::StructOpt;
#[derive(Debug, Struct... | code_fim | hard | {
"lang": "rust",
"repo": "SachinMaharana/toggit",
"path": "/src/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SachinMaharana/toggit path: /src/cli.rs
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "toggit",
about = "toggle your github repository private or public"
)]
pub struct Cli {
#[structopt(short, long)]
pub verbose: bool,
#[structopt(subcommand)]
... | code_fim | medium | {
"lang": "rust",
"repo": "SachinMaharana/toggit",
"path": "/src/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Variable::Undefined => f.write_str("<<<undefined>>>"),
Variable::String(s) => f.write_str(s),
}
}
}<|fim_prefix|>// repo: iCodeIN/rsh path: /src/variable.rs
use std::fmt;
pub(crate) enum Variable {
Undefined,
String(String),
}
<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/rsh",
"path": "/src/variable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/rsh path: /src/variable.rs
use std::fmt;
pub(crate) enum Variable {
Undefined,
String(String),
}
<|fim_suffix|> match self {
Variable::Undefined => f.write_str("<<<undefined>>>"),
Variable::String(s) => f.write_str(s),
}
}
}<|fim_middl... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/rsh",
"path": "/src/variable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lancastr/rust-db-ip path: /src/error.rs
use rusqlite;
use csv;
#[derive(Fail, Debug)]
pub enum Error {
#[fail(display = "SQLite: {}", _0)]
Sqlite(rusqlite::Error),
#[fail(display = "Not found")]
NotFound,
#[fail(display = "Unknown")]
Unknown,
}
impl From<ru... | code_fim | hard | {
"lang": "rust",
"repo": "lancastr/rust-db-ip",
"path": "/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ConverterError::IO(error)
}
}
impl From<csv::Error> for ConverterError {
fn from(error: csv::Error) -> ConverterError {
ConverterError::CsvRecordGetting(error)
}
}
impl From<::std::net::AddrParseError> for ConverterError {
fn from(error: ::std::net::AddrParseEr... | code_fim | medium | {
"lang": "rust",
"repo": "lancastr/rust-db-ip",
"path": "/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ctfhacker/binja-rs path: /binja-sys/build.rs
// #[cfg(feature="build_time_bindings")]
// extern crate bindgen;
#[cfg(feature="build_time_bindings")]
use std::path::Path;
#[cfg(feature="build_time_bindings")]
use std::path::PathBuf;
#[cfg(feature="build_time_bindings")]
use std::process::Comma... | code_fim | hard | {
"lang": "rust",
"repo": "ctfhacker/binja-rs",
"path": "/binja-sys/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bindings = bindgen::Builder::default()
.header("wrapper.hpp")
.generate()
.expect("Unable to generate bindings");
let mut headings = String::from(r#"#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(improper_ctypes)]
"... | code_fim | medium | {
"lang": "rust",
"repo": "ctfhacker/binja-rs",
"path": "/binja-sys/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if parent.pointer_up() {
self.dragging = false;
}
if self.dragging {
let root_rectangle = parent.element_rectangle(root);
let pointer_position = parent.pointer_position();
self.position = (
... | code_fim | hard | {
"lang": "rust",
"repo": "kettle11/kui",
"path": "/src/widgets/drag.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kettle11/kui path: /src/widgets/drag.rs
use crate::ui::UIBuilder;
use crate::ElementHandle;
/// A helper for dragging elements
pub struct Drag {
pub root_and_element: Option<(ElementHandle, ElementHandle)>,
dragging: bool,
offset: (f32, f32),
position: (f32, f32),
}
impl Drag {... | code_fim | hard | {
"lang": "rust",
"repo": "kettle11/kui",
"path": "/src/widgets/drag.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jaxelr/RustTutorial path: /The Rust Book/09_03_to_panic_or_not/src/main.rs
use std::net::IpAddr;
fn main() {
//Technically valid scenario to call unwrap
let _home: IpAddr = "127.0.0.1".parse().unwrap();
<|fim_suffix|>impl Guess {
pub fn new(value: i32) -> Guess {
if value <... | code_fim | hard | {
"lang": "rust",
"repo": "Jaxelr/RustTutorial",
"path": "/The Rust Book/09_03_to_panic_or_not/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iThinkyouknow/exercism path: /saddle-points/src/lib.rs
use std::collections::HashMap;
fn get_indices_from_vector_based_on<F>(vec: &Vec<u64>, filter_fn: F) -> Vec<usize>
where
F: FnMut(&(usize, &u64)) -> bool,
{
vec.iter()
.enumerate()
.filter(filter_fn)
.map(|(ind... | code_fim | hard | {
"lang": "rust",
"repo": "iThinkyouknow/exercism",
"path": "/saddle-points/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let smallest = column_of_greatest.iter().min().unwrap();
get_indices_from_vector_based_on(&column_of_greatest, |(_, n)| *n == smallest)
}
pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> {
let mut smallest_num_index_col_cache: HashMap<usize, Vec<usize>> = HashMap::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "iThinkyouknow/exercism",
"path": "/saddle-points/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: trescommas/tinybacktest path: /src/strategy.rs
use crate::dataframe::DataFrame;
use crate::trade::Trade;
trait Strategy {
fn new() -> Self;
fn backtest(&self, df: &DataFrame); // change it to a result struct
fn take_profit(&self);
<|fim_suffix|> println!("Not implemented");
}... | code_fim | hard | {
"lang": "rust",
"repo": "trescommas/tinybacktest",
"path": "/src/strategy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Not implemented");
}
fn check_exit(&self) {
println!("Not implemented");
}
fn in_position(&self) {
println!("Not implemented");
}
/// The main backtest loop
///
fn backtest(&mut self, df: &DataFrame) -> f64 {
for (i, date) in df.time.ite... | code_fim | hard | {
"lang": "rust",
"repo": "trescommas/tinybacktest",
"path": "/src/strategy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("A = \n{:?}", a);
println!("B = \n{:?}", b);
println!("A*B = \n{:?}", c);
}<|fim_prefix|>// repo: quietlychris/gpuarray-rs path: /examples/small_matmul.rs
extern crate gpuarray as ga;
use ga::Context;
use ga::tensor::{Tensor, TensorMode};
use ga::array::Array;
fn main() {
let r... | code_fim | medium | {
"lang": "rust",
"repo": "quietlychris/gpuarray-rs",
"path": "/examples/small_matmul.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quietlychris/gpuarray-rs path: /examples/small_matmul.rs
extern crate gpuarray as ga;
use ga::Context;
use ga::tensor::{Tensor, TensorMode};
use ga::array::Array;
fn main() {
let ref ctx = Context::new();
let (m,n,k): (usize,usize,usize) = (2,3,1);
let a = Array::from_vec(vec![2,... | code_fim | hard | {
"lang": "rust",
"repo": "quietlychris/gpuarray-rs",
"path": "/examples/small_matmul.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (m,n,k): (usize,usize,usize) = (2,3,1);
let a = Array::from_vec(vec![2,3], (0..m*n).map(|x| x as f32).collect());
let b = Array::from_vec(vec![3,1], (0..n*k).map(|x| 1f32).collect());
let a_gpu = Tensor::from_array(ctx, &a, TensorMode::In);
let b_gpu = Tensor::from_array(ctx, &b,... | code_fim | medium | {
"lang": "rust",
"repo": "quietlychris/gpuarray-rs",
"path": "/examples/small_matmul.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(next, 28);
}
#[test]
fn solution() {
let triangles = triangular();
let next: u32 = triangles
.skip_while(|&n| factors(n).len() < 500)
.next()
.unwrap();
assert_eq!(next, 76576500);
}<|fim_prefix|>// repo: AndreasChristianson/project-euler-rust path: /te... | code_fim | medium | {
"lang": "rust",
"repo": "AndreasChristianson/project-euler-rust",
"path": "/tests/pe-12.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndreasChristianson/project-euler-rust path: /tests/pe-12.rs
extern crate project_euler_rust;
use project_euler_rust::factors::all_factors::factors;
use project_euler_rust::generators::triangular::triangular;
/*
<p>The sequence of triangle numbers is generated by adding the natural numbers. So... | code_fim | medium | {
"lang": "rust",
"repo": "AndreasChristianson/project-euler-rust",
"path": "/tests/pe-12.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.