text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: cetra3/tmq path: /src/socket_builder.rs
use crate::{FromZmqSocket, TmqError};
use zmq::{Context, SocketType};
macro_rules! setter {
($name: ident, $type: ty, $doc: expr) => {
#[doc=$doc]
pub fn $name(mut self, value: $type) -> Self {
if self.error.is_some() {
... | code_fim | hard | {
"lang": "rust",
"repo": "cetra3/tmq",
"path": "/src/socket_builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // FIXME: useless?
#[test]
fn prefix_extractor_customized() {
let tmp_dir = ::tempdir::TempDir::new_in(".", "rocks").unwrap();
let db = DB::open(Options::default()
.map_db_options(|db| db.create_if_missing(true))
.map_cf_optio... | code_fim | hard | {
"lang": "rust",
"repo": "andelf/rust-rocks",
"path": "/src/slice_transform.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(key.len() > 10);
&key[3..9]
}
}
// FIXME: useless?
#[test]
fn prefix_extractor_customized() {
let tmp_dir = ::tempdir::TempDir::new_in(".", "rocks").unwrap();
let db = DB::open(Options::default()
.map_db_opt... | code_fim | hard | {
"lang": "rust",
"repo": "andelf/rust-rocks",
"path": "/src/slice_transform.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andelf/rust-rocks path: /src/slice_transform.rs
//! Class for specifying user-defined functions which perform a
//! transformation on a slice.
//!
//! It is not required that every slice
//! belong to the domain and/or range of a function. Subclasses should
//! define InDomain and InRange to de... | code_fim | hard | {
"lang": "rust",
"repo": "andelf/rust-rocks",
"path": "/src/slice_transform.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>("text/html;charset=utf-8", s)
},
ResponseContentType::Xml=>rouille::Response::html(""),
ResponseContentType::Json=>{
let v = try_or_400!(serde_json::to_vec(&comments));
rouille::Response::from_data("application/json", v)
}
};
}
pub fn comment_upload_view(content_type:R... | code_fim | hard | {
"lang": "rust",
"repo": "Kumazuma/rs-threads-board",
"path": "/src/comments/view.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kumazuma/rs-threads-board path: /src/comments/view.rs
use super::rouille;
use super::serde_json;
use super::templates;
use common::{ ResponseContentType};
use model::Comment;
pub fn comment_list_view(content_type:ResponseContentType, comments:Vec<Comment>)->rouille::Respo<|fim_suffix|>("text/ht... | code_fim | hard | {
"lang": "rust",
"repo": "Kumazuma/rs-threads-board",
"path": "/src/comments/view.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roynalnaruto/core path: /crates/dyn-abi/src/token.rs
use crate::{no_std_prelude::*, Decoder, DynSolValue, Error, Result, Word};
use alloc::borrow::Cow;
use alloy_sol_types::token::{PackedSeqToken, TokenType, WordToken};
/// A dynamic token. Equivalent to an enum over all types implementing
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "roynalnaruto/core",
"path": "/crates/dyn-abi/src/token.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Fallible cast into a packed sequence.
#[inline]
pub const fn as_packed_seq(&self) -> Option<&[u8]> {
match self {
Self::PackedSeq(bytes) => Some(bytes),
_ => None,
}
}
/// True if the type is dynamic, else false.
#[inline]
pub fn is_... | code_fim | hard | {
"lang": "rust",
"repo": "roynalnaruto/core",
"path": "/crates/dyn-abi/src/token.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/image/icon_wb_twilight.rs
pub struct IconWbTwilight {
props: crate::Props,
}
impl yew::Component for IconWbTwilight {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelud... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/image/icon_wb_twilight.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jolhoeft/websession.rs path: /src/sessions.rs
#![forbid(unsafe_code)]
use crate::connectionsignature::ConnectionSignature;
use crate::sessionpolicy::SessionPolicy;
use crate::token::Token;
use crate::AuthError;
use std::collections::HashMap;
use std::time::{Duration, Instant};
// use std::net:... | code_fim | hard | {
"lang": "rust",
"repo": "jolhoeft/websession.rs",
"path": "/src/sessions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Session {
last_access: Instant::now(),
// signature: signature.clone(),
}
}
}
#[derive(Debug)]
pub struct SessionManager {
expiration: Duration,
policy: SessionPolicy,
// cookie_dir: String,
sessions: Mutex<HashMap<ConnectionSignature, Session>>... | code_fim | hard | {
"lang": "rust",
"repo": "jolhoeft/websession.rs",
"path": "/src/sessions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
signature: &ConnectionSignature,
hashmap: &mut MutexGuard<HashMap<ConnectionSignature, Session>>,
) -> bool {
let rv = match hashmap.get(signature) {
Some(sess) => sess.last_access.elapsed() >= self.expiration,
None => true,
};
... | code_fim | hard | {
"lang": "rust",
"repo": "jolhoeft/websession.rs",
"path": "/src/sessions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yishn/adventofcode path: /2019/22.rs
use std::fs::File;
use std::io::prelude::*;
#[derive(Debug, Copy, Clone)]
enum ShuffleOperation {
DealIntoNewStack,
CutNCards(isize),
DealWithIncrement(usize)
}
fn get_input() -> std::io::Result<String> {
let mut file = File::open("22.txt")?;
let ... | code_fim | hard | {
"lang": "rust",
"repo": "yishn/adventofcode",
"path": "/2019/22.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let input = get_input().unwrap();
let instructions = parse_instructions(&input);
let count = 10007;
let shuffle_parameters = calculate_shuffle_parameters(count, instructions.iter().cloned());
let position = track_card_position(shuffle_parameters, 2019, count);
println!("Part 1: {... | code_fim | hard | {
"lang": "rust",
"repo": "yishn/adventofcode",
"path": "/2019/22.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = BusSchedule::parse("0\n67,x,7,59,61").unwrap();
assert_eq!(PartTwo::solve(&input).unwrap(), 779210);
let input = BusSchedule::parse("0\n67,7,x,59,61").unwrap();
assert_eq!(PartTwo::solve(&input).unwrap(), 1261476);
let input = BusSchedule::parse("0\n17... | code_fim | hard | {
"lang": "rust",
"repo": "maxmcc/aoc-2020",
"path": "/src/bin/day13.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut time = 1;
let mut wait = 1;
for bus in input.buses.iter() {
while (time + bus.index) % bus.headway != 0 {
time += wait;
}
wait *= bus.headway;
}
Ok(time)
}
}
aoc::main!(day13);
#[cfg(test)]
mod exampl... | code_fim | hard | {
"lang": "rust",
"repo": "maxmcc/aoc-2020",
"path": "/src/bin/day13.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxmcc/aoc-2020 path: /src/bin/day13.rs
use anyhow::anyhow;
use aoc::{Parse, Result, Solve};
#[derive(Debug, Copy, Clone)]
struct Bus {
headway: u64,
index: u64,
}
struct BusSchedule {
depart: u64,
buses: Vec<Bus>,
}
impl<'a> Parse<'a> for BusSchedule {
fn parse<'b: 'a>(in... | code_fim | hard | {
"lang": "rust",
"repo": "maxmcc/aoc-2020",
"path": "/src/bin/day13.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>orize(
firebase_uid: SubjectClaim,
redis_context: &RedisConnContext,
) -> Result<bool, rocket_contrib::databases::redis::RedisError> {
let frag = "pond/firebase/authorized_uids";
let key = format!("{}/{}", redis_context.namespace, frag);
Ok(redis_context.conn.sismember(key, firebase_ui... | code_fim | medium | {
"lang": "rust",
"repo": "Terkwood/prawnalith",
"path": "/cloud_images/pond/src/authorization.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Terkwood/prawnalith path: /cloud_images/pond/src/authorization.rs
use crate::claims::SubjectClaim;
use crate::redis_conn::RedisConnContext;
use crate::rocket_contrib::databases::redis::Commands;
/// Authorizes a user based<|fim_suffix|>orize(
firebase_uid: SubjectClaim,
redis_context: &... | code_fim | medium | {
"lang": "rust",
"repo": "Terkwood/prawnalith",
"path": "/cloud_images/pond/src/authorization.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rajputrajat/webgpu_sotrh_tutorial path: /src/pipeline_creator.rs
use crate::{buffers, swapchain};
use image::{self, GenericImageView};
use std::num::NonZeroU32;
use wgpu::{
include_spirv,
util::{BufferInitDescriptor, DeviceExt},
Buffer, BufferUsage, ColorTargetState, ColorWrite, Devi... | code_fim | hard | {
"lang": "rust",
"repo": "rajputrajat/webgpu_sotrh_tutorial",
"path": "/src/pipeline_creator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> });
let index_buffer = device.create_buffer_init(&BufferInitDescriptor {
label: Some("index buffer"),
contents: bytemuck::cast_slice(buffers::HEXAGON_INDICES),
usage: BufferUsage::INDEX,
});
let num_indices = buffers:... | code_fim | hard | {
"lang": "rust",
"repo": "rajputrajat/webgpu_sotrh_tutorial",
"path": "/src/pipeline_creator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_inline() {
let values = vec![1721, 979, 366, 299, 675, 1456];
let result = find_solution(&values, 2020, 2).unwrap();
assert_eq!(514579, result);
}
}<|fim_prefix|>// repo: snackb/aoc2020 path: /day1/src/main.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "snackb/aoc2020",
"path": "/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: snackb/aoc2020 path: /day1/src/main.rs
use aoc_input::{get_argument_parsed, get_input_txt};
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 3 {
panic!("Please provide a target and a number to count");
}
let target = get_argument_p... | code_fim | medium | {
"lang": "rust",
"repo": "snackb/aoc2020",
"path": "/day1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // dbg!(&created_intent);
// Ok(created_intent.created_at)
// }
// async fn append_payment_intent(&self, order: i64, intent: &str) -> Result<(), Error> {
// let url = {
// let mut url = self.base_url.clone();
// let path = format!("/api{}", intent)... | code_fim | hard | {
"lang": "rust",
"repo": "except/stupid-farfetch-bot",
"path": "/src/task.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: except/stupid-farfetch-bot path: /src/task.rs
use crate::model::FPSAddress;
use crate::model::FPSCardPaymentIntent;
use crate::model::FPSCity;
use crate::model::FPSCreateOrder;
use crate::model::FPSItem;
use crate::model::FPSOrder;
use crate::model::FPSPatchAddress;
use crate::model::FPSState;
u... | code_fim | hard | {
"lang": "rust",
"repo": "except/stupid-farfetch-bot",
"path": "/src/task.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ketchat_server_id) {
last_message_sent -> BigInt,
matrix_user_id -> Text,
rocketchat_server_id -> Text,
rocketchat_user_id -> Nullable<Text>,
rocketchat_auth_token -> Nullable<Text>,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}<|fim_pref... | code_fim | medium | {
"lang": "rust",
"repo": "mciverza/matrix-rocketchat",
"path": "/src/matrix-rocketchat/models/schema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mciverza/matrix-rocketchat path: /src/matrix-rocketchat/models/schema.rs
#![allow(missing_docs)]
table! {
rocketchat_servers (id) {
id -> Text,
rocketchat_url -> Text,
rocketchat_token -> Null<|fim_suffix|>ketchat_server_id) {
last_message_sent -> BigInt,
... | code_fim | medium | {
"lang": "rust",
"repo": "mciverza/matrix-rocketchat",
"path": "/src/matrix-rocketchat/models/schema.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raum-dellamorte/Petri path: /src/rendering/gui_renderer/mod.rs
mod graph_app;
pub mod gui_renderer;
mod perf<|fim_suffix|>p;
pub use gui_renderer::GUIRenderer;
pub use perf_app::PerfApp;
pub use stat_app::StatApp;<|fim_middle|>_app;
mod stat_app;
pub use graph_app::GridAp | code_fim | easy | {
"lang": "rust",
"repo": "raum-dellamorte/Petri",
"path": "/src/rendering/gui_renderer/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> perf_app::PerfApp;
pub use stat_app::StatApp;<|fim_prefix|>// repo: raum-dellamorte/Petri path: /src/rendering/gui_renderer/mod.rs
mod graph_app;
pub mod gui_renderer;
mod perf_app;
mod stat_app;
pub use graph_app::GridAp<|fim_middle|>p;
pub use gui_renderer::GUIRenderer;
pub use | code_fim | easy | {
"lang": "rust",
"repo": "raum-dellamorte/Petri",
"path": "/src/rendering/gui_renderer/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Riuchando/advent2017 path: /rust_advent/src/day7.rs
#![feature(extern_prelude)]
use petgraph::prelude::*;
use std::collections::HashMap;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Error;
use std::io::ErrorKind;
use petgraph as pg;
use petgraph::dot::Dot;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "Riuchando/advent2017",
"path": "/rust_advent/src/day7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> gr.add_edge(old_node, new_node, 0.0);
}
}
}
// do the topo sort
let order = pg::algo::toposort(&gr, None).unwrap();
// we only care about the first item in the list
let return_string = node_indicies.get(&order[0]).unwrap();
// some debugging too... | code_fim | hard | {
"lang": "rust",
"repo": "Riuchando/advent2017",
"path": "/rust_advent/src/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> = 0;
for i in 0..n {
for j in 0..m {
if field[i][j] == 'W' {
dfs(field, i as i64, j as i64, n, m);
ans += 1;
}
}
}
ans
}
}
fn main() {}<|fim_prefix|>// repo: uta8a/ant-book-rust p... | code_fim | hard | {
"lang": "rust",
"repo": "uta8a/ant-book-rust",
"path": "/library/dfs_field_search/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uta8a/ant-book-rust path: /library/dfs_field_search/main.rs
mod vig {
// near 8 field search example
fn dfs(field: &mut Vec<Vec<char>>, x: i64, y: i64, n: usize, m: usize) {
if field[x as usize][y as usize] == 'W' {
field[x as usize][y as usize] = '.';
for... | code_fim | hard | {
"lang": "rust",
"repo": "uta8a/ant-book-rust",
"path": "/library/dfs_field_search/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let charset = if any { ANY_CHARS } else { ALL_CHARS };
group.trim().lines()
// map each line to set of chars
.map(|line| line.trim().chars().collect())
// reduce into a single set
.fold(charset.chars().collect(), |acc, set|
if any { &acc | &set } else { &acc & &set })
}
#[cfg(t... | code_fim | hard | {
"lang": "rust",
"repo": "bohuim/AdventOfCode",
"path": "/2020/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn form_any() {
assert_eq!(
form(true, r"
a
bc
ac"),
"abc".chars().collect());
assert_eq!(
form(true, r"
a
abc
ac"),
"abc".chars().collect());
}
#[test]
fn form_al... | code_fim | hard | {
"lang": "rust",
"repo": "bohuim/AdventOfCode",
"path": "/2020/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bohuim/AdventOfCode path: /2020/src/day6.rs
use std::collections::HashSet;
const ANY_CHARS: &str = "";
const ALL_CHARS: &str = "abcdefghijklmnopqrstuvwxyz";
#[aoc(day6, part1)]
pub fn solve1(input: &str) -> usize {
count_forms(true, input)
}
<|fim_suffix|> let charset = if any { ANY_CHARS ... | code_fim | hard | {
"lang": "rust",
"repo": "bohuim/AdventOfCode",
"path": "/2020/src/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgottschlag/mkl25z4 path: /src/mtbdwt/tbctrl.rs
#[doc = "Reader of register TBCTRL"]
pub type R = crate::R<u32, super::TBCTRL>;
#[doc = "Writer for register TBCTRL"]
pub type W = crate::W<u32, super::TBCTRL>;
#[doc = "Register TBCTRL `reset()`'s with value 0x2000_0000"]
impl crate::ResetValue fo... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/mkl25z4",
"path": "/src/mtbdwt/tbctrl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `ACOMP1`"]
pub type ACOMP1_R = crate::R<bool, ACOMP1_A>;
impl ACOMP1_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> ACOMP1_A {
match self.bits {
false => ACOMP1_A::_0,
... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/mkl25z4",
"path": "/src/mtbdwt/tbctrl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgmneto/img path: /src/k_means.rs
use crate::commons::image::{Image, Pixel, PixelsByRGBColor};
use crate::commons::rgb::{RGBColor, RGBColorMean};
use rand::Rng;
use std::cmp::max;
const LAST_ITES: usize = 8;
pub struct KMeans {
width: u32,
height: u32,
pixels: Vec<PixelsByRGBColor>... | code_fim | hard | {
"lang": "rust",
"repo": "dgmneto/img",
"path": "/src/k_means.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.means.iter().enumerate()
.min_by_key(|(_, mean)| mean.squared_euclidean(&pixel.color))
.unwrap().0
}
fn build_return(self) -> KMeansReturn {
let image = self.to_image();
let means = self.means;
KMeansReturn {image, means}
}
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "dgmneto/img",
"path": "/src/k_means.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// let sprite_handle = load_sprite_sheet(world);
// self.initialize_pawns(world, sprite_handle);
self.init_map(world);
create_cursor(world);
initialize_camera(world, &self.window_resolution);
use amethyst::renderer::mouse;
let mut msg = world.res.fetch_mut::<WindowMessages>(... | code_fim | hard | {
"lang": "rust",
"repo": "stavenko/pre-historic",
"path": "/src/game_state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stavenko/pre-historic path: /src/game_state.rs
extern crate amethyst;
extern crate nalgebra_glm;
use amethyst::{
assets::{ AssetStorage, Loader },
core::{
nalgebra::{ Vector2, Vector3, Vector4 },
transform::Transform,
},
renderer:: {
Camera,
SpriteRender,
SpriteShee... | code_fim | hard | {
"lang": "rust",
"repo": "stavenko/pre-historic",
"path": "/src/game_state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut msgs = Vec::<GameMessage>::new();
{
let mut messages = data.world.write_resource::<GameMessageResource>();
msgs.append(&mut messages.messages);
}
for msg in msgs {
match msg {
GameMessage::PlacePawn(spece, tile, initial) => place_debug_pawn(data.wo... | code_fim | hard | {
"lang": "rust",
"repo": "stavenko/pre-historic",
"path": "/src/game_state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cantsin/pcg path: /src/util/config.rs
use std::path::{Path, PathBuf};
use std::io::{Read};
use std::fs::{File};
use std::collections::{HashMap, HashSet};
use toml::{Parser, Value, Table, decode};
use rustc_serialize::{Decodable};
use util::sprite::{SpriteRect};
pub struct Config {
content:... | code_fim | hard | {
"lang": "rust",
"repo": "cantsin/pcg",
"path": "/src/util/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// given a TOML configuration file, extract the relevant
/// spritesheet information. returns a hashmap of `Sprite`s.
pub fn process_spritesheet(toml_path: &PathBuf) -> HashMap<String, Vec<SpriteRect>> {
let mut toml_file = File::open(toml_path).unwrap();
let mut contents = St... | code_fim | hard | {
"lang": "rust",
"repo": "cantsin/pcg",
"path": "/src/util/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TeamNumio/zksync path: /core/bin/zksync_eth_sender/src/main.rs
use futures::{channel::mpsc, executor::block_on, SinkExt, StreamExt};
use std::cell::RefCell;
use zksync_config::ZkSyncConfig;
use zksync_eth_client::EthereumGateway;
use zksync_eth_sender::run_eth_sender;
use zksync_gateway_watcher:... | code_fim | hard | {
"lang": "rust",
"repo": "TeamNumio/zksync",
"path": "/core/bin/zksync_eth_sender/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _sentry_guard = vlog::init();
// handle ctrl+c
let (stop_signal_sender, mut stop_signal_receiver) = mpsc::channel(256);
{
let stop_signal_sender = RefCell::new(stop_signal_sender.clone());
ctrlc::set_handler(move || {
let mut sender = stop_signal_sender.bor... | code_fim | medium | {
"lang": "rust",
"repo": "TeamNumio/zksync",
"path": "/core/bin/zksync_eth_sender/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn f(m: u32) -> bool {
let x = [m,m,m];
let y = [2,3,4];
let z = add3(x,y);
z[0] == 2+m
}
const ARG:u32 = 4;
#[cfg(with_main)]
pub fn main() {
println!("{:?}", f(ARG));
}
#[cfg(not(with_main))] #[cfg_attr(crux, crux::test)] fn crux_test() -> bool { f(ARG) }<|fim_prefix|>// repo: ... | code_fim | hard | {
"lang": "rust",
"repo": "GaloisInc/crucible",
"path": "/crux-mir/test/conc_eval/array/wick2.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GaloisInc/crucible path: /crux-mir/test/conc_eval/array/wick2.rs
#![cfg_attr(not(with_main), no_std)]
fn add3(x: [u32; 3], y: [u32; 3]) -> [u32;4]
{
let mut output = [0; 4];
let big0: u64 = (x[0] as u64) + (y[0] as u64);
let carry0: u64 = big0 >> 32u64;
let big1: u64 = (x[1] ... | code_fim | medium | {
"lang": "rust",
"repo": "GaloisInc/crucible",
"path": "/crux-mir/test/conc_eval/array/wick2.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[cfg(with_main)]
pub fn main() {
println!("{:?}", f(ARG));
}
#[cfg(not(with_main))] #[cfg_attr(crux, crux::test)] fn crux_test() -> bool { f(ARG) }<|fim_prefix|>// repo: GaloisInc/crucible path: /crux-mir/test/conc_eval/array/wick2.rs
#![cfg_attr(not(with_main), no_std)]
fn add3(x: [u32; 3], y:... | code_fim | medium | {
"lang": "rust",
"repo": "GaloisInc/crucible",
"path": "/crux-mir/test/conc_eval/array/wick2.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: japaric/stm32f103xx-hal path: /examples/blinky.rs
//! Blinks an LED
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_std]
#![no_main]
extern crate panic_halt;
use stm32f103xx_hal as hal;
use nb::block;
use crate::hal::{
prelude::*,
device,
timer::Timer,
};
use cortex_m_rt::entry;
... | code_fim | medium | {
"lang": "rust",
"repo": "japaric/stm32f103xx-hal",
"path": "/examples/blinky.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Try a different clock configuration
let clocks = rcc.cfgr.freeze(&mut flash.acr);
// let clocks = rcc.cfgr
// .sysclk(64.mhz())
// .pclk1(32.mhz())
// .freeze(&mut flash.acr);
let mut gpioc = dp.GPIOC.split(&mut rcc.apb2);
let mut led = gpioc.pc13.into_push... | code_fim | hard | {
"lang": "rust",
"repo": "japaric/stm32f103xx-hal",
"path": "/examples/blinky.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tony612/adventofcode path: /src/main.rs
mod day1;
mod day2;
mod day3;
mod day4;
mod day5;
mod day6;
<|fim_suffix|> day1::run();
day2::run();
day3::run();
day4::run();
day5::run();
day6::run();
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "tony612/adventofcode",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> day1::run();
day2::run();
day3::run();
day4::run();
day5::run();
day6::run();
}<|fim_prefix|>// repo: tony612/adventofcode path: /src/main.rs
mod day1;
mod day2;
mod day3;
mod day4;
mod day5;
mod day6;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "tony612/adventofcode",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> crate::myarch::*;
use crate::simd::*;<|fim_prefix|>// repo: viirya/vektor path: /src/x86/macros.rs
// Autogenerated by `scrape.py`.
// See https://github.com/AdamNiederer/vek<|fim_middle|>tor-gen
#![allow(unused_imports)]
use | code_fim | easy | {
"lang": "rust",
"repo": "viirya/vektor",
"path": "/src/x86/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: viirya/vektor path: /src/x86/macros.rs
// Autogenerated by `scrape.py`.
// S<|fim_suffix|>tor-gen
#![allow(unused_imports)]
use crate::myarch::*;
use crate::simd::*;<|fim_middle|>ee https://github.com/AdamNiederer/vek | code_fim | easy | {
"lang": "rust",
"repo": "viirya/vektor",
"path": "/src/x86/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tor-gen
#![allow(unused_imports)]
use crate::myarch::*;
use crate::simd::*;<|fim_prefix|>// repo: viirya/vektor path: /src/x86/macros.rs
// Autogenerated by `scrape.py`.
// S<|fim_middle|>ee https://github.com/AdamNiederer/vek | code_fim | easy | {
"lang": "rust",
"repo": "viirya/vektor",
"path": "/src/x86/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgrunwald/rust-cpython path: /src/objects/tests.rs
// Copyright (c) 2015 Dmitry Trofimov
//
// 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, inc... | code_fim | hard | {
"lang": "rust",
"repo": "dgrunwald/rust-cpython",
"path": "/src/objects/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut map = BTreeMap::<i32, i32>::new();
map.insert(1, 1);
let py_map = map.to_py_object(py);
assert!(py_map.len(py) == 1);
assert!(py_map.get_item(py, 1).unwrap().extract::<i32>(py).unwrap() == 1);
}<|fim_prefix|>// repo: dgrunwald/rust-cpython path: /src/objects/tests.rs
// Copy... | code_fim | hard | {
"lang": "rust",
"repo": "dgrunwald/rust-cpython",
"path": "/src/objects/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lythenas/rust-orgmode path: /src/types/greater_elements/plain_list.rs
use super::*;
/// A plain list.
///
/// # Semantics
///
/// A complete list of [`Item`]s.
///
/// # Syntax
///
/// This is a set of consecutive items of the same indentation. It can only directly contain
/// items.
///
/// If... | code_fim | hard | {
"lang": "rust",
"repo": "Lythenas/rust-orgmode",
"path": "/src/types/greater_elements/plain_list.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PlainList {
pub fn kind(&self) -> ListKind {
// find first item and get kind of item
// TODO not sure if this is the best way
unimplemented!()
}
}
/// The list kind of a [`PlainList`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ListKind {
Unordered,
... | code_fim | medium | {
"lang": "rust",
"repo": "Lythenas/rust-orgmode",
"path": "/src/types/greater_elements/plain_list.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: choimake/reverse_polish path: /src/main.rs
// 逆ポーランド記法の数式を計算するプログラム
// - 演算子は + - * / %
// - 数値は32bit整数
use anyhow::Result;
use clap::Clap;
use std::fs::File;
use std::io::{stdin, BufRead, BufReader};
use std::path::PathBuf;
// deriveは「引き出す」という意味
// この場合は、Clapの処理をOpsに継承している
#[derive(Clap)]
// ... | code_fim | medium | {
"lang": "rust",
"repo": "choimake/reverse_polish",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in reader.lines() {
let line = line?;
// 計算
match reverse_polish::eval(&line) {
Ok(result) => println!("calculation result is {}", result),
Err(e) => eprintln!("{:#?}", e),
}
}
Ok(())
}<|fim_prefix|>// repo: choimake/reverse_pol... | code_fim | hard | {
"lang": "rust",
"repo": "choimake/reverse_polish",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wehjin/smarket path: /src/lib.rs
extern crate reqwest;
use std::collections::HashMap;
use std::path::Path;
use std::sync::mpsc::{channel, Sender};
use std::thread;
use std::time::SystemTime;
use echo_lib::Echo;
pub use self::basics::*;
mod basics;
mod sample;
pub mod yf;
#[derive(Debug, Clo... | code_fim | hard | {
"lang": "rust",
"repo": "wehjin/smarket",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn open(data_folder: &Path) -> Self {
let echo = Echo::connect("smarket-1", data_folder);
let (tx, rx) = channel();
thread::spawn(move || {
let mut latest = echo.chamber().unwrap();
for msg in rx {
match msg {
Msg::SetSharePrice(symbol, price, out) => {
let symbol = canonic... | code_fim | hard | {
"lang": "rust",
"repo": "wehjin/smarket",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KedamaOvO/soft3d-rs path: /src/vector.rs
use std::ops::{Add, Sub, Mul};
use std::fmt;
use std::fmt::{Formatter, Error};
#[derive(Debug, PartialEq, Clone)]
pub struct Vector {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
#[derive(Debug, PartialEq, Clone)]
pub s... | code_fim | hard | {
"lang": "rust",
"repo": "KedamaOvO/soft3d-rs",
"path": "/src/vector.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "[{},{},{},{}]", self.x, self.y, self.z, self.w)
}
}
#[cfg(test)]
mod test {
use crate::vector::Vector;
#[test]
fn cross_test() {
let a = Vector::new(1.0, 2.0, 3.0, 0.0);
let b = Vector::new(4.0, 5.0, 6.0, 0.0);
assert_eq!(Vector::new... | code_fim | hard | {
"lang": "rust",
"repo": "KedamaOvO/soft3d-rs",
"path": "/src/vector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CaptainXX/RustLearning path: /c8/c8_s1_vector/src/main.rs
fn main() {
let mut v: Vec<i32> = Vec::new();
v.push(1);
v.push(2);
v.push(3);
v.push(4);
v.push(5);
for i in v {
println!("{}", i);
}
let mut v1 = vec![1, 2, 3, 4, 5];
let third: &i32 = &v... | code_fim | medium | {
"lang": "rust",
"repo": "CaptainXX/RustLearning",
"path": "/c8/c8_s1_vector/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Debug)]
enum MulTypesInVec {
Int(i32),
Float(f64),
Text(String),
}
let row = vec![
MulTypesInVec::Int(10),
MulTypesInVec::Int(2),
MulTypesInVec::Float(20.12),
MulTypesInVec::Text(String::from("Hello")),
];
for i in &... | code_fim | hard | {
"lang": "rust",
"repo": "CaptainXX/RustLearning",
"path": "/c8/c8_s1_vector/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let row = vec![
MulTypesInVec::Int(10),
MulTypesInVec::Int(2),
MulTypesInVec::Float(20.12),
MulTypesInVec::Text(String::from("Hello")),
];
for i in &row {
println!("{:?} in row", i);
}
}<|fim_prefix|>// repo: CaptainXX/RustLearning path: /c8/c8_s1_v... | code_fim | hard | {
"lang": "rust",
"repo": "CaptainXX/RustLearning",
"path": "/c8/c8_s1_vector/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MMXVII/mmix path: /src/machine/behavior/is/float/flotu.rs
use machine::state::State;
pub fn flotu(state: &mut State, x: u8, y: u8, z: u8) {
// Load operand
let op1: u64 = state.gpr[z].into();
<|fim_suffix|> // Store result
state.gpr[x] = res.into();
}<|fim_middle|> // Execute... | code_fim | hard | {
"lang": "rust",
"repo": "MMXVII/mmix",
"path": "/src/machine/behavior/is/float/flotu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AKrill91/advent-of-code path: /src/2018/day02.rs
use std::collections::HashMap;
use advent_helper;
pub fn run_a() -> i32 {
let ids = advent_helper::read_file_lines("resources/day02.txt");
let mut num_twos = 0;
let mut num_threes = 0;
for id in ids {
let mut letter_cou... | code_fim | hard | {
"lang": "rust",
"repo": "AKrill91/advent-of-code",
"path": "/src/2018/day02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut similar_letters : Vec<u8> = Vec::new();
for pair in bytes.iter().zip(compare_bytes.iter()) {
let left = pair.0;
let right = pair.1;
if left != right {
num_diffs += 1;
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "AKrill91/advent-of-code",
"path": "/src/2018/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: winksaville/fuchsia path: /third_party/rust_crates/vendor/harfbuzz/src/language.rs
// Copyright 2018 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apac... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/third_party/rust_crates/vendor/harfbuzz/src/language.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn to_string(&self) -> &str {
unsafe { std::ffi::CStr::from_ptr(sys::hb_language_to_string(self.raw)) }
.to_str()
.unwrap()
}
pub unsafe fn from_raw(raw: sys::hb_language_t) -> Self {
Language { raw }
}
pub fn as_raw(self) -> sys::hb_langua... | code_fim | hard | {
"lang": "rust",
"repo": "winksaville/fuchsia",
"path": "/third_party/rust_crates/vendor/harfbuzz/src/language.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[no_mangle]
pub extern "C" fn exit(ret: i32) -> u64 {
return syscall(ret as u64, 0, 0, 0, 0, 0, 0, 93);
}
#[no_mangle]
pub extern "C" fn debug(s: &[u8]) -> u64 {
return syscall(s.as_ptr() as *const u8 as u64, 0, 0, 0, 0, 0, 0, 2177);
}
#[no_mangle]
pub unsafe extern "C" fn ckb_load_tx_hash(add... | code_fim | hard | {
"lang": "rust",
"repo": "rink1969/rust-ckb-contract",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rink1969/rust-ckb-contract path: /src/main.rs
#![feature(asm)]
#![no_std]
#![no_main]
#![feature(ptr_offset_from)]
extern crate core;
extern crate secp256k1;
extern crate blake2_rfc;
mod checksignall;
use checksignall::verify_sighash_all;
static mut PARGC: *const u64 = 0 as *const u64;
stat... | code_fim | hard | {
"lang": "rust",
"repo": "rink1969/rust-ckb-contract",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub unsafe extern "C" fn ckb_load_tx_hash(addr: &mut [u8], len: &mut u64, offset: u64) -> u64
{
return syscall(addr.as_ptr() as u64, (len as *const u64).offset_from(0 as *const u64) as u64 * 8, offset, 0, 0, 0, 0, 2061);
}
use core::panic::PanicInfo;
/// This function is called on panic.
#... | code_fim | hard | {
"lang": "rust",
"repo": "rink1969/rust-ckb-contract",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let url = "https://gfycat.com/babyishsoftleveret-babushka-flowers-waiting-welcome-hello";
let right = "babyishsoftleveret";
let left = strip_gfycat(url);
dbg! {&left};
assert_eq! {left.unwrap(), right};
}
#[test]
fn test_strip_2() {
let url = "https://gfycat.com/obviousoldgrayreef... | code_fim | hard | {
"lang": "rust",
"repo": "VanillaBrooks/mastodon-mirror",
"path": "/src/reddit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let left = strip_gfycat(url);
dbg! {&left};
assert_eq! {left.unwrap(), right};
}
#[test]
fn test_strip_7() {
let url = "https://gfycat.com/glitteringdeafeningindianskimmer-happy-new-year-new-years-holiday-hanson";
let right = "glitteringdeafeningindianskimmer";
let left = strip_gf... | code_fim | hard | {
"lang": "rust",
"repo": "VanillaBrooks/mastodon-mirror",
"path": "/src/reddit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VanillaBrooks/mastodon-mirror path: /src/reddit.rs
use super::error;
use bytes;
use gfycat;
use serde::Deserialize;
use serde_json;
use std::fs;
use std::io::Write;
#[derive(Debug, Deserialize)]
struct RedditData {
data: DataInfo,
}
#[derive(Debug, Deserialize)]
struct DataInfo {
childr... | code_fim | hard | {
"lang": "rust",
"repo": "VanillaBrooks/mastodon-mirror",
"path": "/src/reddit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guydunigo/tokio_test path: /src/codec.rs
use bytes::{BufMut, BytesMut};
use tokio::codec::{Decoder, Encoder};
use std::io;
<|fim_suffix|> if buf.len() >= 4 {
let array = [buf[0], buf[1], buf[2], buf[3]];
let n = u32::from_le_bytes(array);
buf.split_to... | code_fim | medium | {
"lang": "rust",
"repo": "guydunigo/tokio_test",
"path": "/src/codec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Encoder for ProtoCodec {
type Item = u32;
type Error = io::Error;
fn encode(&mut self, packet: Self::Item, buf: &mut BytesMut) -> Result<(), Self::Error> {
buf.reserve(4);
buf.put_u32_le(packet);
Ok(())
}
}<|fim_prefix|>// repo: guydunigo/tokio_test path: /s... | code_fim | hard | {
"lang": "rust",
"repo": "guydunigo/tokio_test",
"path": "/src/codec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: martincrb/rust-learnings path: /rust02/src/vars.rs
pub fn run() {
// Variables are immutable by default in Rust
<|fim_suffix|>his kind of 'destructuring'
let (var1, var2) = ("string", 3);
}<|fim_middle|> let name = "Martin";
println!("My name is {}", name);
const ID: i32 ... | code_fim | medium | {
"lang": "rust",
"repo": "martincrb/rust-learnings",
"path": "/rust02/src/vars.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const ID: i32 = 001;
// I can assign multiple vars using this kind of 'destructuring'
let (var1, var2) = ("string", 3);
}<|fim_prefix|>// repo: martincrb/rust-learnings path: /rust02/src/vars.rs
pub fn run() {
// Variables are immutable by default in Rust
<|fim_middle|> let name = "Mar... | code_fim | medium | {
"lang": "rust",
"repo": "martincrb/rust-learnings",
"path": "/rust02/src/vars.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let module = parity_wasm::deserialize_file("experiment.wasm").expect("File to be deserialized");
let loaded_module = wasmi::Module::from_parity_wasm_module(module).expect("Module to be valid");
let main = ModuleInstance::new(&loaded_module, &ImportsBuilder::default())
.expect("Failed t... | code_fim | medium | {
"lang": "rust",
"repo": "richardanaya/rust-wasm-scripting",
"path": "/examples/add.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: richardanaya/rust-wasm-scripting path: /examples/add.rs
extern crate parity_wasm;
extern crate wasmi;
use wasmi::{ImportsBuilder, ModuleInstance, NopExternals, RuntimeValue};
<|fim_suffix|> let module = parity_wasm::deserialize_file("experiment.wasm").expect("File to be deserialized");
... | code_fim | medium | {
"lang": "rust",
"repo": "richardanaya/rust-wasm-scripting",
"path": "/examples/add.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return request;
}
fn fetch<T: Decodable>(req: Request<Fresh>) -> Result<T, HttpError> {
let connection = try!(req.start());
let mut response = try!(connection.send());
let mut body = vec![];
let _ = try!(response.read_to_end(&mut body));
let objec... | code_fim | hard | {
"lang": "rust",
"repo": "rakibulislam/stripe-rust",
"path": "/src/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rakibulislam/stripe-rust path: /src/connection.rs
use std::string::String;
use std::io::Read;
use customer::{CustomerList,CustomerId};
use card::CardList;
use decoder::StripeDecoder;
use url::Url;
use hyper::client::Request;
use hyper::net::Fresh;
use hyper::Get;
use hyper::header::Authorization... | code_fim | hard | {
"lang": "rust",
"repo": "rakibulislam/stripe-rust",
"path": "/src/connection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn cards(&self, customer: CustomerId) -> Result<CardList, HttpError> {
let req = self.request(urlify!("v1", "customers", customer, "cards"));
return Connection::fetch(req);
}
}<|fim_prefix|>// repo: rakibulislam/stripe-rust path: /src/connection.rs
use std::string::String;
us... | code_fim | hard | {
"lang": "rust",
"repo": "rakibulislam/stripe-rust",
"path": "/src/connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Containers
add_note_to_container_path,
remove_note_from_container_path,
query_child_paths_from_parent_container,
query_note_container_paths,
query_note_ids_from_container,
//Tags
get_tags,
get_no... | code_fim | hard | {
"lang": "rust",
"repo": "acweathersby/Ruminate",
"path": "/app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acweathersby/Ruminate path: /app/src/main.rs
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use tauri::Manager;
use crate::globals::init_store;
mod bridge;
mod store;
mod globals;
mod tests;
/// Pre-populates store with testing note... | code_fim | hard | {
"lang": "rust",
"repo": "acweathersby/Ruminate",
"path": "/app/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::set_max_level(LevelFilter::Debug);
if let Err(err) = std::fs::create_dir_all(&get_main_path()){
debug!("{}", err);
}
load_notes();
#[cfg(debug_assertions)]
add_debug_components();
Ok(())
})... | code_fim | hard | {
"lang": "rust",
"repo": "acweathersby/Ruminate",
"path": "/app/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: museun/molpe path: /src/pe/tables/module.rs
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C<|fim_suffix|>ation: u16,
pub name: u16,
pub mvid: u16,
pub env_id: u16,
pub env_base_id: u16,
}<|fim_middle|>, packed)]
pub struct ModuleTable {
pub gener | code_fim | easy | {
"lang": "rust",
"repo": "museun/molpe",
"path": "/src/pe/tables/module.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>ation: u16,
pub name: u16,
pub mvid: u16,
pub env_id: u16,
pub env_base_id: u16,
}<|fim_prefix|>// repo: museun/molpe path: /src/pe/tables/module.rs
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C<|fim_middle|>, packed)]
pub struct ModuleTable {
pub gener | code_fim | easy | {
"lang": "rust",
"repo": "museun/molpe",
"path": "/src/pe/tables/module.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub env_id: u16,
pub env_base_id: u16,
}<|fim_prefix|>// repo: museun/molpe path: /src/pe/tables/module.rs
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C<|fim_middle|>, packed)]
pub struct ModuleTable {
pub generation: u16,
pub name: u16,
pub mvid: u16, | code_fim | medium | {
"lang": "rust",
"repo": "museun/molpe",
"path": "/src/pe/tables/module.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kazchimo/pro-con path: /src/bin/ALDS1_1_A.rs
use std::fmt::Display;
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
<|fim_suffix|> for i in 1..n {
let v = vec[i];
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "kazchimo/pro-con",
"path": "/src/bin/ALDS1_1_A.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, v) in vec.iter().enumerate() {
if i != vec.len() - 1 {
print!("{} ", v)
} else {
println!("{}", v)
}
}
}
fn main() {
let n = read::<usize>();
let mut vec = read_vec::<u16>();
println_vec(&vec);
for i in 1..n {
let v ... | code_fim | medium | {
"lang": "rust",
"repo": "kazchimo/pro-con",
"path": "/src/bin/ALDS1_1_A.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ProgramInstruction {
/// Unpack inbound buffer to associated Instruction
/// The expected format for input is a Borsh serialized vector
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
let block = Vec::<Vec<u8>>::try_from_slice(input).unwrap();
match block[0][0]... | code_fim | medium | {
"lang": "rust",
"repo": "oksanassss/first-solana-example",
"path": "/src/instruction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oksanassss/first-solana-example path: /src/instruction.rs
use crate::errors::SampleError;
use {borsh::BorshDeserialize, solana_program::program_error::ProgramError};
<|fim_suffix|>impl ProgramInstruction {
/// Unpack inbound buffer to associated Instruction
/// The expected format for ... | code_fim | medium | {
"lang": "rust",
"repo": "oksanassss/first-solana-example",
"path": "/src/instruction.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.