text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let mut stmt = conn .prepare("SELECT select id, name_id, name, is_cereal, proxy_crop_id, proxy_adaption_factor FROM yieldstat_crop where crop_id = ? and use_in_landcare = 1") .unwrap(); stmt .query_row(&[crop_id], |row| CropInfo { id: row.get(0), name_id: row.get...
code_fim
hard
{ "lang": "rust", "repo": "zalf-rpm/yieldstat_rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zalf-rpm/yieldstat_rs path: /src/lib.rs extern crate rusqlite; extern crate time; //use rusqlite::types::ToSql; //use time::Timespec; pub mod yieldstat { use std::path::Path; type CropId = i32; type STTCode = i32; pub enum TillageType { Plough, Conserving, NoTillage, }...
code_fim
hard
{ "lang": "rust", "repo": "zalf-rpm/yieldstat_rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use std::io::File; let source_path = Path::new(cx.codemap().span_to_filename(sp)); let path = source_path.dir_path().join(path); let mut file = try!(File::open(&path)); file.read_to_string() } fn mk_doc_attr(doc_string: String) -> Attribute { use syntax::attr; let meta_item =...
code_fim
hard
{ "lang": "rust", "repo": "tomjakubowski/doc_file", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomjakubowski/doc_file path: /src/lib.rs #![feature(phase, plugin_registrar)] extern crate rustc; extern crate syntax; #[phase(plugin, link)] extern crate log; use rustc::plugin::Registry; use syntax::ast::{Attribute, Item, MetaItem}; use syntax::ext::base::{ExtCtxt, ItemModifier, SyntaxExten...
code_fim
hard
{ "lang": "rust", "repo": "tomjakubowski/doc_file", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn expand_attr(cx: &mut ExtCtxt, sp: Span, meta: &MetaItem, item: P<Item>) -> P<Item> { item.map(|mut item| { if let Err(e) = expand_attr_(cx, sp, meta, &mut item.attrs) { match e { AttrError::Path => { cx.span_err(sp, "Invalid pat...
code_fim
hard
{ "lang": "rust", "repo": "tomjakubowski/doc_file", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ichyo/cargo-snippet path: /src/snippet.rs use std::collections::{BTreeMap, BTreeSet, HashSet}; pub struct SnippetAttributes { // A snippet with multiple names is allowed but using dependency is recommended. pub names: HashSet<String>, // Dependencies pub uses: HashSet<String>, }...
code_fim
hard
{ "lang": "rust", "repo": "ichyo/cargo-snippet", "path": "/src/snippet.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut res: BTreeMap<String, String> = BTreeMap::new(); for (name, uses) in &deps { let mut used = HashSet::new(); used.insert(name.clone()); let mut stack = uses.iter().cloned().collect::<Vec<_>>(); while let Some(dep) = stack.pop() { if !used.contai...
code_fim
hard
{ "lang": "rust", "repo": "ichyo/cargo-snippet", "path": "/src/snippet.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> struct Recurrence { mem: [u64; 2], pos: usize, } struct IndexOffset<'a> { slice: &'a [u64; 2], offset: usize, } impl<'a> Index<usize> for IndexOffset<'a> { type Output = u64; #[inl...
code_fim
hard
{ "lang": "rust", "repo": "kyleburton/sandbox", "path": "/examples/rust/programming-rust/practical-intro-to-macros/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyleburton/sandbox path: /examples/rust/programming-rust/practical-intro-to-macros/src/main.rs // NB: -Z and --pretty only work on the nightly unstable compiler :/ // so no macro help w/the release rust toolchain? // rustc -Z unstable-options --pretty expanded recurrence.rs /* // 'a is a lif...
code_fim
hard
{ "lang": "rust", "repo": "kyleburton/sandbox", "path": "/examples/rust/programming-rust/practical-intro-to-macros/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn degrees_to_radians(degree_val: f64) -> f64 { PI * degree_val / 180.0 }<|fim_prefix|>// repo: vincent-prz/ray_tracer_in_one_weekend path: /src/utils.rs pub fn clamp(x: f64, min: f64, max: f64) -> f64 { if x < min { return min } if x > max { return max } x } ...
code_fim
easy
{ "lang": "rust", "repo": "vincent-prz/ray_tracer_in_one_weekend", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vincent-prz/ray_tracer_in_one_weekend path: /src/utils.rs pub fn clamp(x: f64, min: f64, max: f64) -> f64 { if x < min { return min } if x > max { return max } x } <|fim_suffix|>pub fn degrees_to_radians(degree_val: f64) -> f64 { PI * degree_val / 180.0 }...
code_fim
easy
{ "lang": "rust", "repo": "vincent-prz/ray_tracer_in_one_weekend", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut preview = Scrollable::new(&mut self.preview).style(self.palette); for (i, (old, new)) in self .rename .iter() .sorted_by_key(|(old, _new)| *old) .enumerate() { let mut container = Container::new( Co...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/SimpleRenamer", "path": "/src/bin/gui/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn update( &mut self, message: Self::Message, _clipboard: &mut iced::Clipboard, ) -> iced::Command<Self::Message> { self.error_msg = String::new(); match message { Message::EditFileName(value) => { self.input_value = value; ...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/SimpleRenamer", "path": "/src/bin/gui/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lineCode/SimpleRenamer path: /src/bin/gui/main.rs #![windows_subsystem = "windows"] mod style; use crate::style::*; use iced::{ button, executor, scrollable, text_input, window, Application, Button, Column, Command, Container, Element, HorizontalAlignment, Length, Row, Scrollable, Settin...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/SimpleRenamer", "path": "/src/bin/gui/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/robt path: /src/scans.rs use mkit::{ self, db::{self, Bloom}, }; use std::{cmp, convert::TryFrom, hash, marker, time}; use crate::{Error, Result}; // Iterator wrapper, to wrap full-table scanners and count seqno, // index-items, deleted items and epoch. pub struct BuildScan<K,...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/robt", "path": "/src/scans.rs", "mode": "psm", "license": "LicenseRef-scancode-dco-1.1", "source": "the-stack-v2" }
<|fim_suffix|>impl<K, V, D, I> CompactScan<K, V, D, I> { pub fn new(iter: I, cutoff: db::Cutoff) -> Self { CompactScan { iter, cutoff, _key: marker::PhantomData, _val: marker::PhantomData, _dff: marker::PhantomData, } } } impl<K, V, D...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/robt", "path": "/src/scans.rs", "mode": "spm", "license": "LicenseRef-scancode-dco-1.1", "source": "the-stack-v2" }
<|fim_suffix|> match base64::hex_to_base64(&hex.trim()) { Ok(v) => { println!("base64: {}", v); exit_ok!() } Err(e) => { println!("{}", e); exit_err!() } } }<|fim_prefix|>// repo: amol9/matasano path: /src/set1/hextobase64.rs use common::{base64, challenge, util}; pub static info: challenge::Info = challenge::...
code_fim
medium
{ "lang": "rust", "repo": "amol9/matasano", "path": "/src/set1/hextobase64.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amol9/matasano path: /src/set1/hextobase64.rs use common::{base64, challenge, util}; pub static info: challenge::Info = challenge::Info { no: 1, title: "Convert hex to base64", help: "", execute_fn: interactive }; <|fim_suffix|> match base64::hex_to_base64(...
code_fim
medium
{ "lang": "rust", "repo": "amol9/matasano", "path": "/src/set1/hextobase64.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { Pg_magic_data = postgres_extension::Pg_magic_struct { len: size_of::<postgres_extension::Pg_magic_struct>() as c_int, version: $vers / 100, funcmaxargs: 100, indexmaxkeys: 32, ...
code_fim
hard
{ "lang": "rust", "repo": "stereobooster/postgres-extension.rs", "path": "/macros/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stereobooster/postgres-extension.rs path: /macros/src/lib.rs /// Postgres has a macro called `PG_MODULE_MAGIC` that is supposed /// to be called within extensions. This generates a bunch /// of metadata structures that Postgres reads to determine /// the compatibility of the extension. /// /// `...
code_fim
hard
{ "lang": "rust", "repo": "stereobooster/postgres-extension.rs", "path": "/macros/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> CString::new(str).unwrap_or_else(|_| CString::new(str.replace('\0', "")).unwrap()) } unsafe fn from_cstring(ptr: *const c_char) -> String { CStr::from_ptr(ptr).to_string_lossy().into_owned() } unsafe fn from_cstring_opt(ptr: *const c_char) -> Option<String> { if ptr.is_null() { None ...
code_fim
hard
{ "lang": "rust", "repo": "pie-flavor/hexchat-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pie-flavor/hexchat-rs path: /src/lib.rs //! A safe API for creating HexChat plugins. //! //! To get started, create a struct representing your plugin, and implement `Plugin` for it. Then, //! call `plugin!` on the struct. //! //! All plugins should be built as cdylibs, or if for some reason you ...
code_fim
hard
{ "lang": "rust", "repo": "pie-flavor/hexchat-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risooonho/bytepath-rs path: /src/systems/bounds.rs use nphysics2d::object::{BodyHandle, RigidBody}; use specs::world::*; use specs::*; use crate::components::*; use crate::entities::*; use crate::resources::*; <|fim_suffix|>impl<'a> System<'a> for BoundsSystem { type SystemData = ( Read<...
code_fim
medium
{ "lang": "rust", "repo": "risooonho/bytepath-rs", "path": "/src/systems/bounds.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let explode_bounds_component: Option<&ExplodeBoundsComponent> = explode_bounds.get(entity); if let Some(_) = explode_bounds_component { let position_component = PositionComponent { x: position.x, y: position.y, angle: 0.0, }; ...
code_fim
hard
{ "lang": "rust", "repo": "risooonho/bytepath-rs", "path": "/src/systems/bounds.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn multiple_input<T: std::str::FromStr>() -> Result<Vec<T>, T::Err> { let mut s = String::new(); std::io::stdin() .read_line(&mut s) .expect("Value not found"); s.trim() .split_whitespace() .map(|word| word.parse()) .collect() } fn fibo(n: usize...
code_fim
medium
{ "lang": "rust", "repo": "aa-ryan/DSA", "path": "/Algorithmic_Toolbox/week2/againlastdigitsum/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut a = 0; let mut b = 1; let mut c = 0; for _ in 2..n+1 { c = a+b; c = c % 10; let temp = b; b = c; a = temp; } c-1 }<|fim_prefix|>// repo: aa-ryan/DSA path: /Algorithmic_Toolbox/week2/againlastdigitsum/src/main.rs fn main() { le...
code_fim
hard
{ "lang": "rust", "repo": "aa-ryan/DSA", "path": "/Algorithmic_Toolbox/week2/againlastdigitsum/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aa-ryan/DSA path: /Algorithmic_Toolbox/week2/againlastdigitsum/src/main.rs fn main() { let inp = multiple_input::<usize>().unwrap(); let m = inp[0]; let n = inp[1]; if n <= 1 { println!("{}", n); std::process::exit(1); } let less_n = (n + 2) % 60; l...
code_fim
hard
{ "lang": "rust", "repo": "aa-ryan/DSA", "path": "/Algorithmic_Toolbox/week2/againlastdigitsum/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn delete( id: Identity, db: web::Data<Database>, info: web::Path<(u64,)>, // params: web::Form<DeleteRequest> ) -> HttpResponse { let user_id = identity_user_id!(id); match app_api::api_191103::group_delete(&db, info.0, user_id) { Ok(()) => HttpResponse::Ok().json(De...
code_fim
hard
{ "lang": "rust", "repo": "luojia65/Classistant", "path": "/classistant-server/src/http_api/groups.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luojia65/Classistant path: /classistant-server/src/http_api/groups.rs pub mod members; pub mod owner; use actix_web::{web, HttpResponse}; use actix_identity::Identity; use serde::{Serialize};// , Deserialize}; use crate::app_api; use crate::db::Database; use crate::http_api::ErrorResponse; // ...
code_fim
hard
{ "lang": "rust", "repo": "luojia65/Classistant", "path": "/classistant-server/src/http_api/groups.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Default)] pub struct CreateResponse { group_id: u64 } pub fn create( id: Identity, db: web::Data<Database>, // params: web::Form<CreateRequest> ) -> HttpResponse { let user_id = identity_user_id!(id); match app_api::api_191103::group_create(&db, user_id) { ...
code_fim
medium
{ "lang": "rust", "repo": "luojia65/Classistant", "path": "/classistant-server/src/http_api/groups.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_future( &self, mime_types: &[&str], io_priority: glib::Priority, ) -> Pin< Box< dyn future::Future<Output = Result<(gio::InputStream, GString), glib::Error>> + 'static, >, > { let mime_types = mime_types .iter(...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gdk4/src/clipboard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /gdk4/src/clipboard.rs // Take a look at the license at the top of the repository in the LICENSE file. use crate::Clipboard; use glib::object::IsA; use glib::translate::*; use glib::GString; use std::future; use std::pin::Pin; use std::ptr; impl Clipboard { #[doc(alia...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/gdk4/src/clipboard.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ut-utp/playground path: /hdl/src/wires/index.rs use super::{BitCountType, Wire}; use core::ops::{Index, IndexMut}; // Warning! Indexes by byte (not bit). This isn't very useful. impl<const B: BitCountType, const S: usize> Index<usize> for Wire<{B}, {S}> { type Output = u8; fn index(&s...
code_fim
medium
{ "lang": "rust", "repo": "ut-utp/playground", "path": "/hdl/src/wires/index.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn index_bytes() { assert_eq!(w!(1#0)[0], 0u8); assert_eq!(w!(8*8)[7], 0u8); assert_eq!(w!((8*7)#core::u64::MAX)[7], 255u8); } }<|fim_prefix|>// repo: ut-utp/playground path: /hdl/src/wires/index.rs use super::{BitCountType, Wire}; use core::ops::{Index, Index...
code_fim
hard
{ "lang": "rust", "repo": "ut-utp/playground", "path": "/hdl/src/wires/index.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casey/office-hours path: /strs/src/error.rs use crate::common::*; <|fim_suffix|> Error::Io(io_error) } }<|fim_middle|>#[derive(Debug)] pub enum Error { Io(io::Error), } impl From<io::Error> for Error { fn from(io_error: io::Error) -> Error {
code_fim
medium
{ "lang": "rust", "repo": "casey/office-hours", "path": "/strs/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Error::Io(io_error) } }<|fim_prefix|>// repo: casey/office-hours path: /strs/src/error.rs use crate::common::*; <|fim_middle|>#[derive(Debug)] pub enum Error { Io(io::Error), } impl From<io::Error> for Error { fn from(io_error: io::Error) -> Error {
code_fim
medium
{ "lang": "rust", "repo": "casey/office-hours", "path": "/strs/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casey/office-hours path: /strs/src/error.rs use crate::common::*; #[derive(Debug)] pub enum Error { Io(io::Error), } <|fim_suffix|> Error::Io(io_error) } }<|fim_middle|>impl From<io::Error> for Error { fn from(io_error: io::Error) -> Error {
code_fim
medium
{ "lang": "rust", "repo": "casey/office-hours", "path": "/strs/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erochest/straw-boss path: /tests/daemon.rs extern crate assert_cmd; #[macro_use] extern crate failure; extern crate spectral; extern crate straw_boss; extern crate sysinfo; use spectral::assert_that; use spectral::prelude::*; use std::thread; use std::time::Duration; mod utils; <|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "erochest/straw-boss", "path": "/tests/daemon.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod utils; use utils::command::StopServer; use utils::poll::poll_processes; #[test] fn test_daemon() { let mut server = StopServer::new("test-daemon"); server.daemonize("./fixtures/Procfile.python").unwrap(); let process_info = poll_processes("http.server", "3040", 10); assert_that(&pro...
code_fim
medium
{ "lang": "rust", "repo": "erochest/straw-boss", "path": "/tests/daemon.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use super::k8::K8EnvironmentDriver; use super::local::LocalEnvDriver; pub fn create_driver(option: TestOption) -> Box<dyn EnvironmentDriver> { if option.use_k8_driver() { println!("using k8 environment driver"); Box::new(K8EnvironmentDriver::new(option)) as Box...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/tests/runner/src/environment/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vijaylaxmid/fluvio path: /tests/runner/src/environment/mod.rs mod k8; mod local; pub use common::*; mod common { use std::process::Command; use async_trait::async_trait; use crate::TestOption; /// Environment driver for test #[async_trait] pub trait EnvironmentDrive...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/tests/runner/src/environment/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if option.tls() { let client_dir = Cert::load_client(&option.tls_user); cmd.arg("--tls") .arg("--domain") .arg("fluvio.local") .arg("--ca-cert") .arg(client_dir.ca.as_os_str()) ...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/tests/runner/src/environment/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run_rogcat_with_input_file(args: &SVec, payload: &SVec) -> Result<(bool, SVec), Error> { let input = tempfile_with_content(payload).expect("Failed to crate input file"); let mut a = svec!("-i", format!("{}", input.display())); a.extend(args.clone()); run_rogcat(&a, None) } #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "rafamatias/rogcat", "path": "/src/tests/utils.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rafamatias/rogcat path: /src/tests/utils.rs // Copyright © 2017 Felix Obenhuber // This program is free software. It comes without any warranty, to the extent // permitted by applicable law. You can redistribute it and/or modify it under // the terms of the Do What The Fuck You Want To Public Li...
code_fim
hard
{ "lang": "rust", "repo": "rafamatias/rogcat", "path": "/src/tests/utils.rs", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> else { println!("bad opcode ip: {}, code: {} ", *instpointer, program[*instpointer]); break; } if *instpointer>=program.len() { println!("ran past end of program"); break; } } return retval; } pub fn fi64(value:i64) -> num_bigint::BigInt { return nu...
code_fim
hard
{ "lang": "rust", "repo": "wilfriedschmidt/adventofcode2019", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wilfriedschmidt/adventofcode2019 path: /src/util.rs use std::fs::File; use std::io::prelude::*; use std::error::Error; extern crate num_bigint; extern crate num_traits; pub fn readfile(filename:&str) -> Vec<u8> { let mut file = match File::open(&filename) { Err(why) => panic!("couldn't ...
code_fim
hard
{ "lang": "rust", "repo": "wilfriedschmidt/adventofcode2019", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn train(&mut self, history : &Vec<HistoryStep>, history_metadata : &HistoryMetadata, input_window : u32, prediction_window : u32, extra_params : &Self::TrainingParams) -> anyhow::Result<()>; fn predict(&mut self, input : &Vec<HistoryStep>) -> anyhow::Result<(f32, f32)...
code_fim
medium
{ "lang": "rust", "repo": "Boulougou/trading-bot", "path": "/lib/src/trading_model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Boulougou/trading-bot path: /lib/src/trading_model.rs use crate::trading_service::HistoryStep; #[cfg(test)] use mockall::{automock}; use crate::{HistoryMetadata, HistoryTimeframe}; #[cfg_attr(test, automock(type TrainingParams = f32;))] pub trait TradingModel { type TrainingParams;...
code_fim
hard
{ "lang": "rust", "repo": "Boulougou/trading-bot", "path": "/lib/src/trading_model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input_window : u32, prediction_window : u32, extra_params : &Self::TrainingParams) -> anyhow::Result<()>; fn predict(&mut self, input : &Vec<HistoryStep>) -> anyhow::Result<(f32, f32)>; fn calculate_loss(&mut self, predictions : &[(f32, f32)], expectations : &[(f32, f3...
code_fim
medium
{ "lang": "rust", "repo": "Boulougou/trading-bot", "path": "/lib/src/trading_model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tismith/device-checkout-rs path: /src/lib.rs #![feature(plugin, proc_macro_hygiene, decl_macro, custom_attribute)] //#[macro_use] //this crate has macros, currently unused pub extern crate failure; #[macro_use] pub extern crate log; pub e<|fim_suffix|> pub extern crate exitfailure; #[macro_use]...
code_fim
hard
{ "lang": "rust", "repo": "tismith/device-checkout-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub extern crate exitfailure; #[macro_use] extern crate validator_derive; extern crate validator; pub mod database; pub mod models; pub mod pool; pub mod routes; pub mod schema; pub mod utils;<|fim_prefix|>// repo: tismith/device-checkout-rs path: /src/lib.rs #![feature(plugin, proc_macro_hygiene, decl...
code_fim
medium
{ "lang": "rust", "repo": "tismith/device-checkout-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielKeep/rust-scan-rules path: /tests/case_match.rs /* Copyright ⓒ 2016 Daniel Keep. Licensed under the MIT license (see LICENSE or <http://opensource.org /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All file...
code_fim
hard
{ "lang": "rust", "repo": "DanielKeep/rust-scan-rules", "path": "/tests/case_match.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_match!( scan!(StrCursor::<IgnoreCaseNormalized>::new(inp); ("UPPERCASE", "lowerCase", "mIxeDcAsE", "TitleCase") => ()), Ok(()) ); assert_match!( scan!(StrCursor::<IgnoreCaseNormalized>::new(inp); ("UPPERCASE", "lowercase", "mIxEdcAsE", "T...
code_fim
hard
{ "lang": "rust", "repo": "DanielKeep/rust-scan-rules", "path": "/tests/case_match.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_match!( scan!(StrCursor::<IgnoreAsciiCase>::new(inp); ("UPPERCASE", "lowerCase", "mIxeDcAsE", "TitleCase") => ()), Ok(()) ); assert_match!( scan!(StrCursor::<IgnoreAsciiCase>::new(inp); ("UPPERCASE", "lowercase", "mIxEdcAsE", "TitleCase")...
code_fim
hard
{ "lang": "rust", "repo": "DanielKeep/rust-scan-rules", "path": "/tests/case_match.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if label.len() > 0 { println!("{}", label); } println!("move: {}", state.cur_move); println!("{}", state.facility); } fn process_state(state: &State, states: &mut LinkedList<State>, visited: &mut HashSet<String>) -> bool { // print_state(&state, "generating next state...
code_fim
hard
{ "lang": "rust", "repo": "jblee123/advent_of_code_2016", "path": "/day11/b/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jblee123/advent_of_code_2016 path: /day11/b/main.rs use std::collections::HashMap; use std::collections::HashSet; use std::collections::LinkedList; use std::fmt; use std::fs; const NUM_FLOORS: usize = 4; #[derive(Clone, Debug)] enum Item { Chip(u32), Generator(u32), } impl fmt::Displa...
code_fim
hard
{ "lang": "rust", "repo": "jblee123/advent_of_code_2016", "path": "/day11/b/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for chip_num in chips { if !generators.is_empty() && !generators.contains(&chip_num) { return false; } } } true } fn apply_facility_mutation( facility: &Facility, new_floor_idx: usize, items_to_move: &Vec<Item>, new_floor: &Floor, v...
code_fim
hard
{ "lang": "rust", "repo": "jblee123/advent_of_code_2016", "path": "/day11/b/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, items: I, vars: Option<J>, ) -> Result<(), Box<dyn std::error::Error>> where I: IntoIterator<Item = alfred::Item<'a>>, J: IntoIterator<Item = (&'b str, &'b str)>, { debug!("Starting in write_output_items"); let mut output_items = i...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/alfred-pinboard-rs", "path": "/src/commands/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spamwax/alfred-pinboard-rs path: /src/commands/mod.rs use std::io; use std::{env, process}; use crate::cli::SubCommand; use crate::workflow_config::Config; use rusty_pin::{PinBuilder, Pinboard, Tag}; pub mod config; mod delete; mod list; mod post; mod rename; mod search; mod update; mod upgra...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/alfred-pinboard-rs", "path": "/src/commands/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn get_upgrade_item(&self) -> Result<Option<alfred::Item>, Box<dyn std::error::Error>> { debug!("Starting in get_upgrade_item"); self.updater .as_ref() .unwrap() .update_ready() .map(|update| { if update { ...
code_fim
hard
{ "lang": "rust", "repo": "spamwax/alfred-pinboard-rs", "path": "/src/commands/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn kind_from_raw(raw: rowan::SyntaxKind) -> Self::Kind { assert!(raw.0 <= SyntaxKind::Root as u16); // Safety: // - Root variant is always the last variant of the SyntaxKind enum. unsafe { mem::transmute::<u16, SyntaxKind>(raw.0) } } fn kind_to_raw(kind: Self::...
code_fim
medium
{ "lang": "rust", "repo": "mbrobbel/tydi-lang", "path": "/crates/syntax/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> kind.into() } } pub type SyntaxToken = rowan::SyntaxToken<TydiLang>; pub type SyntaxNode = rowan::SyntaxNode<TydiLang>; pub type SyntaxElement = rowan::SyntaxElement<TydiLang>;<|fim_prefix|>// repo: mbrobbel/tydi-lang path: /crates/syntax/src/lib.rs use std::mem; use tydi_lang_lexer::TokenKi...
code_fim
hard
{ "lang": "rust", "repo": "mbrobbel/tydi-lang", "path": "/crates/syntax/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mbrobbel/tydi-lang path: /crates/syntax/src/lib.rs use std::mem; use tydi_lang_lexer::TokenKind; #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[repr(u16)] pub enum SyntaxKind { // Safety: // - The variants in this enum **must** extend TokenKind from lexer. Type, Equals, Semi...
code_fim
hard
{ "lang": "rust", "repo": "mbrobbel/tydi-lang", "path": "/crates/syntax/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> void *handle, const char *info ) { if (!handle) { fprintf(stderr, "\n Error in %s: Creation failed: invalid handle\n", info); exit (1); } } fn main() { let domain_participant = DomainParticipant::create_participant("HelloWorld example"); let message_seq = sequen...
code_fim
medium
{ "lang": "rust", "repo": "makerj/rust-dds", "path": "/src/helloworld_subscriber.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const char *info ) { if (!handle) { fprintf(stderr, "\n Error in %s: Creation failed: invalid handle\n", info); exit (1); } } fn main() { let domain_participant = DomainParticipant::create_participant("HelloWorld example"); let message_seq = sequence_helloworld_data...
code_fim
medium
{ "lang": "rust", "repo": "makerj/rust-dds", "path": "/src/helloworld_subscriber.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makerj/rust-dds path: /src/helloworld_subscriber.rs extern crate dds; use dds::api::DomainParticipant; use dds::api::Subscriber; use dds::api::DataReader; use dds::api::TypeSupport; use ::DDS_sequence_HelloWorldData_Msg::*; fn check_handle(ts: TypeSupport, msg: &'static str) { if } <|fim_s...
code_fim
medium
{ "lang": "rust", "repo": "makerj/rust-dds", "path": "/src/helloworld_subscriber.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait FromPrimitive<T>: Sized { fn from(i: T) -> Option<Self>; } macro_rules! impl_from_primitive_ty { ($($ty:ident),*) => { $( impl FromPrimitive<$ty> for $ty { #[inline] fn from(i: $ty) -> Option<$ty> { Some(i) } } ...
code_fim
hard
{ "lang": "rust", "repo": "Orangenosecom/tiberius", "path": "/src/protocol/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Orangenosecom/tiberius path: /src/protocol/util.rs use std::io; use std::io::prelude::*; use encoding::{Encoding, EncoderTrap, DecoderTrap}; use encoding::all::UTF_16LE; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use ::{TdsResult}; #[doc(hidden)] pub trait WriteCStr { fn w...
code_fim
hard
{ "lang": "rust", "repo": "Orangenosecom/tiberius", "path": "/src/protocol/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn read_us_varchar(&mut self) -> TdsResult<String> { let len = try!(self.read_u16::<LittleEndian>()) as usize; self.read_varchar(len) } #[inline] fn read_b_varchar(&mut self) -> TdsResult<String> { let len = try!(self.read_u8()) as usize; self...
code_fim
hard
{ "lang": "rust", "repo": "Orangenosecom/tiberius", "path": "/src/protocol/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oberien/heradoc path: /src/error.rs use std::io; use std::result; use std::fmt; use diagnostic::ErrorCode; pub type Result<T> = result::Result<T, Error>; pub type FatalResult<T> = result::Result<T, Fatal>; #[must_use] #[derive(Debug)] pub enum Fatal { /// Output file write error. Outpu...
code_fim
hard
{ "lang": "rust", "repo": "oberien/heradoc", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> GraphvizError, TempFileError, InvalidConfigPath(String), InvalidHeaderLevel, Unsupported, SvgConversionError, EspeakCreationError, InternalCompilerError, } impl ErrorCode for DiagnosticCode { fn code(&self) -> String { match self { DiagnosticCode::...
code_fim
hard
{ "lang": "rust", "repo": "oberien/heradoc", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn message(&self) -> String { match self { DiagnosticCode::FoundTwoLabels => "found two labels".to_string(), DiagnosticCode::InvalidFigureValue => "invalid figure attribute value".to_string(), DiagnosticCode::MultipleFigureKeys => "found multiple figure keys...
code_fim
hard
{ "lang": "rust", "repo": "oberien/heradoc", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>named!( nom_ecdsa<(&[u8], &[u8])>, do_parse!( _key_type: length_bytes!(be_u32) >> curve: length_bytes!(be_u32) >> point: length_bytes!(be_u32) >> (curve, point) ) ); pub fn peek_algorithm(is_encrypted: bool, key_bytes: &[u8]) -> Result<Algorithm, St...
code_fim
hard
{ "lang": "rust", "repo": "focusaurus/tealeaves", "path": "/src/ssh_key.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn peek_algorithm(is_encrypted: bool, key_bytes: &[u8]) -> Result<Algorithm, String> { if key_bytes.len() < 4 { return Err("Too short to be a valid ssh key".into()); } let mut algorithm = Algorithm::Unknown; // Skip 4-byte length indicator let algorithm_name = &key_bytes[4....
code_fim
hard
{ "lang": "rust", "repo": "focusaurus/tealeaves", "path": "/src/ssh_key.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: focusaurus/tealeaves path: /src/ssh_key.rs use nom; use nom::be_u32; use std::fmt; #[derive(PartialEq, Eq, Debug)] pub enum Algorithm { Unknown, Ed25519(Vec<u8>), Rsa(Vec<u8>), Ecdsa(String, Vec<u8>), Dsa(Vec<u8>), } impl fmt::Display for Algorithm { fn fmt(&self, out: ...
code_fim
hard
{ "lang": "rust", "repo": "focusaurus/tealeaves", "path": "/src/ssh_key.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> withdraw_collateral { let origin: T::AccountId = account("Origin", 0, 0); let _ = T::DOT::make_free_balance_be(&origin, (1u32 << 31).into()); let u in 0 .. 100; VaultRegistry::<T>::_register_vault(&origin, u.into(), dummy_public_key()).unwrap(); }: _(RawOrigin::Sign...
code_fim
hard
{ "lang": "rust", "repo": "p9c/duo-parachain", "path": "/crates/vault-registry/src/benchmarking.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..u { let origin: T::AccountId = account("Origin", i, 0); let _ = T::DOT::make_free_balance_be(&origin, (1u32 << 31).into()); VaultRegistry::<T>::_register_vault(&origin, 1234567u32.into(), dummy_public_key()).unwrap(); } // sanity chec...
code_fim
hard
{ "lang": "rust", "repo": "p9c/duo-parachain", "path": "/crates/vault-registry/src/benchmarking.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: p9c/duo-parachain path: /crates/vault-registry/src/benchmarking.rs use super::*; use crate::{ sp_api_hidden_includes_decl_storage::hidden_include::traits::Currency, types::BtcPublicKey, Pallet as VaultRegistry, }; use exchange_rate_oracle::Pallet as ExchangeRateOracle; use frame_benchmarking...
code_fim
hard
{ "lang": "rust", "repo": "p9c/duo-parachain", "path": "/crates/vault-registry/src/benchmarking.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn view(&self) -> Html { let input_text = self.link.callback(|i: InputData| Msg::SetText(i.value)); html! { <section class="app-container"> <header> <h1>{"Umlaute Substituter"}</h1> </header> <main> ...
code_fim
hard
{ "lang": "rust", "repo": "DomiDre/umlaute", "path": "/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DomiDre/umlaute path: /src/app.rs use yew::prelude::*; use crate::umlaut_replacer::replace_umlaute; pub struct Model { link: ComponentLink<Self>, entered_text: String, edited_text: String, ignore_words: Vec<String> } pub enum Msg { SetText(String) } impl Component for Mode...
code_fim
hard
{ "lang": "rust", "repo": "DomiDre/umlaute", "path": "/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input_text = self.link.callback(|i: InputData| Msg::SetText(i.value)); html! { <section class="app-container"> <header> <h1>{"Umlaute Substituter"}</h1> </header> <main> <div> ...
code_fim
hard
{ "lang": "rust", "repo": "DomiDre/umlaute", "path": "/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itamarga/rust-exercises path: /src/day5.rs #![allow(dead_code)] use crate::intcode::*; const INTCODE_PATH: &str = "src/day5_input.txt"; pub fn solve_day_5_pt1() -> i64 { let input = std::fs::read_to_string(INTCODE_PATH).unwrap(); let mut machine = IntcodeMachine::from(&input); ...
code_fim
hard
{ "lang": "rust", "repo": "itamarga/rust-exercises", "path": "/src/day5.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>= 0; while ret != IntcodeReturns::Halt { ret = machine.step(None); if let IntcodeReturns::Val(result) = ret { // println!("Test {} returned {}", count, result); final_result = result; // count += 1; } } final_result }<|fim_p...
code_fim
hard
{ "lang": "rust", "repo": "itamarga/rust-exercises", "path": "/src/day5.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>hantomData, mem::swap, ops::{Add, Div, Mul, Neg, Range, RangeInclusive, Rem, Sub, AddAssign}, str::FromStr, };<|fim_prefix|>// repo: optozorax/olymp path: /templates/src/to_include/imports.rs use std::{ cmp::{max, min, Ordering, Reverse}, collections::{BTreeMap, BTreeSet, BinaryHeap, ...
code_fim
hard
{ "lang": "rust", "repo": "optozorax/olymp", "path": "/templates/src/to_include/imports.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: optozorax/olymp path: /templates/src/to_include/imports.rs use std::{ cmp::{max, min, Ordering, Reverse}, collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque, HashMap, HashSet}, convert::{identity, TryFrom, TryInto}, error, fmt::{Debug, Display, Error, Formatter}, io::...
code_fim
medium
{ "lang": "rust", "repo": "optozorax/olymp", "path": "/templates/src/to_include/imports.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> log::info!("Got a request!"); Ok(Response::new(resp)) } }<|fim_prefix|>// repo: aksiksi/paygo path: /backend/auth/src/auth.rs use tonic::{Request, Response, Status}; use crate::proto::auth::{AuthRequest, AuthResponse}; use crate::proto::auth::auth_server::Auth; #[derive(Debug, Defa...
code_fim
hard
{ "lang": "rust", "repo": "aksiksi/paygo", "path": "/backend/auth/src/auth.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aksiksi/paygo path: /backend/auth/src/auth.rs use tonic::{Request, Response, Status}; use crate::proto::auth::{AuthRequest, AuthResponse}; use crate::proto::auth::auth_server::Auth; <|fim_suffix|> log::info!("Got a request!"); Ok(Response::new(resp)) } }<|fim_middle|>#[deri...
code_fim
hard
{ "lang": "rust", "repo": "aksiksi/paygo", "path": "/backend/auth/src/auth.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let autoscaler = Autoscaler::from_properties( "release".into(), "instance".into(), "component".into(), prop_map, None, ); let kauto = autoscaler.to_horizontal_pod_autoscaler(); assert_eq!( Some("instance-trait-autoscaler".to_string()), ...
code_fim
hard
{ "lang": "rust", "repo": "abhirockzz/rudr", "path": "/src/schematic/traits/autoscaler_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhirockzz/rudr path: /src/schematic/traits/autoscaler_test.rs use crate::schematic::traits::*; use crate::workload_type::ParamMap; use serde_json::json; use std::collections::BTreeMap; use serde_json::map::Map; #[test] fn test_autoscaler_defaults() { let autoscaler = Autoscaler { n...
code_fim
hard
{ "lang": "rust", "repo": "abhirockzz/rudr", "path": "/src/schematic/traits/autoscaler_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[rustfmt::skip] gpu_texture .upload(queue, &as_2d_source(&source[0]).unwrap(), CubeTextureFace::PositiveX, 0) .upload(queue, &as_2d_source(&source[1]).unwrap(), CubeTextureFace::NegativeX, 0) .upload(queue, &as_2d_source(&source[2]).unwrap(), CubeTextureFace::PositiveY...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/scene/webgpu/src/texture/cube.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn create_fallback_empty_cube_texture(device: &GPUDevice) -> GPUCubeTexture { GPUTexture::create( webgpu::TextureDescriptor { label: "unimplemented default texture".into(), size: webgpu::Extent3d { width: 1, height: 1, depth_or_array_layers: 6, }, mip_...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/scene/webgpu/src/texture/cube.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mikialex/rendiation path: /scene/webgpu/src/texture/cube.rs use rendiation_texture::CubeTextureFace; use crate::*; pub struct ReactiveGPUCubeTextureSignal { inner: EventSource<BindableGPUChange>, gpu: GPUCubeTextureView, } pub type TextureCubeRenderComponentDeltaStream = impl Stream<Item ...
code_fim
hard
{ "lang": "rust", "repo": "mikialex/rendiation", "path": "/scene/webgpu/src/texture/cube.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let baseline = match child_top { // Units::Pixels(val) => match child_bottom { // Units::Stretch(_) => { // y += val + border_width; // Baseline::Top // } // _ => Bas...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/core/src/events/event_handler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lineCode/tuix path: /core/src/events/event_handler.rs te::style::{Direction, Justify, Units, Visibility}; use std::any::{Any, TypeId}; pub type Canvas = femtovg::Canvas<OpenGl>; pub trait EventHandler: Any { fn widget_name(&self) -> String { String::new() } // Called whe...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/core/src/events/event_handler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lineCode/tuix path: /core/src/events/event_handler.rs // let width = state.data.get_width(entity); // let height = state.data.get_height(entity); // let padding_left = match state.style.child_left.get(entity).unwrap_or(&Units::Auto) { // Units::Pixels(val) =>...
code_fim
hard
{ "lang": "rust", "repo": "lineCode/tuix", "path": "/core/src/events/event_handler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let xml = parse(r#"<div id="a"><b class="b">dave</b></div>"#).unwrap(); assert_eq!( unparse(&xml), r#"<div id="a"><b class="b">dave</b></div>"# ); }<|fim_prefix|>// repo: andrew-johnson-4/mxml_dep path: /tests/parse.rs use mxml_dep::*; #[test] fn parse1() { let xml = parse("<br/>...
code_fim
medium
{ "lang": "rust", "repo": "andrew-johnson-4/mxml_dep", "path": "/tests/parse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrew-johnson-4/mxml_dep path: /tests/parse.rs use mxml_dep::*; #[test] fn parse1() { let xml = parse("<br/>").unwrap().to_json().unwrap(); assert_eq!( xml, r#"{"treeType":"documentFragment","children":[{"name":"br","variant":"void"}]}"# ); } #[test] fn parse2() { <|fim_s...
code_fim
hard
{ "lang": "rust", "repo": "andrew-johnson-4/mxml_dep", "path": "/tests/parse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AmarOk1412/rori_utils path: /data/mod.rs use rustc_serialize::json::decode; /** * This struct represent the object used to communicate between RORI points */ #[derive(Clone, RustcDecodable, RustcEncodable, Default, PartialEq, Debug)] pub struct RoriData { pub author: String, pub conte...
code_fim
hard
{ "lang": "rust", "repo": "AmarOk1412/rori_utils", "path": "/data/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn to_string(&self) -> String { format!("{{ \"author\":\"{}\", \"content\":\"{}\", \"client\":\"{}\", \"datatype\":\"{}\", \"secret\":\"{}\" }}", self.author, self.content, self.client, self.datatype, ...
code_fim
hard
{ "lang": "rust", "repo": "AmarOk1412/rori_utils", "path": "/data/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iKurum/leet_code path: /rust/src/simple/c1221.rs #![allow(dead_code)] struct Solution; impl Solution { /// 在一个 **平衡字符串** 中,'L' 和 'R' 字符的数量是相同的。 /// /// 给你一个平衡字符串 s,请你将它分割成尽可能多的平衡字符串。 /// /// 注意:分割得到的每个字符串都必须是平衡字符串。 /// /// 返回可以通过分割得到的平衡字符串的 **最大数量** 。 /// /// 提示: /// ``` ...
code_fim
hard
{ "lang": "rust", "repo": "iKurum/leet_code", "path": "/rust/src/simple/c1221.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }