text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>impl From<BinaryReaderError> for Error { fn from(e: BinaryReaderError) -> Self { Error::Input(format!("At wasm offset {}: {}", e.offset(), e.message())) } } impl From<capstone::Error> for Error { fn from(e: capstone::Error) -> Self { Error::Disassembler(e.to_string()) } }<...
code_fim
medium
{ "lang": "rust", "repo": "mashtizadeh/wasmtime", "path": "/crates/lightbeam/src/error.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> if last_collapsed { y_offset += WINDOW_HEADER; } Window::new(im_str!("Debug")) .flags(WindowFlags::NO_RESIZE) .size([300.0, 150.0], Condition::Always) .collapsed(true, Condition::Once) .position_pivot(GLOBAL_PIVOT) ...
code_fim
hard
{ "lang": "rust", "repo": "AustinOliverHaskell/RustBot", "path": "/UI/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AustinOliverHaskell/RustBot path: /UI/src/main.rs use imgui::*; use imgui::ImStr; mod support; fn main() { let mut create_master: bool = true; let mut use_outlines: bool = true; let mut threadcount_text: ImString = ImString::with_capacity(3); let mut printbed...
code_fim
hard
{ "lang": "rust", "repo": "AustinOliverHaskell/RustBot", "path": "/UI/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if last_collapsed { y_offset += WINDOW_HEADER; } else { last_collapsed = true; } Window::new(im_str!("Info")) .flags(WindowFlags::NO_RESIZE) .size([300.0, 150.0], Condition::Always) .collapsed(true, Condition::Onc...
code_fim
hard
{ "lang": "rust", "repo": "AustinOliverHaskell/RustBot", "path": "/UI/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GeTechG/svgParser path: /src/main.rs mod parse_svg_path; mod svg_parse; fn main() { let test_path = "M 1307.944, 308.119 1298.496, 304.842 1289.048, 301.565 1279.600, 298.289 1270.152, 295.012 1260.704, 291.736 1251.256, 288.459 1241.808, 285.183 1232.360, 281.906 1222.912, 278.630 1213.46...
code_fim
hard
{ "lang": "rust", "repo": "GeTechG/svgParser", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>94.097, 782.025 1202.911, 777.301 1211.724, 772.576 1220.538, 767.852 1229.351, 763.127 1238.165, 758.403 1246.979, 753.678 1255.792, 748.954 1264.606, 744.229 1273.419, 739.505 1281.379, 735.238 1282.000, 725.258 1282.620, 715.277 1283.241, 705.296 1283.862, 695.316 1284.483, 685.335 1285.103, 675.354 12...
code_fim
hard
{ "lang": "rust", "repo": "GeTechG/svgParser", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>4 662.716, 741.142 671.259, 746.340 679.802, 751.538 688.345, 756.736 696.888, 761.934 705.431, 767.132 713.973, 772.330 722.516, 777.528 731.059, 782.726 739.602, 787.924 748.145, 793.122 756.688, 798.320 765.231, 803.518 773.774, 808.716 782.316, 813.914 790.859, 819.112 799.402, 824.310 807.945, 829.50...
code_fim
hard
{ "lang": "rust", "repo": "GeTechG/svgParser", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn source(&self, e: &Ed) -> Nd { self.graph.edge(*e).source() } fn target(&self, e: &Ed) -> Nd { self.graph.edge(*e).target() } }<|fim_prefix|>// repo: tmerr/machete path: /src/todot.rs use std::borrow::IntoCow; use graphviz as dot; use graph::{Graph, NodeIndex, EdgeIndex...
code_fim
hard
{ "lang": "rust", "repo": "tmerr/machete", "path": "/src/todot.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmerr/machete path: /src/todot.rs use std::borrow::IntoCow; use graphviz as dot; use graph::{Graph, NodeIndex, EdgeIndex}; use backend::GraphInfo; pub type Nd = NodeIndex; pub type Ed = EdgeIndex; /// Render the graph to the file. Note the graph name must match the regex /// [a-zA-Z_][a-zA-Z_0...
code_fim
medium
{ "lang": "rust", "repo": "tmerr/machete", "path": "/src/todot.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhenkyle/ta-rs path: /src/indicators/efficiency_ratio.rs use std::fmt; use crate::errors::{Error, ErrorKind, Result}; use crate::traits::{Close, Next, Period, Reset}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; /// Kaufman's Efficiency Ratio (ER). /// /// It is calculated by...
code_fim
hard
{ "lang": "rust", "repo": "zhenkyle/ta-rs", "path": "/src/indicators/efficiency_ratio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_reset() { let mut er = EfficiencyRatio::new(3).unwrap(); er.next(3.0); er.next(5.0); er.reset(); assert_eq!(round(er.next(3.0)), 1.0); assert_eq!(round(er.next(5.0)), 1.0); assert_eq!(round(er.next(2.0)), 0.2); asse...
code_fim
hard
{ "lang": "rust", "repo": "zhenkyle/ta-rs", "path": "/src/indicators/efficiency_ratio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update_item(&self, p: &Item) -> ServerResult<Item> { p.save_changes(&self.get()) .map_err(|_| reject::server_error()) } pub fn sunset_items(&self) -> QueryResult<usize> { diesel::delete(items::table.filter(items::sunset.le(Utc::now()))).execute(&self.get()) ...
code_fim
hard
{ "lang": "rust", "repo": "firebitsbr/zero-rs", "path": "/src/db.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: firebitsbr/zero-rs path: /src/db.rs use crate::model::Item; use crate::schema::*; use chrono::Utc; use diesel::pg::PgConnection; use diesel::prelude::*; use diesel::r2d2::{ConnectionManager, Pool, PooledConnection}; use diesel::result::Error::NotFound; use diesel::sql_types::{BigInt, Text}; use...
code_fim
medium
{ "lang": "rust", "repo": "firebitsbr/zero-rs", "path": "/src/db.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Luthaf/log-once path: /src/lib.rs #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::new_without_default, clippy::new_without_default)] #![allow(clippy::useless_attribute, clippy::missing_docs_in_private_items)] #![allow(clippy::use_self)] //! Collection of helper macros for logging some ...
code_fim
hard
{ "lang": "rust", "repo": "Luthaf/log-once", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Logs a message once at the trace level. /// /// The log event will only be emitted once for each combinaison of target/arguments. /// /// Logging at this level is disabled if any of the following features are /// present: `max_level_off`, `max_level_error`, `max_level_warn`, /// `max_level_info`, or `...
code_fim
hard
{ "lang": "rust", "repo": "Luthaf/log-once", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: han-so1omon/linkerd2-proxy path: /linkerd/service-profiles/src/split.rs use crate::{Profile, Receiver, Target}; use futures::{prelude::*, ready}; use indexmap::IndexSet; use linkerd2_addr::Addr; use linkerd2_error::Error; use linkerd2_stack::{layer, NewService}; use rand::distributions::{Distrib...
code_fim
hard
{ "lang": "rust", "repo": "han-so1omon/linkerd2-proxy", "path": "/linkerd/service-profiles/src/split.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let idx = if addrs.len() == 1 { 0 } else { distribution.sample(&mut self.rng) }; let addr = addrs.get_index(idx).expect("invalid index"); trace!(%addr, "Dispatching"); Box::pin(self.services.call_ready(addr, req).err_into::<Error>()) ...
code_fim
hard
{ "lang": "rust", "repo": "han-so1omon/linkerd2-proxy", "path": "/linkerd/service-profiles/src/split.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kwohlfahrt/vkrs path: /src/device.rs use sys::common::{VkResult, VkStructureType, VK_NULL_HANDLE}; use sys::device::*; use sys::instance::VK_QUEUE_GRAPHICS_BIT; use instance::PhysicalDevice; use std::marker::PhantomData; use std::collections::HashMap; use std::ptr; pub struct QueuePriority(f32)...
code_fim
hard
{ "lang": "rust", "repo": "kwohlfahrt/vkrs", "path": "/src/device.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let instance = debug_instance(); let (errs, dbg) = debug_monitor(&instance, true); let device = { let priorities = vec!((0, vec!(QueuePriority::from_float_clamped(1.0)))).into_iter().collect::<HashMap<u32, Vec<QueuePriority>>>(); Device::new(&instance.devic...
code_fim
hard
{ "lang": "rust", "repo": "kwohlfahrt/vkrs", "path": "/src/device.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_queue(&self, family: u32, index: u32) -> Option<Queue<'a>> { match self.nqueues.get(&family) { Some(nqueues) if index < *nqueues => { let mut queue = VK_NULL_HANDLE; unsafe {vkGetDeviceQueue(self.handle, family, index, &mut queue);} ...
code_fim
hard
{ "lang": "rust", "repo": "kwohlfahrt/vkrs", "path": "/src/device.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sriram23/deeprust path: /code/deeprust/src/sgd/gradient.rs // Task :- Performing gradient descent operations // Author :- @digneshwer // Version :- 0.0.1 // Date : - 28 Jan 2017 // Modules used use std::{f64,i32}; // Main function point of execution pub fn exec() { println!("Gradient Desce...
code_fim
hard
{ "lang": "rust", "repo": "sriram23/deeprust", "path": "/code/deeprust/src/sgd/gradient.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// implement area for circle impl ParameterOptimization for Params { fn theta_zero_update(&mut self) -> &Params { self.theta.0 = self.theta.0 - self.update_int.0; // (self.theta.0, self.sgd_alpha, self.sample_size, self.data.0) self } fn theta_one_update(&mut self) -> &Params { self.theta.1 = ...
code_fim
medium
{ "lang": "rust", "repo": "sriram23/deeprust", "path": "/code/deeprust/src/sgd/gradient.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: multivac61/gameboy path: /src/cartridge.rs use crate::cpu::MemoryAddress; pub const ROM_BANK_0_START: u16 = 0x0000; const ROM_BANK_0_END: u16 = 0x3FFF; pub const ROM_BANK_N_START: u16 = 0x4000; const ROM_BANK_N_END: u16 = 0x7FFF; const ROM_BANK_SIZE: usize = 0x4000; const RAM_BANK_SIZE: usize ...
code_fim
hard
{ "lang": "rust", "repo": "multivac61/gameboy", "path": "/src/cartridge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_ram(&self, address: MemoryAddress) -> u8 { let address = (address - RAM_START) as usize + RAM_BANK_SIZE * self.cur_ram_bank; self.ram[address] } pub fn write_rom(&mut self, address: MemoryAddress, data: u8) { match address { 0x0000..=0x1FFF => {...
code_fim
hard
{ "lang": "rust", "repo": "multivac61/gameboy", "path": "/src/cartridge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>laration; pub(crate) mod interface_declaration; pub(crate) mod module_declaration; pub(crate) mod type_alias_declaration;<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/ts/declarations/mod.rs //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-...
code_fim
medium
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/ts/declarations/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/ts/declarations/mod.rs //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. pub(crate) mod declare_function_declaration; pub(crate) mod declare_function_export_default_declaration; pub(crate)...
code_fim
medium
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/ts/declarations/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>aration; pub(crate) mod external_module_declaration; pub(crate) mod global_declaration; pub(crate) mod import_equals_declaration; pub(crate) mod interface_declaration; pub(crate) mod module_declaration; pub(crate) mod type_alias_declaration;<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatte...
code_fim
medium
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/ts/declarations/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> xplm::debug("Flightsimcompanionplugin enable"); self.plugin_menu.add_to_plugins_menu(); Ok(()) } fn disable(&mut self) { self.plugin_menu.remove_from_plugins_menu(); } } #[derive(Error, Debug)] enum FlightSimCompanionPluginError { #[error("Menu error")] ...
code_fim
hard
{ "lang": "rust", "repo": "sprhawk/xplm-rs-example", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Plugin for FlightSimCompanionPlugin { type Error = FlightSimCompanionPluginError; fn start() -> Result<Self, Self::Error> { xplm::debug("Flightsimcompanionplugin start"); let plugin = FlightSimCompanionPlugin::new()?; Ok(plugin) } fn info(&self) -> PluginInfo...
code_fim
hard
{ "lang": "rust", "repo": "sprhawk/xplm-rs-example", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sprhawk/xplm-rs-example path: /src/lib.rs use std::rc::Rc; use thiserror::Error; use xplm::{ menu::{ActionItem, Item, Menu}, plugin::{Plugin, PluginInfo}, xplane_plugin, }; use xplm_sys; struct FlightSimCompanionPlugin { plugin_menu: Menu, } impl FlightSimCompanionPlugin { ...
code_fim
hard
{ "lang": "rust", "repo": "sprhawk/xplm-rs-example", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DmitryTravyan/ywatch path: /src/server/status_svc.rs use crate::state::State; use hyper::http::{Request, Response, StatusCode}; use hyp<|fim_suffix|>usCode::OK) .body(state.get_json_as_str().into()) .unwrap() ) }<|fim_middle|>er::Body; use std::sync::Arc; pub(crate) async fn...
code_fim
medium
{ "lang": "rust", "repo": "DmitryTravyan/ywatch", "path": "/src/server/status_svc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>usCode::OK) .body(state.get_json_as_str().into()) .unwrap() ) }<|fim_prefix|>// repo: DmitryTravyan/ywatch path: /src/server/status_svc.rs use crate::state::State; use hyper::http::{Request, Response, StatusCode}; use hyp<|fim_middle|>er::Body; use std::sync::Arc; pub(crate) async fn...
code_fim
medium
{ "lang": "rust", "repo": "DmitryTravyan/ywatch", "path": "/src/server/status_svc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args: Vec<String> = env::args().collect(); let mut bf: BrainfuckState = BrainfuckState::new(); bf.parse(&args[1]); bf.execute(); }<|fim_prefix|>// repo: Mitafr/brainfuck-rust path: /src/main.rs mod brainfuck; use crate::brainfuck::BrainfuckState; use std::env; <|fim_middle|>fn main(...
code_fim
easy
{ "lang": "rust", "repo": "Mitafr/brainfuck-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mitafr/brainfuck-rust path: /src/main.rs mod brainfuck; use crate::brainfuck::BrainfuckState; use std::env; <|fim_suffix|> let args: Vec<String> = env::args().collect(); let mut bf: BrainfuckState = BrainfuckState::new(); bf.parse(&args[1]); bf.execute(); }<|fim_middle|>fn main(...
code_fim
easy
{ "lang": "rust", "repo": "Mitafr/brainfuck-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vyugov/hbbft path: /src/honey_badger/error.rs use bincode; use failure::Fail; use crate::fault_log; use crate::subset; use crate::threshold_decrypt; /// Honey badger error variants. #[derive(Debug, Fail)] pub enum Error { /// Failed to serialize contribution. #[fail(display = "Error se...
code_fim
medium
{ "lang": "rust", "repo": "vyugov/hbbft", "path": "/src/honey_badger/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Faults detectable from receiving honey badger messages #[derive(Clone, Debug, Fail, PartialEq)] pub enum FaultKind { /// `HoneyBadger` received a decryption share for an unaccepted proposer. #[fail(display = "`HoneyBadger` received a decryption share for an unaccepted proposer.")] Unexpect...
code_fim
medium
{ "lang": "rust", "repo": "vyugov/hbbft", "path": "/src/honey_badger/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // returns 0 before first appearan& ce assert_eq!(Some(0), tree.rank(& 'l', 0)); assert_eq!(Some(0), tree.rank(& 'b', 2)); assert_eq!(Some(0), tree.rank(& 'r', 4)); assert_eq!(Some(0), tree.rank(& ' ', 5)); assert_eq!(Some(0), tree.rank(& 'd', 17)); ...
code_fim
hard
{ "lang": "rust", "repo": "halex97/rust-wavelet-trees", "path": "/src/pointers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: halex97/rust-wavelet-trees path: /src/pointers.rs t; use bv::BitVec; use rand::Rng; use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] pub struct PointerWaveletTree<T: PartialOrd + Clone> { alphabet: Vec<T>, root: WaveletTreeNode } impl <T: PartialOrd + Clone> super...
code_fim
hard
{ "lang": "rust", "repo": "halex97/rust-wavelet-trees", "path": "/src/pointers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match direction { Direction::North => Self { x: self.x, y: self.y - 1, }, Direction::East => Self { x: self.x + 1, y: self.y, }, Direction::West => Self { x: ...
code_fim
hard
{ "lang": "rust", "repo": "BenoitZugmeyer/RustyAdventOfCode", "path": "/2018/src/bin/day13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BenoitZugmeyer/RustyAdventOfCode path: /2018/src/bin/day13.rs use std::io::{stdin, BufRead}; #[derive(Debug, Clone, PartialEq, Eq)] enum Cell { Empty, StraightVertical, StraightHorizontal, TurnNorthLeft, TurnNorthRight, Intersection, } #[derive(Debug, Clone)] enum Direc...
code_fim
hard
{ "lang": "rust", "repo": "BenoitZugmeyer/RustyAdventOfCode", "path": "/2018/src/bin/day13.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut carts: Vec<Cart> = Vec::new(); let map: Vec<Vec<Cell>> = stdin() .lock() .lines() .filter_map(|l| l.ok()) .enumerate() .map(|(y, l)| { l.chars() .enumerate() .map(|(x, ch)| match ch { ...
code_fim
hard
{ "lang": "rust", "repo": "BenoitZugmeyer/RustyAdventOfCode", "path": "/2018/src/bin/day13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sebasv/pokerroom path: /src/communication.rs use crate::score::Score; use num_derive::FromPrimitive; use serde::{Deserialize, Serialize}; pub type Money = u32; #[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Copy, Debug)] pub enum RequestTable { RequestTable, Table(TableRe...
code_fim
hard
{ "lang": "rust", "repo": "sebasv/pokerroom", "path": "/src/communication.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Cards struct represents playing card. /// rank has range 2-14(aces high) but when evaluating straights includes 1(aces low). #[derive(Debug, PartialEq, PartialOrd, Eq, Ord, Clone, Copy, Serialize, Deserialize)] pub struct Card { pub rank: u8, pub suit: Suit, } /// Response from the callback. ...
code_fim
hard
{ "lang": "rust", "repo": "sebasv/pokerroom", "path": "/src/communication.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok((state.param(new_param).cost(residuals.l2_norm()), None)) } fn terminate(&mut self, state: &IterState<P, (), J, (), F>) -> TerminationStatus { if (state.get_prev_cost() - state.get_cost()).abs() < self.tol { return TerminationStatus::Terminated(TerminationReason::So...
code_fim
hard
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/src/solver/gaussnewton/gaussnewton_method.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: argmin-rs/argmin path: /argmin/src/solver/gaussnewton/gaussnewton_method.rs // Copyright 2018-2022 argmin 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/lice...
code_fim
hard
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/src/solver/gaussnewton/gaussnewton_method.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn jacobian(&self, _p: &Self::Param) -> Result<Self::Jacobian, Error> { Ok(Array::from_shape_vec((2, 2), vec![1f64, 2.0, 3.0, 4.0])?) } } // Single iteration, starting from [0, 0], gamma = 1 let problem = Problem { counter: RefCe...
code_fim
hard
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/src/solver/gaussnewton/gaussnewton_method.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>type variant = spanned[variant_]; type view_item = spanned[view_item_]; tag view_item_ { view_item_use(ident, vec[@meta_item], node_id); view_item_import(ident, vec[ident], node_id); view_item_import_glob(vec[ident], node_id); view_item_export(ident, node_id); } type obj_def_ids = rec(n...
code_fim
hard
{ "lang": "rust", "repo": "sayrer/rust", "path": "/src/comp/syntax/ast.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>// Distinguishes between attributes that decorate items and attributes that // are contained as statements within items. These two cases need to be // distinguished for pretty-printing. tag attr_style { attr_outer; attr_inner; } type attribute_ = rec(attr_style style, meta_item value); type item = rec(i...
code_fim
hard
{ "lang": "rust", "repo": "sayrer/rust", "path": "/src/comp/syntax/ast.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sayrer/rust path: /src/comp/syntax/ast.rs import std::vec; import codemap::span; import codemap::filename; type spanned[T] = rec(T node, span span); fn respan[T](&span sp, &T t) -> spanned[T] { ret rec(node=t, span=sp); } type ident = str; // Functions may or may not have names. type fn_ident...
code_fim
hard
{ "lang": "rust", "repo": "sayrer/rust", "path": "/src/comp/syntax/ast.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: williamhogman/food path: /src/lib.rs extern crate cfg_if; extern crate wasm_bindgen; mod qty; mod utils; mod recipe; use cfg_if::cfg_if; use wasm_bindgen::prelude::*; use recipe::Recipe; <|fim_suffix|>#[wasm_bindgen] pub fn recipe_to_html(x: String) -> String { let maybe_r = Recipe::fro...
code_fim
hard
{ "lang": "rust", "repo": "williamhogman/food", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen] pub fn recipe_to_html(x: String) -> String { let maybe_r = Recipe::from_string(x); if let Some(r) = maybe_r { r.to_html() } else { "Invalid format".to_string() } }<|fim_prefix|>// repo: williamhogman/food path: /src/lib.rs extern crate cfg_if; extern crate wasm_bindgen;...
code_fim
hard
{ "lang": "rust", "repo": "williamhogman/food", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yzhs/sokoban path: /src/macros.rs use crate::command::Command; /// A collection of macros, one for each of the F? keys, together with methods for recording and /// accessing them. #[derive(Debug, Default)] pub struct Macros { /// If a macro is currently being recorded, this is where its com...
code_fim
hard
{ "lang": "rust", "repo": "yzhs/sokoban", "path": "/src/macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn to_string(&self, slot: u8) -> String { let mut result = "".to_string(); for cmd in self.slots[slot as usize].iter().filter(|&c| !c.is_empty()) { result.push_str(&cmd.to_string()); } result } }<|fim_prefix|>// repo: yzhs/sokoban path: /src/macros....
code_fim
hard
{ "lang": "rust", "repo": "yzhs/sokoban", "path": "/src/macros.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn calculate(card: &Card, rating: f64, today: u32) -> Card { let percent_overdue = percent_overdue(card.interval, card.update, today); let difficulty = within_bounds(card.difficulty + (8.0 - 9.0 * rating) * percent_overdue / 17.0); le...
code_fim
hard
{ "lang": "rust", "repo": "monjohn/sm2-plus-rust", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if some_number < 0.0 { 0.0 } else if some_number > 1.0 { 1.0 } else { some_number } } fn new_interval(rating: f64, difficulty_weight: f64, percent_overdue: f64) -> u32 { if difficulty_weight == 0.0 { 1 ...
code_fim
hard
{ "lang": "rust", "repo": "monjohn/sm2-plus-rust", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: monjohn/sm2-plus-rust path: /src/lib.rs pub mod spacing { use std::time::{UNIX_EPOCH, SystemTime}; const DEFAULT_DIFFICULTY: f64 = 0.3; #[derive(Debug)] pub struct Card { pub question: String, pub answer: String, pub update: u32, pub interval: u...
code_fim
hard
{ "lang": "rust", "repo": "monjohn/sm2-plus-rust", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gtk4/src/subclass/text_view.rs // Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`TextView`](crate::TextView). use crate::subclass::prelude::*; use crate::{ DeleteType,...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gtk4/src/subclass/text_view.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, text_view: &Self::Type, step: MovementStep, count: i32, extend_selection: bool, ) { unsafe { let data = T::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GtkTextViewClass; if let Some(...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gtk4/src/subclass/text_view.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn run(self) { println!("Listening on {}", self.addr); let listener = TcpListener::bind(&self.addr).unwrap(); println!("{:?}", listener); loop { match listener.accept() { Ok((mut stream, _)) => { let mut buffer = [0; 1024]; match stream.read(&mut buf...
code_fim
medium
{ "lang": "rust", "repo": "satvik-1203/rust-apps", "path": "/httpserver/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: satvik-1203/rust-apps path: /httpserver/src/server.rs use crate::http::{request::Request, response::Response, status_code::StatusCode}; use std::convert::{TryFrom, TryInto}; use std::io::Read; use std::net::{TcpListener, TcpStream}; <|fim_suffix|>impl Server { pub fn new(addr: String) -> Sel...
code_fim
medium
{ "lang": "rust", "repo": "satvik-1203/rust-apps", "path": "/httpserver/src/server.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: songlinshu/winsafe path: /src/handles/mod.rs //! Win32 handles. #[macro_use] mod macros; mod any_handles; mod haccel; mod hbrush; mod hcursor; mod hdc; mod hdrop; mod hdwp; mod hfile; mod hfilemap; mod hfindfile; mod hfont; mod hglobal; mod hhook; mod hicon; mod himagelist; ...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/winsafe", "path": "/src/handles/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>NCE; pub use hkey::HKEY; pub use hlocal::HLOCAL; pub use hmenu::HMENU; pub use hpen::HPEN; pub use hpipe::HPIPE; pub use hprocess::HPROCESS; pub use hprocesslist::HPROCESSLIST; pub use hrgn::HRGN; pub use htheme::HTHEME; pub use hthread::HTHREAD; pub use hwnd::HWND;<|fim_prefix|>// repo: songli...
code_fim
hard
{ "lang": "rust", "repo": "songlinshu/winsafe", "path": "/src/handles/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crazymerlyn/imageviewer path: /src/main.rs #[macro_use] extern crate log; extern crate gtk; extern crate gdk_pixbuf; extern crate gdk; use std::env; use std::cell::RefCell as Rc; use gtk::prelude::*; use gdk::RGBA; use gdk::enums::modifier_type; use gdk::enums::key; use gtk::{ApplicationWin...
code_fim
hard
{ "lang": "rust", "repo": "crazymerlyn/imageviewer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let image: gtk::Image = builder.get_object("image").unwrap(); image.set_from_pixbuf(buf_manager.borrow().get_buf()); let window: ApplicationWindow = builder.get_object("window").unwrap(); let black = RGBA {red: 0.0, green:0.0, blue:0.0, alpha: 1.0}; window.override_background_color(ST...
code_fim
hard
{ "lang": "rust", "repo": "crazymerlyn/imageviewer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Index of a frame at which to notify external observers. pub frame: u32, /// Is the signal enabled or not. Disabled signals won't produce any events. pub enabled: bool, } impl Default for Signal { fn default() -> Self { Self { id: 0, frame: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "FyroxEngine/Fyrox", "path": "/src/animation/spritesheet/signal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FyroxEngine/Fyrox path: /src/animation/spritesheet/signal.rs //! Animation signal is used as a point at which to notify external observers that animation just //! started to play a specific frame. <|fim_suffix|>impl Default for Signal { fn default() -> Self { Self { id: ...
code_fim
hard
{ "lang": "rust", "repo": "FyroxEngine/Fyrox", "path": "/src/animation/spritesheet/signal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sssilver/servoto path: /src/photo.rs use error::WaldoError; use error::WaldoError::ParseError; use rexiv2::Metadata; use std::collections::HashMap; use std::str::FromStr; use storage_class::StorageClass; use xmltree::Element; #[derive(Debug)] pub struct PhotoResource { pub key: String, ...
code_fim
hard
{ "lang": "rust", "repo": "sssilver/servoto", "path": "/src/photo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Photo { pub fn new(key: &str, data: &[u8]) -> Result<Photo, WaldoError> { // Parse EXIF let meta = Metadata::new_from_buffer(data)?; let mut exif_tags = HashMap::new(); let tag_names = meta.get_exif_tags()?; for tag_name in tag_names { exif_ta...
code_fim
hard
{ "lang": "rust", "repo": "sssilver/servoto", "path": "/src/photo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)] pub struct Photo { #[serde(rename = "_id")] pub key: String, pub exif_tags: HashMap<String, String> } impl Photo { pub fn new(key: &str, data: &[u8]) -> Result<Photo, WaldoError> { // Parse EXIF let meta = Metadata::new_from_buffer...
code_fim
hard
{ "lang": "rust", "repo": "sssilver/servoto", "path": "/src/photo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Transformer { fn apply( r: &LinuxResources, properties: &mut Properties, cgroup_hierarchy: &CgroupHierarchy, systemd_version: &str, ) -> Result<()>; }<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/agent/rustjail/src/cgroups/systemd/subs...
code_fim
medium
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/agent/rustjail/src/cgroups/systemd/subsystem/transformer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> r: &LinuxResources, properties: &mut Properties, cgroup_hierarchy: &CgroupHierarchy, systemd_version: &str, ) -> Result<()>; }<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/agent/rustjail/src/cgroups/systemd/subsystem/transformer.rs // Copyright 2021...
code_fim
easy
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/agent/rustjail/src/cgroups/systemd/subsystem/transformer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kata-containers/kata-containers path: /src/agent/rustjail/src/cgroups/systemd/subsystem/transformer.rs // Copyright 2021-2022 Kata Contributors // // SPDX-License-Identifier: Apache-2.0 // <|fim_suffix|>pub trait Transformer { fn apply( r: &LinuxResources, properties: &mut P...
code_fim
medium
{ "lang": "rust", "repo": "kata-containers/kata-containers", "path": "/src/agent/rustjail/src/cgroups/systemd/subsystem/transformer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Unpin> Stream for RequestQueue<T> { type Item = QueuedRequest<T>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { if self.queued_requests.is_empty() { return Poll::Ready(None); } let pin = self.get_mut(); l...
code_fim
hard
{ "lang": "rust", "repo": "creptt/voyager", "path": "/src/requests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: creptt/voyager path: /src/requests.rs use futures::stream::Stream; use futures::Future; use futures_timer::Delay; use reqwest::header::HeaderMap; use reqwest::{StatusCode, Url}; use std::collections::VecDeque; use std::pin::Pin; use std::task::{Context, Poll}; use std::time::Duration; /// A req...
code_fim
hard
{ "lang": "rust", "repo": "creptt/voyager", "path": "/src/requests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Wrapper for `glfwWindowHint` called with `REFRESH_RATE`. #[fixed_stack_segment] #[inline(never)] pub fn refresh_rate(rate: int) { unsafe { ffi::glfwWindowHint(ffi::REFRESH_RATE, rate as c_int); } } /// Wrapper for `glfwWindowHint` called with `CLIENT_API`. #[fixed_stac...
code_fim
hard
{ "lang": "rust", "repo": "Kimundi/glfw3-rs", "path": "/src/glfw/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kimundi/glfw3-rs path: /src/glfw/lib.rs on() .map_default(Err(()), |ptr| Ok(Monitor { ptr: ptr })) } } /// Wrapper for `glfwGetMonitors`. #[fixed_stack_segment] #[inline(never)] pub fn get_connected() -> ~[Monitor] { unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "Kimundi/glfw3-rs", "path": "/src/glfw/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Wrapper for `glfwWindowHint` called with `RED_BITS`. #[fixed_stack_segment] #[inline(never)] pub fn red_bits(bits: uint) { unsafe { ffi::glfwWindowHint(ffi::RED_BITS, bits as c_int); } } /// Wrapper for `glfwWindowHint` called with `GREEN_BITS`. #[fixed_stack_segment] ...
code_fim
hard
{ "lang": "rust", "repo": "Kimundi/glfw3-rs", "path": "/src/glfw/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_unbalanced_bracket_in_string_with_escape() { test_helper(r#""lorem {"{\"{"} ipsum""#, r#""lorem {} ipsum","{\"{""#); } #[test] fn test_unbalanced_bracket_in_char() { test_helper(r#""lorem {'{'} ipsum""#, r#""lorem {} ipsum",'{'"#); } #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "sortmann/expression_format_impl", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_nested_argument() { test_helper( r#""lorem {dolor.sit} ipsum""#, r#""lorem {} ipsum",dolor.sit"#, ); } #[test] fn test_array_argument() { test_helper( r#""lorem {dolor[0]} ipsum""#, r#""lorem {} ip...
code_fim
hard
{ "lang": "rust", "repo": "sortmann/expression_format_impl", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sortmann/expression_format_impl path: /src/lib.rs //! Crate with macro implementations of `expression_format`. //! //! A separete crate is required to test procedural macros. extern crate proc_macro; use core::str::CharIndices; use proc_macro::TokenStream; use regex::Regex; use std::ops::Range...
code_fim
hard
{ "lang": "rust", "repo": "sortmann/expression_format_impl", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KaiserY/trpl-zh-cn path: /listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/src/main.rs fn main() { print_labeled_measurement(5, 'h'); } <|fim_suffix|> println!("The measurement is: {value}{unit_label}"); }<|fim_middle|>fn print_labeled_measuremen...
code_fim
medium
{ "lang": "rust", "repo": "KaiserY/trpl-zh-cn", "path": "/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("The measurement is: {value}{unit_label}"); }<|fim_prefix|>// repo: KaiserY/trpl-zh-cn path: /listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/src/main.rs fn main() { print_labeled_measurement(5, 'h'); } <|fim_middle|>fn print_labeled_measuremen...
code_fim
medium
{ "lang": "rust", "repo": "KaiserY/trpl-zh-cn", "path": "/listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fintanduffy/solana-iot-tps path: /program/src/instruction.rs //! instruction Contains the main ProgramInstruction enum use { crate::error::SampleError, borsh::BorshDeserialize, solana_program::program_error::ProgramError, }; #[derive(Debug, PartialEq)] /// All custom program instructions p...
code_fim
hard
{ "lang": "rust", "repo": "fintanduffy/solana-iot-tps", "path": "/program/src/instruction.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> key: String::try_from_slice(&block[1])?, value: String::try_from_slice(&block[2])?, }), 5 => Ok(Self::TransferBetweenAccountsWithFee { key: String::try_from_slice(&block[1])?, }), 6 => Ok(Self::BurnFromAccountWi...
code_fim
hard
{ "lang": "rust", "repo": "fintanduffy/solana-iot-tps", "path": "/program/src/instruction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flarelee/lunatic path: /stdlib/rust/src/channel.rs use std::alloc::{alloc, dealloc, Layout}; use std::fmt; use std::marker::PhantomData; use std::mem::transmute; use std::slice; use serde::de::{self, Deserialize, Deserializer, Visitor}; use serde::ser::{Serialize, Serializer}; use crate::{clon...
code_fim
hard
{ "lang": "rust", "repo": "flarelee/lunatic", "path": "/stdlib/rust/src/channel.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn deserialize_from_u64(id: u64) -> Self { let channel_externref = unsafe { stdlib::channel_deserialize(id) }; unsafe { Channel::from_externref(channel_externref) } } } impl<'de, T: Serialize + Deserialize<'de>> Serialize for Channel<T> { fn serialize<S>(&self, serializer:...
code_fim
hard
{ "lang": "rust", "repo": "flarelee/lunatic", "path": "/stdlib/rust/src/channel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("an pointer to an externref containing a channel") } fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> where E: de::Error, { let channel_externref = unsafe { stdl...
code_fim
hard
{ "lang": "rust", "repo": "flarelee/lunatic", "path": "/stdlib/rust/src/channel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tokio-rs/axum path: /axum-core/src/response/append_headers.rs use super::{IntoResponse, IntoResponseParts, Response, ResponseParts, TryIntoHeaderError}; use http::header::{HeaderName, HeaderValue}; use std::fmt; /// Append headers to a response. /// /// Returning something like `[("content-type...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum-core/src/response/append_headers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (key, value) in self.0 { let key = key.try_into().map_err(TryIntoHeaderError::key)?; let value = value.try_into().map_err(TryIntoHeaderError::value)?; res.headers_mut().append(key, value); } Ok(res) } }<|fim_prefix|>// repo: tokio-rs/axu...
code_fim
hard
{ "lang": "rust", "repo": "tokio-rs/axum", "path": "/axum-core/src/response/append_headers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn _start() -> ! { init_heap(); let mut vga = 0xb8000 as *mut VgaByte; let mut i = 0; let mut j = 0; let helloVga = to_vga (b"Hello world\n", VgaColor::Black, VgaColor::White); loop { for b in helloVga.iter() { unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "JoseD92/bare_rust", "path": "/hello_world/src/main copy 2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoseD92/bare_rust path: /hello_world/src/main copy 2.rs #![no_std] #![no_main] #![feature(default_alloc_error_handler)] extern crate alloc; use linked_list_allocator::LockedHeap; use alloc::vec::Vec; #[global_allocator] static ALLOCATOR: LockedHeap = LockedHeap::empty(); #[panic_handler] fn ...
code_fim
hard
{ "lang": "rust", "repo": "JoseD92/bare_rust", "path": "/hello_world/src/main copy 2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match opts.subcmd { SubCommand::Start(opts) => cmd::Start::new(&git, &store, &timer, opts, config).run()?, SubCommand::Next => cmd::Next::new(&git, &store, config).run()?, SubCommand::Done => cmd::Done::new(&git, &store, config).run()?, SubCommand::Clean => store.clean(...
code_fim
hard
{ "lang": "rust", "repo": "wusty/mob", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wusty/mob path: /src/main.rs use anyhow::Result; use clap::Clap; use remotemob::{cmd, config, emoji_logger, git, session, session::Store, timer}; #[derive(Clap)] #[clap(version = clap::crate_version!(), author = clap::crate_authors!())] struct Opts { #[clap(subcommand)] subcmd: SubComma...
code_fim
medium
{ "lang": "rust", "repo": "wusty/mob", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// ANCHOR: here fn la_plus_longue<'a>(x: &'a str, y: &str) -> &'a str { x } // ANCHOR_END: here<|fim_prefix|>// repo: Jimskapt/rust-book-fr path: /FRENCH/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/src/main.rs fn main() { let string1 = String::f...
code_fim
medium
{ "lang": "rust", "repo": "Jimskapt/rust-book-fr", "path": "/FRENCH/listings/ch10-generic-types-traits-and-lifetimes/no-listing-08-only-one-reference-with-lifetime/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let cfg = cfg(None); assert_eq!( table().transformed_query_to(Some(&cfg), 0).unwrap(), "COPY some_table(\"col1\", \"col2\") TO STDOUT" ); assert_eq!(table().untransformed_query_to(Some(&cfg), 0), None); assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "janmeier/datanymizer", "path": "/datanymizer_dumper/src/postgres/table.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: janmeier/datanymizer path: /datanymizer_dumper/src/postgres/table.rs use super::{column::PgColumn, dumper::PgDumper, row::PgRow, sequence::PgSequence}; use crate::Table; use datanymizer_engine::{Query as QueryCfg, Table as TableCfg}; use postgres::{types::Type, Row as PostgresRow}; use std::{ ...
code_fim
hard
{ "lang": "rust", "repo": "janmeier/datanymizer", "path": "/datanymizer_dumper/src/postgres/table.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> table.set_columns(vec![col1.clone(), col2.clone(), col3.clone()]); assert_eq!(table.columns, vec![col1, col2, col3]); assert_eq!(table.column_indexes.len(), 3); assert_eq!(table.column_indexes["col1"], 0); assert_eq!(table.column_indexes["col2"], 1); asser...
code_fim
hard
{ "lang": "rust", "repo": "janmeier/datanymizer", "path": "/datanymizer_dumper/src/postgres/table.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Want this to return a Token<T> channel, and maybe spawn a lexing // task that writes to the channel. For now, just return a list of tokens fn run(&self, file: ~str) -> ~[~Token<T>] { ~[] } } */<|fim_prefix|>// repo: rstout/rust path: /parst/lexer.rs //use token::Token; pub enu...
code_fim
medium
{ "lang": "rust", "repo": "rstout/rust", "path": "/parst/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rstout/rust path: /parst/lexer.rs //use token::Token; pub enum LexCmd { Symbol(char), } impl LexCmd { pub fn accepts(self, c: char) -> bool { match self { Symbol(sym) => c == sym, } } pub fn print(self) { match self { Symbol(c) =...
code_fim
hard
{ "lang": "rust", "repo": "rstout/rust", "path": "/parst/lexer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: villekalliomaki/async-graphql path: /derive/src/scalar.rs use proc_macro::TokenStream; use quote::quote; use syn::ItemImpl; use crate::args::{self, RenameTarget}; use crate::utils::{ get_crate_name, get_rustdoc, get_type_path_and_name, visible_fn, GeneratorResult, }; pub fn generate( s...
code_fim
hard
{ "lang": "rust", "repo": "villekalliomaki/async-graphql", "path": "/derive/src/scalar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }