text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> match body {
None => ParsedMetadata {
title: None,
description: None,
image: None,
},
Some(body) => parse_metadata_from_html(body),
}
}
async fn fetch_url(url: String) -> Option<String> {
let response = reqwest::get(&url).await;
... | code_fim | hard | {
"lang": "rust",
"repo": "astanzani/save-it",
"path": "/api/src/controllers/bookmarks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astanzani/save-it path: /api/src/controllers/bookmarks.rs
use actix::Addr;
use actix_web::{web, HttpResponse};
use cached::proc_macro::cached;
use mongodb::error::ErrorKind;
use scraper::Html;
use std::time;
use crate::helpers::metadata_parser::MetadataParser;
use crate::types::{BookmarkRequest... | code_fim | hard | {
"lang": "rust",
"repo": "astanzani/save-it",
"path": "/api/src/controllers/bookmarks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdisanti/hasselc path: /src/llir/binop/compare.rs
//
// Copyright 2017 hasselc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option.... | code_fim | hard | {
"lang": "rust",
"repo": "jdisanti/hasselc",
"path": "/src/llir/binop/compare.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
left: &Value,
right: &Value,
flag: BranchFlag,
set_value: bool,
) -> error::Result<()> {
let compare_block_ref = self.binop.run_builder.new_block().block_ref;
let clear_block_ref = self.binop.run_builder.new_block().block_ref;
... | code_fim | hard | {
"lang": "rust",
"repo": "jdisanti/hasselc",
"path": "/src/llir/binop/compare.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tree = RTree::bulk_load(feature_polygons);
let nearest = tree
.nearest_neighbor(&search_point)
.expect("There is a nearest polygon");
assert_eq!(
nearest.properties.as_ref().unwrap().get("STATEFP"),
Some(&serde_json::Value::Strin... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/geojson-rstar",
"path": "/tests/test_polygon_feature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/geojson-rstar path: /tests/test_polygon_feature.rs
extern crate geojson;
extern crate geojson_rstar;
extern crate rstar;
extern crate serde_json;
use geojson::GeoJson;
use geojson_rstar::PolygonFeature;
use rstar::RTree;
use std::convert::TryInto;
#[test]
fn test_try_from_polygon_succe... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/geojson-rstar",
"path": "/tests/test_polygon_feature.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let search_point = [-118.0, 34.0];
if let Ok(GeoJson::FeatureCollection(collection)) = polygon_geojson.parse::<GeoJson>() {
let feature_polygons = collection
.features
.into_iter()
.map(|f| f.try_into())
.collect::<Result<Vec<PolygonFeature>... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/geojson-rstar",
"path": "/tests/test_polygon_feature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn bar() {
baz();
dep::baz()
}
#[inline(never)]
fn baz() {
use d1::*;
use log::*;
let logger = TermLogger::new(LevelFilter::Info, Config::default());
dep::baz();
}<|fim_prefix|>// repo: Technolution/rustig path: /test_subjects/multi_dep/src/main.rs
// (C) COPYRIGHT 2018 TECHNOLU... | code_fim | hard | {
"lang": "rust",
"repo": "Technolution/rustig",
"path": "/test_subjects/multi_dep/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Technolution/rustig path: /test_subjects/multi_dep/src/main.rs
// (C) COPYRIGHT 2018 TECHNOLUTION BV, GOUDA NL
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses... | code_fim | hard | {
"lang": "rust",
"repo": "Technolution/rustig",
"path": "/test_subjects/multi_dep/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> acc = 0;
let mut ip = 0;
while !was_executed[ip] {
was_executed[ip] = true;
let (new_ip, new_acc) = instructions[ip].execute(ip, acc);
ip = new_ip;
acc = new_acc;
if ip >= was_executed.len() {
finished = t... | code_fim | hard | {
"lang": "rust",
"repo": "liona24/advent-of-code2020",
"path": "/src/day08.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liona24/advent-of-code2020 path: /src/day08.rs
use std::convert::{TryFrom, TryInto};
use crate::util::read_lines;
#[derive(Debug, Clone)]
enum Instruction {
Nop { arg: i64 },
Acc { inc: i64 },
Jmp { offset: i64 },
}
impl Instruction {
fn execute(&self, ip: usize, acc: i64) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "liona24/advent-of-code2020",
"path": "/src/day08.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: albertofem/carcasian path: /src/util/args.rs
extern crate argparse;
use self::argparse::{ArgumentParser, Store};
<|fim_suffix|> ap.refer(port).add_option(
&["-p", "--port"],
Store,
"8991"
);
ap.parse_args_or_exit();
}<|fim_middle|>/// We use this to parse program arguments
pub fn pars... | code_fim | hard | {
"lang": "rust",
"repo": "albertofem/carcasian",
"path": "/src/util/args.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ap.refer(port).add_option(
&["-p", "--port"],
Store,
"8991"
);
ap.parse_args_or_exit();
}<|fim_prefix|>// repo: albertofem/carcasian path: /src/util/args.rs
extern crate argparse;
use self::argparse::{ArgumentParser, Store};
<|fim_middle|>/// We use this to parse program arguments
pub fn pars... | code_fim | hard | {
"lang": "rust",
"repo": "albertofem/carcasian",
"path": "/src/util/args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ByteNacked/tetris-stm32 path: /src/pause.rs
use crate::TIMER_PAUSE;
use nb::block;
use stm32f1xx_hal::{prelude::*, time::Milli<|fim_suffix|>t());
} else {
panic!("No timer for pause!");
}
}
}<|fim_middle|>Seconds};
pub fn pause(mili: MilliSeconds) {
unsafe {
... | code_fim | medium | {
"lang": "rust",
"repo": "ByteNacked/tetris-stm32",
"path": "/src/pause.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t());
} else {
panic!("No timer for pause!");
}
}
}<|fim_prefix|>// repo: ByteNacked/tetris-stm32 path: /src/pause.rs
use crate::TIMER_PAUSE;
use nb::block;
use stm32f1xx_hal::{prelude::*, time::MilliSeconds};
pub fn pause(mili: MilliSeconds) {
unsafe {
if let... | code_fim | medium | {
"lang": "rust",
"repo": "ByteNacked/tetris-stm32",
"path": "/src/pause.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marier-nico/venv-wrapper path: /src/cli/commands/new_command.rs
use crate::{
cli::command::{Command, CommandResult},
config::config_data::Config,
virtualenv::{
creation::{
create_virtualenv, locate_interpreter::locate_interpreter,
python_version::Pytho... | code_fim | hard | {
"lang": "rust",
"repo": "marier-nico/venv-wrapper",
"path": "/src/cli/commands/new_command.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let python_version = PythonVersion::try_from_interpreter(&interpreter)?;
let venv = Virtualenv::new(
venv_name.to_string(),
config.venv_root.as_ref().unwrap().clone(),
python_version,
None,
&interpreter,
)?;
crea... | code_fim | hard | {
"lang": "rust",
"repo": "marier-nico/venv-wrapper",
"path": "/src/cli/commands/new_command.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bigdatakid/mongodb-demos path: /dataLake/data/restaurants/reviews-1-chunk.rs
"reviewerCity": "",
"reviewerState": "",
"reviewRating": 5
}, {
"reviewId": "",
"reviewDate": {
"$date": "2016-07-07T00:00:00.000Z"
},
"reviewTitle": "Great view!",
"reviewText": ... | code_fim | hard | {
"lang": "rust",
"repo": "bigdatakid/mongodb-demos",
"path": "/dataLake/data/restaurants/reviews-1-chunk.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> "reviewText": "Great hotel, will stay here anytime we are in the area. Only negative, was the cold water faucet in the bathroom had very little water pressure.",
"reviewerCity": "",
"reviewerState": "",
"reviewRating": 5
}, {
"reviewId": "",
"reviewDate": {
"$date": "2016-05-0... | code_fim | hard | {
"lang": "rust",
"repo": "bigdatakid/mongodb-demos",
"path": "/dataLake/data/restaurants/reviews-1-chunk.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tast::Stmt(pos.clone(), stmt_(s, env))
}
fn fun<'a>(f: &ast::Fun_, env: &'a Genv) -> tast::Fun_<'a> {
let ast = f.body.ast.iter().map(|x| stmt(x, env)).collect();
// We put empty vec below for all of those, since real conversion is unimplemented
assert!(f.tparams.is_empty());
assert!... | code_fim | hard | {
"lang": "rust",
"repo": "jackwiy/hhvm",
"path": "/hphp/hack/src/typing/typing.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|> tast::Fun_ {
span: f.span.clone(),
annotation: f.annotation,
mode: f.mode,
ret: f.ret.clone(),
name: f.name.clone(),
tparams: vec![],
where_constraints: f.where_constraints.clone(),
body: tast::FuncBody {
ast,
anno... | code_fim | hard | {
"lang": "rust",
"repo": "jackwiy/hhvm",
"path": "/hphp/hack/src/typing/typing.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackwiy/hhvm path: /hphp/hack/src/typing/typing.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
// Copyright (c) Facebook, Inc. and its affiliates.
//
// Thi... | code_fim | hard | {
"lang": "rust",
"repo": "jackwiy/hhvm",
"path": "/hphp/hack/src/typing/typing.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|>internal::Leaf::from_raw(data, include_bytes!("./extra.x509leaf"));
});<|fim_prefix|>// repo: micromaomao/ctclient path: /fuzz/fuzz_targets/leaf_parsing.rs
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate ctclient;
fuzz_target!(|data: &[u8]| {
let _ = ctclient::internal::Leaf::<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "micromaomao/ctclient",
"path": "/fuzz/fuzz_targets/leaf_parsing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: micromaomao/ctclient path: /fuzz/fuzz_targets/leaf_parsing.rs
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate ctclient;
fuzz_target!(|data: &[u8]| {
let _ = ctclient::internal::Leaf::<|fim_suffix|>internal::Leaf::from_raw(data, include_bytes!("./extra.x509leaf"));
});<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "micromaomao/ctclient",
"path": "/fuzz/fuzz_targets/leaf_parsing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> serde_json::to_string_pretty(&token_vec).unwrap()
}<|fim_prefix|>// repo: satyamakgec/fe path: /parser/src/tokenizer/wasm.rs
#![cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
use crate::tokenizer::tokenize as get_token_vec;
<|fim_middle|>/// Get a JSON serialized tokenization of the Fe... | code_fim | medium | {
"lang": "rust",
"repo": "satyamakgec/fe",
"path": "/parser/src/tokenizer/wasm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: satyamakgec/fe path: /parser/src/tokenizer/wasm.rs
#![cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
use crate::tokenizer::tokenize as get_token_vec;
<|fim_suffix|> serde_json::to_string_pretty(&token_vec).unwrap()
}<|fim_middle|>/// Get a JSON serialized tokenization of the Fe... | code_fim | medium | {
"lang": "rust",
"repo": "satyamakgec/fe",
"path": "/parser/src/tokenizer/wasm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BrooksPatton/twitch-overlay path: /src/main.rs
extern crate actix_web;
use actix_web::{server, App, HttpRequest, HttpResponse, fs};
fn starting_soon(_req: &HttpRequest) -> HttpResponse {
HttpResponse::Ok()
.body(include_str!("../static/index.html"))
}
fn break_time(_req: &HttpRequ... | code_fim | medium | {
"lang": "rust",
"repo": "BrooksPatton/twitch-overlay",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> server::new(|| {
App::new()
.handler("/static", fs::StaticFiles::new("./static").unwrap())
.resource("/", |r| r.f(starting_soon))
.resource("/break", |r| r.f(break_time))
.resource("/stream-ending", |r| r.f(stream_ending))
.resource("... | code_fim | medium | {
"lang": "rust",
"repo": "BrooksPatton/twitch-overlay",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielhenrymantilla/join-lazy-fmt-rs path: /src/lib.rs
#![cfg_attr(feature = "nightly",
feature(external_doc)
)]
#![cfg_attr(feature = "nightly",
doc(include = "../README.md")
)]
#"
)]
... | code_fim | easy | {
"lang": "rust",
"repo": "danielhenrymantilla/join-lazy-fmt-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::join::{Join, DisplayableJoin};
mod join;<|fim_prefix|>// repo: danielhenrymantilla/join-lazy-fmt-rs path: /src/lib.rs
#![cfg_attr(feature = "nightly",
feature(external_doc)
)]
#![cfg_attr(feature = "nightly",
doc(include = "../README.md")
)]
#![cfg_attr(not(feature = "nightly"),
... | code_fim | easy | {
"lang": "rust",
"repo": "danielhenrymantilla/join-lazy-fmt-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>> Result<DBPage, file_manager::Error> {
// TODO: Use BufferManager
let mut page = try!(DBPage::new(&dbfile.file_info, page_no));
match file_manager::load_page(dbfile, page_no, &mut page.page_data, create) {
Ok(()) => {
page.pin();
Ok(page)
}
Err(... | code_fim | hard | {
"lang": "rust",
"repo": "eugene-bulkin/nanodb-rust",
"path": "/src/storage/storage_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eugene-bulkin/nanodb-rust path: /src/storage/storage_manager.rs
//! This module contains utilities for general database file storage handling.
use std::fs::File;
use ::storage::{DBFile, DBPage, Pinnable, file_manager};
/// This method returns a database page to use, retrieving it from the buf... | code_fim | hard | {
"lang": "rust",
"repo": "eugene-bulkin/nanodb-rust",
"path": "/src/storage/storage_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(" nth = {}" , numbes_iter.nth(3 ).unwrap_or(&0u32) );
let mut numbes_iter = (&numbers).into_iter();
println!(" last = {}" , numbes_iter.last( ).unwrap_or(&0u32) );
let mut numbes_iter = (&numbers).into_iter();
println!(" position de 7 = {}" , numbes_iter.find(|m| m ... | code_fim | hard | {
"lang": "rust",
"repo": "halimabergaoui/rust-training-halima",
"path": "/consumed_iter/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: halimabergaoui/rust-training-halima path: /consumed_iter/src/main.rs
fn main() {
let numbers:Vec<u32> = vec![ 1 , 2 , 5 , 7 , 10];
let numbes_iter = (&numbers).into_iter();
println!(" sum = {}" , numbes_iter.sum::<u32>() );
let numbes_iter = (&numbers).into_iter();
... | code_fim | hard | {
"lang": "rust",
"repo": "halimabergaoui/rust-training-halima",
"path": "/consumed_iter/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A 3-dimensional translation.
pub type Translation3<N> = Translation<N, U3>;<|fim_prefix|>// repo: Standard-Cognition/nalgebra path: /src/geometry/translation_alias.rs
use base::dimension::{U2, U3};
<|fim_middle|>use geometry::Translation;
/// A 2-dimensional translation.
pub type Translation2<N> = ... | code_fim | medium | {
"lang": "rust",
"repo": "Standard-Cognition/nalgebra",
"path": "/src/geometry/translation_alias.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Standard-Cognition/nalgebra path: /src/geometry/translation_alias.rs
use base::dimension::{U2, U3};
<|fim_suffix|>/// A 2-dimensional translation.
pub type Translation2<N> = Translation<N, U2>;
/// A 3-dimensional translation.
pub type Translation3<N> = Translation<N, U3>;<|fim_middle|>use geo... | code_fim | easy | {
"lang": "rust",
"repo": "Standard-Cognition/nalgebra",
"path": "/src/geometry/translation_alias.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dbcfd/rs-shutdown path: /src/lib.rs
///! Shutdown
///!
///! Provides a signal handler which by default will listen to shutdown type signals
///! (e.g. SIGINT, SIGHUP, SIGTERM, SIGQUIT) and provide either a future that completes with the
///! signal or invoke a callback to provide you with the re... | code_fim | hard | {
"lang": "rust",
"repo": "dbcfd/rs-shutdown",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let signal_handler = SignalHandler::new_with_signals(&signals);
let sig = tokio::executor::current_thread::block_on_all(signal_handler);
if let Ok(mut current_signal_raised) = thread_signal_raised.lock() {
if *current_signal_raised == 1... | code_fim | hard | {
"lang": "rust",
"repo": "dbcfd/rs-shutdown",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(res, libc::SIGUSR2);
assert_eq!(*signal_raised.lock().unwrap(), 2);
}
#[test]
fn test_watch() {
let _ = env_logger::try_init();
let mut rt = tokio::runtime::Runtime::new().expect("No runtime");
let (tx, rx) = futures::sync::oneshot::channe... | code_fim | hard | {
"lang": "rust",
"repo": "dbcfd/rs-shutdown",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SickanK/discord-bot-rust path: /src/discord/interface/message/message_flags.rs
bitflags! {
pub struct MessageFlags: u64 {
const NONE = 0;
const CROSSPOSTED = 1 << 0;
const IS_CROSSPOST = 1 << 1;
const SUPPRESS_EMBEDS = 1 << 2;
const SOURCE_MESSAGE_DELETED = 1 << 3;
const URGENT = 1 << 4;
... | code_fim | hard | {
"lang": "rust",
"repo": "SickanK/discord-bot-rust",
"path": "/src/discord/interface/message/message_flags.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl serde::ser::Serialize for MessageFlags {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_u64(self.bits())
}
}
impl<'de> serde::de::Deserialize<'de> for MessageFlags {
fn deserialize<D>(d... | code_fim | hard | {
"lang": "rust",
"repo": "SickanK/discord-bot-rust",
"path": "/src/discord/interface/message/message_flags.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
E: serde::de::Error,
{
match MessageFlags::from_bits(v) {
Some(f) => Ok(f),
None => Err(E::custom("Failed to convert bits to flag")),
}
}
}
impl serde::ser::Serialize for MessageFlags {
fn serialize<S>(&self, serializer: S) ... | code_fim | medium | {
"lang": "rust",
"repo": "SickanK/discord-bot-rust",
"path": "/src/discord/interface/message/message_flags.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn ensure_array_capacity(&mut self, num_batch_items: i32) {
let needed_capacity = 6 * num_batch_items;
if needed_capacity <= self.index.capacity() as i32 {
// Short circuit out of here because we have enough capacity.
return;
}
let info: &st... | code_fim | hard | {
"lang": "rust",
"repo": "delaneyj/minigame-rust",
"path": "/src/spritebatcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: delaneyj/minigame-rust path: /src/spritebatcher.rs
use graphicsdevice::GraphicsDevice;
use spritebatchitem::SpriteBatchItem;
use spritebatch::SpriteSortMode;
use renderstate::RenderState;
use texture::Texture;
use log::Log;
use std::i32;
use std::rc::Rc;
use vertexpositioncolortexture::VertexPos... | code_fim | hard | {
"lang": "rust",
"repo": "delaneyj/minigame-rust",
"path": "/src/spritebatcher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_c_translate() {
let result = CCmdResult {
dest: Some("MD".into()),
comp: Some("M-1".into()),
jump: Some("JMP".into()),
};
assert_eq!(Coder::translate_c(&result).unwrap(), "10111110010111");
}
}<|fim_prefix|>// repo: te... | code_fim | hard | {
"lang": "rust",
"repo": "tenheadedlion/nand2tetris",
"path": "/projects/06/assembler/src/model/coder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tenheadedlion/nand2tetris path: /projects/06/assembler/src/model/coder.rs
use super::base::*;
use super::error::*;
use super::parser::*;
use std::collections::HashMap;
pub struct Coder {}
impl Coder {
pub fn translate_a<'a>(
map: &'a mut HashMap<String, usize>,
varmem: &'a m... | code_fim | hard | {
"lang": "rust",
"repo": "tenheadedlion/nand2tetris",
"path": "/projects/06/assembler/src/model/coder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Options {
pub fn execute(self) -> anyhow::Result<ExitCode> {
let mut sgx_key = File::open(&self.key).context("Failed to open SGX key file")?;
let mut buffer = String::new();
sgx_key.read_to_string(&mut buffer)?;
let sgx_key = RsaPrivateKey::from_pkcs1_pem(&buffer).... | code_fim | hard | {
"lang": "rust",
"repo": "enarx/enarx",
"path": "/src/cli/key/sgx/digest.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: enarx/enarx path: /src/cli/key/sgx/digest.rs
// SPDX-License-Identifier: Apache-2.0
use std::fmt::Debug;
use std::fs::File;
use std::io::prelude::*;
use std::io::stdout;
use std::process::ExitCode;
use anyhow::Context;
use camino::Utf8PathBuf;
use clap::Args;
use rsa::pkcs1::DecodeRsaPrivateKe... | code_fim | hard | {
"lang": "rust",
"repo": "enarx/enarx",
"path": "/src/cli/key/sgx/digest.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = sgx_key_digest(&sgx_key)?;
let out = hex::encode(res);
if let Some(path) = self.out {
let mut file = File::create(path)?;
file.write_all(out.as_bytes())?;
} else {
stdout().write_all(out.as_bytes())?;
}
Ok(Exit... | code_fim | hard | {
"lang": "rust",
"repo": "enarx/enarx",
"path": "/src/cli/key/sgx/digest.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BobuSumisu/knowit19 path: /luke17/src/main.rs
struct TriangularNumberIter {
n: u64,
i: u64,
}
fn triangular_numbers() -> TriangularNumberIter {
TriangularNumberIter { n: 0, i: 0 }
}
impl Iterator for TriangularNumberIter {
type Item = u64;
<|fim_suffix|> let num_digits = nu... | code_fim | hard | {
"lang": "rust",
"repo": "BobuSumisu/knowit19",
"path": "/luke17/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("{}", solution(1_000_000));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_solution() {
assert_eq!(solution(1_000_000), 74);
}
}<|fim_prefix|>// repo: BobuSumisu/knowit19 path: /luke17/src/main.rs
struct TriangularNumberIter {
n: u64,
i... | code_fim | hard | {
"lang": "rust",
"repo": "BobuSumisu/knowit19",
"path": "/luke17/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FNSdev/gitrello-github-integration-service path: /src/middlewares/authentication.rs
use std::pin::Pin;
use std::task::{Context, Poll};
use actix_service::{Service, Transform};
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error, HttpMessage};
use futures::future::{ok, Ready};
use f... | code_fim | hard | {
"lang": "rust",
"repo": "FNSdev/gitrello-github-integration-service",
"path": "/src/middlewares/authentication.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(decoded_claims.is_some());
assert_eq!(decoded_claims.unwrap().user_id, 42);
}
#[test]
fn test_get_claims_invalid_token() {
use jsonwebtoken::{encode, Header, EncodingKey};
let claims = Claims {user_id: 42};
let token = encode(&Header::default(), &claims, &EncodingKey::from_se... | code_fim | hard | {
"lang": "rust",
"repo": "FNSdev/gitrello-github-integration-service",
"path": "/src/middlewares/authentication.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0435_non_overlapping_intervals/greedy.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn erase_overlap_intervals(intervals: Vec<Vec<i32>>)... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0435_non_overlapping_intervals/greedy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> intervals.sort_unstable_by_key(|x| x[1]);
let mut last_finish_time = i32::MIN;
let k = intervals
.iter()
.filter(|x| {
let r = x[0] >= last_finish_time;
if r {
last_finish_time = x[1];
}
... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0435_non_overlapping_intervals/greedy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> solvers.extend(year2020::solvers(prefix.clone() + "year2020/"));
solvers
}<|fim_prefix|>// repo: benfrankel/aoc path: /src/aoc/mod.rs
use std::collections::HashMap;
pub mod year2019;
pub mod year2020;
pub fn solvers(prefix: String) -> HashMap<String, crate::Solver> {
let mut solvers = Hash<... | code_fim | medium | {
"lang": "rust",
"repo": "benfrankel/aoc",
"path": "/src/aoc/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benfrankel/aoc path: /src/aoc/mod.rs
use std::collections::HashMap;
pub mod year2019;
pub mod year2020;
pub fn solve<|fim_suffix|> solvers.extend(year2020::solvers(prefix.clone() + "year2020/"));
solvers
}<|fim_middle|>rs(prefix: String) -> HashMap<String, crate::Solver> {
let mut s... | code_fim | medium | {
"lang": "rust",
"repo": "benfrankel/aoc",
"path": "/src/aoc/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &*self {
ErrorKind::MissingField { typ, field } => {
write!(f, "Missing field '{}' in type '{}'", field, typ)
}
ErrorKind::InvalidLogType(s) => wri... | code_fim | medium | {
"lang": "rust",
"repo": "crides/sched-test",
"path": "/src/api/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crides/sched-test path: /src/api/error.rs
use rlua::prelude::*;
use std::fmt;
#[derive(Debug)]
pub struct APIError {
function: String,
message: String,
}
#[derive(Debug)]
pub struct Error {
pub method: String,
pub kind: ErrorKind,
}
impl std::convert::Into<LuaError> for Error ... | code_fim | hard | {
"lang": "rust",
"repo": "crides/sched-test",
"path": "/src/api/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Palpatineli/pi-ffi path: /src/lib.rs
#![allow(dead_code)]
extern crate num;
pub mod gpio;
pub mod pwm;
pub mod st;
pub mod spi;
pub mod i2c;
#[repr(u8)]
#[derive(Copy, Clone)]
pub enum Polarity {
High = 1,
Low = 0,
}
#[repr(u8)]
#[derive(Copy, Clone)]
pub enum PUDControl {
Off = 0b00,
... | code_fim | hard | {
"lang": "rust",
"repo": "Palpatineli/pi-ffi",
"path": "/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
mod ffi {
#[link(name = "bcm2835")]
extern "C" {
pub fn bcm2835_init() -> i32;
pub fn bcm2835_close() -> i32;
pub fn bcm2835_set_debug(debug: u8);
pub fn bcm2835_gpio_fsel(pin: u8, mode: u8);
pub fn bcm2835_gpio_set(pin: u8);
pub fn bcm2835_gpio_clr(pin: u8);
pub... | code_fim | hard | {
"lang": "rust",
"repo": "Palpatineli/pi-ffi",
"path": "/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Clock {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let (hrs, mnts) = Self::m_to_hm(self.0);
write!(f, "{:02}:{:02}", hrs, mnts)
}
}
impl Clock {
pub fn new(hours: i32, minutes: i32) -> Self {
Clock(Self::hm_to_m(hours, minutes))
}
... | code_fim | medium | {
"lang": "rust",
"repo": "pedantic79/Exercism",
"path": "/rust/clock/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pedantic79/Exercism path: /rust/clock/src/lib.rs
use std::convert::TryInto;
use std::fmt;
#[derive(Debug, Eq, PartialEq)]
pub struct Clock(u16);
const MINUTES_PER_DAY: i32 = 60 * 24;
impl fmt::Display for Clock {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let (hrs, mnt... | code_fim | medium | {
"lang": "rust",
"repo": "pedantic79/Exercism",
"path": "/rust/clock/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: longfangsong/tiny-nom path: /src/digit.rs
use crate::many0::many0;
use crate::recognize::recognize;
use crate::result::{ErrorKind, IResult};
use crate::tuple::tuple;
pub fn digit(input: &str) -> IResult<&str, char> {
if let Some(first) = input.chars().next() {
if first.is_digit(10) ... | code_fim | medium | {
"lang": "rust",
"repo": "longfangsong/tiny-nom",
"path": "/src/digit.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test_case = digit("123");
assert_eq!(test_case, Ok(("23", '1')));
let test_case = digit("abc");
assert!(test_case.is_err());
}
pub fn digit0(input: &str) -> IResult<&str, &str> {
recognize(many0(digit))(input)
}
#[test]
fn test_digit0() {
let test_case = digit0("123");
as... | code_fim | medium | {
"lang": "rust",
"repo": "longfangsong/tiny-nom",
"path": "/src/digit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_digit1() {
let test_case = digit1("123");
assert_eq!(test_case, Ok(("", "123")));
let test_case = digit1("abc");
assert!(test_case.is_err());
}<|fim_prefix|>// repo: longfangsong/tiny-nom path: /src/digit.rs
use crate::many0::many0;
use crate::recognize::recognize;
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "longfangsong/tiny-nom",
"path": "/src/digit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: minioin/uhid-virt path: /src/uhid_device.rs
use std::convert::TryFrom;
use std::fs::{File, OpenOptions};
use std::io::{self, prelude::*};
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;
use crate::codec::*;
pub struct UHIDDevice<T: Read + Write> {
handle: T,
}
/// Contains inf... | code_fim | hard | {
"lang": "rust",
"repo": "minioin/uhid-virt",
"path": "/src/uhid_device.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fun = FunctionIdent {
module: Ident::from_str("woo"),
name: Ident::from_str("nth_root"),
arity: 2,
};
let mut vm = VMState::new();
vm.add_builtin_modules();
vm.add_erlang_module(eir_mod);
assert!(vm.call(&fun, &[2.into(), 2.into()]).unwrap().as_boolean... | code_fim | hard | {
"lang": "rust",
"repo": "eirproject/eir",
"path": "/libeir_tests/src/control_flow/nth_root.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pass_manager = PassManager::default();
pass_manager.run(&mut eir_mod);
let fun = FunctionIdent {
module: Ident::from_str("woo"),
name: Ident::from_str("nth_root"),
arity: 2,
};
let mut vm = VMState::new();
vm.add_builtin_modules();
vm.add_erlan... | code_fim | hard | {
"lang": "rust",
"repo": "eirproject/eir",
"path": "/libeir_tests/src/control_flow/nth_root.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eirproject/eir path: /libeir_tests/src/control_flow/nth_root.rs
use std::rc::Rc;
use crate::{lower, write_dot};
use libeir_intern::{Ident, Symbol};
use libeir_ir::FunctionIdent;
use libeir_passes::PassManager;
use libeir_syntax_erl::ParseConfig;
use libeir_interpreter::{ErlEq, Term, VMState};... | code_fim | hard | {
"lang": "rust",
"repo": "eirproject/eir",
"path": "/libeir_tests/src/control_flow/nth_root.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xfbs/matasano path: /src/hex.rs
use std::char::from_digit;
/// Iterator adaptor that hex-encodes data.
pub struct ToHexIter<T: Iterator> {
input: T,
store: Option<char>
}
impl<T: Iterator> ToHexIter<T> {
/// Create a new `ToHexIter` from an `Iterator`.
pub fn new(iter: T) -> Se... | code_fim | hard | {
"lang": "rust",
"repo": "xfbs/matasano",
"path": "/src/hex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Iterator<Item=u8>> Iterator for ToHexIter<T> {
type Item = char;
fn next(&mut self) -> Option<Self::Item> {
let store = self.store;
match store {
Some(val) => {
self.store = None;
Some(val)
},
None => {
... | code_fim | hard | {
"lang": "rust",
"repo": "xfbs/matasano",
"path": "/src/hex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match resolver.resolve_record::<Txt>(&args[1]) {
Ok(records) => {
for txt in records {
let data = match str::from_utf8(&txt.data) {
Ok(string) => string,
Err(e) => {
println!("Failed to decode UTF8 data... | code_fim | hard | {
"lang": "rust",
"repo": "sunfishcode/sync-resolve",
"path": "/examples/lookup_txt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunfishcode/sync-resolve path: /examples/lookup_txt.rs
use std::env::args;
use std::str;
use sync_resolve::record::Txt;
use sync_resolve::{DnsConfig, DnsResolver};
fn main() {
let args = args().collect::<Vec<_>>();
if args.len() != 2 {
println!("Usage: {} <name>", args[0]);
... | code_fim | hard | {
"lang": "rust",
"repo": "sunfishcode/sync-resolve",
"path": "/examples/lookup_txt.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set SoC and memory offsets based on model
match model {
Model::RaspberryPiA
| Model::RaspberryPiAPlus
| Model::RaspberryPiBRev1
| Model::RaspberryPiBRev2
| Model::RaspberryPiBPlus
| Model::RaspberryPiComputeModule
... | code_fim | hard | {
"lang": "rust",
"repo": "jacobrosenthal/rppal",
"path": "/src/system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobrosenthal/rppal path: /src/system.rs
// Copyright (c) 2017-2019 Rene van der Meer
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, inclu... | code_fim | hard | {
"lang": "rust",
"repo": "jacobrosenthal/rppal",
"path": "/src/system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lineCode/garnet path: /bin/wlancfg/src/main.rs
// Copyright 2018 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.
#![deny(warnings)]
extern crate failure;
extern crate fidl;
extern crate fidl_fuchs... | code_fim | medium | {
"lang": "rust",
"repo": "lineCode/garnet",
"path": "/bin/wlancfg/src/main.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cfg = Config::load_from_file()?;
let mut executor = async::Executor::new().context("error creating event loop")?;
let wlan_svc = app::client::connect_to_service::<DeviceServiceMarker>()
.context("failed to connect to device service")?;
let (watcher_proxy, watcher_server_end) ... | code_fim | medium | {
"lang": "rust",
"repo": "lineCode/garnet",
"path": "/bin/wlancfg/src/main.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", number);
}
// Increment counter
number += 1;
}
}<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /test30.rs
fn main() {
// A counter variable
let mut number = 0;
while number < 101 {
if n<|fim_middle|>umber % 10 == 15 {
... | code_fim | medium | {
"lang": "rust",
"repo": "TianTianForever/Rust-Tutorial",
"path": "/test30.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /test30.rs
fn main() {
// A counter variable
let mut number = 0;
while number < 101 {
if n<|fim_suffix|> println!("{}", number);
}
// Increment counter
number += 1;
}
}<|fim_middle|>umber % 10 == 15 {
... | code_fim | medium | {
"lang": "rust",
"repo": "TianTianForever/Rust-Tutorial",
"path": "/test30.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aguss787/doraemon path: /src/core/url_shortener/read.rs
use actix_web::web::{Data, Query};
use actix_web::{HttpRequest, HttpResponse, Result};
use serde::{Deserialize, Serialize};
use crate::app_data::AppData;
use crate::core::url_shortener::utils::authenticate;
use crate::database::handler::ur... | code_fim | hard | {
"lang": "rust",
"repo": "aguss787/doraemon",
"path": "/src/core/url_shortener/read.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(HttpResponse::Ok().json(GetUrlResponse {
urls,
page,
per_page,
total,
}))
}
pub async fn handle_one(data: Data<AppData>, req: HttpRequest) -> Result<HttpResponse> {
let token = authenticate(&data, &req)?;
let key = String::from(req.match_info().get("key"... | code_fim | hard | {
"lang": "rust",
"repo": "aguss787/doraemon",
"path": "/src/core/url_shortener/read.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "postgres")]
impl Clone for DieselAdminServiceStore<diesel::pg::PgConnection> {
fn clone(&self) -> Self {
Self {
connection_pool: self.connection_pool.clone(),
}
}
}<|fim_prefix|>// repo: sbshrey/splinter path: /libsplinter/src/admin/store/diesel/mod.rs... | code_fim | hard | {
"lang": "rust",
"repo": "sbshrey/splinter",
"path": "/libsplinter/src/admin/store/diesel/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbshrey/splinter path: /libsplinter/src/admin/store/diesel/mod.rs
// Copyright 2018-2020 Cargill Incorporated
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//... | code_fim | medium | {
"lang": "rust",
"repo": "sbshrey/splinter",
"path": "/libsplinter/src/admin/store/diesel/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dorucioclea/omics path: /catalogue/infrastructure/service/publication_service.rs
use std::sync::Arc;
use async_trait::async_trait;
use common::result::Result;
use crate::domain::catalogue::{Author, Category, Publication, PublicationService, Statistics};
use publishing::domain::author::AuthorR... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/omics",
"path": "/catalogue/infrastructure/service/publication_service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Publication::new(
publication.base().id().to_string(),
Author::new(
author.base().id().value(),
author.username(),
author.name(),
author.lastname(),
self.publication_repo
... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/omics",
"path": "/catalogue/infrastructure/service/publication_service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ormat!("NO: {:?}", err)
} else {
"YES".to_string()
}
);
}
Err(e) => {
eprintln!("Failed to parse ROM: {:?}", e);
std::process::exit(-1);
}
}
}<|fim_prefix|>// repo: MarkMcCaskey/gameboy-rom-... | code_fim | hard | {
"lang": "rust",
"repo": "MarkMcCaskey/gameboy-rom-parser",
"path": "/src/bin/gb2json.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarkMcCaskey/gameboy-rom-parser path: /src/bin/gb2json.rs
use std::io::Read;
fn main() {
let mut args = std::env::args();
args.next().unwrap();
let rom_file_path = if let Some(arg) = args.next() {
arg
} else {
eprintln!("Must supply a path to a gameboy ROM");
... | code_fim | hard | {
"lang": "rust",
"repo": "MarkMcCaskey/gameboy-rom-parser",
"path": "/src/bin/gb2json.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tm.fg(hash_color(&login)).unwrap();
print!("{}", login);
tm.fg(term::color::WHITE).unwrap();
println!(", {}",rest);
},
None => {
tm.fg(term::color::WHITE).unwrap();
println!("{}", rec.m... | code_fim | hard | {
"lang": "rust",
"repo": "gloryman/btce-trollbox-rs",
"path": "/src/lib/console.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gloryman/btce-trollbox-rs path: /src/lib/console.rs
extern crate term;
use std::sync::mpsc::Sender;
use std::sync::mpsc::Receiver;
use super::regex::Regex;
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
use super::{TicksList, TickType, ChatMessage, };
static COL... | code_fim | hard | {
"lang": "rust",
"repo": "gloryman/btce-trollbox-rs",
"path": "/src/lib/console.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RpcApi for OceanClient {
fn call<T: for<'b> serde::de::Deserialize<'b>>(
&self,
cmd: &str,
args: &[serde_json::Value],
) -> ocean_rpc::Result<T> {
for _ in 0..OCEAN_CLIENT_RETRY_ATTEMPTS {
match self.client.call(cmd, args) {
Ok(ret) ... | code_fim | medium | {
"lang": "rust",
"repo": "commerceblock/coordinator",
"path": "/src/util/ocean.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: commerceblock/coordinator path: /src/util/ocean.rs
//! # Ocean
//!
//! Ocean node communication implementations
use ocean_rpc::{Auth, Client, RpcApi};
use crate::error::Result;
/// Extension of ocean_rpc::Client that retries rpc calls
pub struct OceanClient {
/// Ocean rpc client instance... | code_fim | medium | {
"lang": "rust",
"repo": "commerceblock/coordinator",
"path": "/src/util/ocean.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>&self) -> READYUSR7_R {
READYUSR7_R::new(((self.bits >> 7) & 0x01) != 0)
}
#[doc = "Bit 8 - Ready User for Channel 8"]
#[inline(always)]
pub fn readyusr8(&self) -> READYUSR8_R {
READYUSR8_R::new(((self.bits >> 8) & 0x01) != 0)
}
#[doc = "Bit 9 - Ready User for Chann... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd51g19a/src/evsys/readyusr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd51g19a/src/evsys/readyusr.rs
#[doc = "Reader of register READYUSR"]
pub type R = crate::R<u32, super::READYUSR>;
#[doc = "Reader of field `READYUSR0`"]
pub type READYUSR0_R = crate::R<bool, bool>;
#[doc = "Reader of field `READYUSR1`"]
pub type READYUSR1_R = crate... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd51g19a/src/evsys/readyusr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>eenPoint2D;
pub use complex::point2d::*;<|fim_prefix|>// repo: ricardopieper/rust-billiards path: /src/complex/mod.rs
mod complex;
mod point2d;
mod screen_po<|fim_middle|>int2d;
pub use complex::complex::Complex;
pub use complex::screen_point2d::Scr | code_fim | medium | {
"lang": "rust",
"repo": "ricardopieper/rust-billiards",
"path": "/src/complex/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ricardopieper/rust-billiards path: /src/complex/mod.rs
mod complex;
mod point2d;
mod screen_point2d;
pub use complex::complex::Compl<|fim_suffix|>eenPoint2D;
pub use complex::point2d::*;<|fim_middle|>ex;
pub use complex::screen_point2d::Scr | code_fim | easy | {
"lang": "rust",
"repo": "ricardopieper/rust-billiards",
"path": "/src/complex/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ex;
pub use complex::screen_point2d::ScreenPoint2D;
pub use complex::point2d::*;<|fim_prefix|>// repo: ricardopieper/rust-billiards path: /src/complex/mod.rs
mod complex;
mod point2d;
mod screen_po<|fim_middle|>int2d;
pub use complex::complex::Compl | code_fim | easy | {
"lang": "rust",
"repo": "ricardopieper/rust-billiards",
"path": "/src/complex/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jasmaa/bandori-puyopuyo path: /src/lib.rs
mod utils;
mod engine;
pub use engine::enums::Affiliation;
pub use engine::enums::Dire<|fim_suffix|>eature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_... | code_fim | medium | {
"lang": "rust",
"repo": "jasmaa/bandori-puyopuyo",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>eature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;<|fim_prefix|>// repo: jasmaa/bandori-puyopuyo path: /src/lib.rs
mod utils;
mod engine;
pub use engine::enums::Affiliation;
pub u... | code_fim | medium | {
"lang": "rust",
"repo": "jasmaa/bandori-puyopuyo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
println!("\tPOOL STATE
\t{}:{}
\t{}:{}\n", pool.token1.symbol, pool.token1_amount, pool.token2.symbol, pool.token2_amount);
loop {
println!("swap {} for {}? ({{amount}}/n)", pool.token1.symbol, pool.token2.symbol);
let line = getLine();
match ... | code_fim | hard | {
"lang": "rust",
"repo": "w1r2p1/RustUniswapSimulator",
"path": "/src/main.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.