text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: sergey-litvinov/crawler path: /src/parsers/html_parser.rs use log::{trace, warn}; use anyhow::{Result}; use reqwest::blocking::{Client}; use crate::settings::Site; use crawler::{NotifyData, Parser}; pub struct HtmlParser{ site: Site, client: Client } impl HtmlParser { pub fn new(...
code_fim
hard
{ "lang": "rust", "repo": "sergey-litvinov/crawler", "path": "/src/parsers/html_parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for ignored in vec.as_slice() { html = html.replace(ignored, "") } html = html.replace("\n", "").replace("\r", "").trim().to_string(); if html.len() > 0 { trace!("Found html content {:?}", html); return Ok(...
code_fim
hard
{ "lang": "rust", "repo": "sergey-litvinov/crawler", "path": "/src/parsers/html_parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[empty_attr] mod module; //~ ERROR non-inline modules in proc macro input are unstable #[empty_attr] //~ ERROR custom attributes cannot be applied to modules mod outer { mod inner; //~ ERROR non-inline modules in proc macro input are unstable mod inner_inline {} // OK } fn main() {}<|fim_prefi...
code_fim
medium
{ "lang": "rust", "repo": "Alpaca-H/rust", "path": "/src/test/ui/proc-macro/attributes-on-modules-fail.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alpaca-H/rust path: /src/test/ui/proc-macro/attributes-on-modules-fail.rs // aux-build:test-macros.rs #[macro_use] extern crate test_macros; #[identity_attr] //~ ERROR custom attributes cannot be applied to modules mod m { pub struct X; type A = Y; //~ ERROR cannot find type `Y` in th...
code_fim
medium
{ "lang": "rust", "repo": "Alpaca-H/rust", "path": "/src/test/ui/proc-macro/attributes-on-modules-fail.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(num_enum::TryFromPrimitive, Debug, Clone, Copy, PartialOrd, PartialEq)] #[repr(u8)] pub enum Role { Admin = 0xff, Public = 0x00, }<|fim_prefix|>// repo: crossperf/basil path: /router.rs use crate::*; type Page = Vec<Action>; pub fn title() -> &'static str { "Basil" } fn recipes<T:...
code_fim
medium
{ "lang": "rust", "repo": "crossperf/basil", "path": "/router.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> vec![Action::SelectPage(site::Show::Notfound)] } #[derive(num_enum::TryFromPrimitive, Debug, Clone, Copy, PartialOrd, PartialEq)] #[repr(u8)] pub enum Role { Admin = 0xff, Public = 0x00, }<|fim_prefix|>// repo: crossperf/basil path: /router.rs use crate::*; type Page = Vec<Action>; pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "crossperf/basil", "path": "/router.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crossperf/basil path: /router.rs use crate::*; type Page = Vec<Action>; pub fn title() -> &'static str { "Basil" } fn recipes<T: Into<String>>(category: T) -> Page { let category = category.into(); vec![ Action::SelectPage(site::Show::Recipes), Action::Recipes(reci...
code_fim
hard
{ "lang": "rust", "repo": "crossperf/basil", "path": "/router.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cipepser/programming-rust-sample path: /chap7/json/src/main.rs fn doSomething() -> Result<(), JsonError> { return Err(JsonError { message: "expectd ']' at end of array".to_string(), line: current_line, column: current_column, }); } <|fim_suffix|> println!("Hel...
code_fim
easy
{ "lang": "rust", "repo": "cipepser/programming-rust-sample", "path": "/chap7/json/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Hello, world!"); }<|fim_prefix|>// repo: cipepser/programming-rust-sample path: /chap7/json/src/main.rs fn doSomething() -> Result<(), JsonError> { <|fim_middle|> return Err(JsonError { message: "expectd ']' at end of array".to_string(), line: current_line, column...
code_fim
medium
{ "lang": "rust", "repo": "cipepser/programming-rust-sample", "path": "/chap7/json/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { println!("Hello, world!"); }<|fim_prefix|>// repo: cipepser/programming-rust-sample path: /chap7/json/src/main.rs fn doSomething() -> Result<(), JsonError> { <|fim_middle|> return Err(JsonError { message: "expectd ']' at end of array".to_string(), line: current_line, ...
code_fim
medium
{ "lang": "rust", "repo": "cipepser/programming-rust-sample", "path": "/chap7/json/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn should_verify_on_drop(&mut self, flag: bool) { self.verify_on_drop = flag; } #[allow(dead_code)] pub fn add_given_behaviour(&self, requested_trait: &'static str, method: &'static str, behaviour: GivenBehaviour) { self.given_behavi...
code_fim
hard
{ "lang": "rust", "repo": "mindsbackyard/galvanic-mock", "path": "/src/generate/mock_struct_implementer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mindsbackyard/galvanic-mock path: /src/generate/mock_struct_implementer.rs /* Copyright 2017 Christopher Bacher * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * ...
code_fim
hard
{ "lang": "rust", "repo": "mindsbackyard/galvanic-mock", "path": "/src/generate/mock_struct_implementer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match action { MenuActions::Back => self.menu_back(), MenuActions::Key(c) => { return self.menu_act_key(c); } MenuActions::Cancel => self.on_cancel.signal(None), MenuActions::ToggleHelp => self.show_help = !self.show_help, }; return t...
code_fim
hard
{ "lang": "rust", "repo": "erezsh/rex", "path": "/src/ui/menu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erezsh/rex path: /src/ui/menu.rs use std::default::Default; use rex_utils; use rex_utils::rect::Rect; use super::common::Canceled; use super::input::Input; use super::widget::Widget; use super::view::HexEditActions; use super::super::frontend::{Frontend, Style, KeyPress}; pub enum MenuActions...
code_fim
hard
{ "lang": "rust", "repo": "erezsh/rex", "path": "/src/ui/menu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rb.print_style(area.left as usize, (area.bottom() - 1) as usize, Style::Default, &clear_line); rb.print_style(area.right() as usize - hint_msg.len(), (area.bottom() - 1) as usize, Style::Hint, hint_msg); self.draw_menu_location(rb, area.left, area.bottom...
code_fim
hard
{ "lang": "rust", "repo": "erezsh/rex", "path": "/src/ui/menu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>i); thread::sleep(Duration::from_millis(1)); } }); for i in 1..5 { println!("Main: {}", i); thread::sleep(Duration::from_millis(1)); } }<|fim_prefix|>// repo: ytyaru/Rust.Thread.20190706091329 path: /src/0/main.rs /* * Rustのスレッド。 * CreatedAt: 2019-07-06 ...
code_fim
medium
{ "lang": "rust", "repo": "ytyaru/Rust.Thread.20190706091329", "path": "/src/0/main.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ytyaru/Rust.Thread.20190706091329 path: /src/0/main.rs /* * Rustのスレッド。 * CreatedAt: 2019-07-06 */ use std::thread; use std::time::Duration; fn main() { thread::spawn(|| { for i in 1..10 { println!("Thread: {}", <|fim_suffix|> { println!("Main: {}", i); ...
code_fim
medium
{ "lang": "rust", "repo": "ytyaru/Rust.Thread.20190706091329", "path": "/src/0/main.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johannesegger/AdventOfCode path: /2022/Day03/Rust/src/main.rs use std::{fs::File, io::{BufReader, Error, BufRead}, collections::HashSet}; fn get_prio (c: char) -> i32 { if c >= 'a' && c <= 'z' { c as i32 - 'a' as i32 + 1 } else if c >= 'A' && c <= 'Z' { c as i32 - 'A' as i32 + 27 } ...
code_fim
hard
{ "lang": "rust", "repo": "johannesegger/AdventOfCode", "path": "/2022/Day03/Rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let part2 : i32 = lines .chunks(3) .map(|chunk| { let intersection = chunk.iter() .map(|line| line.chars().collect::<HashSet<_>>()) .reduce(|a, b| a.intersection(&b).cloned().collect::<HashSet<_>>()) .unwrap(); ret...
code_fim
hard
{ "lang": "rust", "repo": "johannesegger/AdventOfCode", "path": "/2022/Day03/Rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WeAreRust/Nes path: /nes/src/io/audio.rs use sdl2::audio::AudioCallback; use std::sync::mpsc::Receiver; use apu::channel; use apu::channel::ChannelState; pub struct NesAudioProcess { sample: u64, sample_rate: u32, channels: channel::ApuChannelState, delta_stream: Receiver<channel::ApuC...
code_fim
medium
{ "lang": "rust", "repo": "WeAreRust/Nes", "path": "/nes/src/io/audio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let channels = self.channels.clone(); self.channels = self .delta_stream .try_iter() .fold(channels, |acc, delta| acc.transform(delta)); } }<|fim_prefix|>// repo: WeAreRust/Nes path: /nes/src/io/audio.rs use sdl2::audio::AudioCallback; use std::sync::mpsc::Receiver; use apu::...
code_fim
hard
{ "lang": "rust", "repo": "WeAreRust/Nes", "path": "/nes/src/io/audio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EstebanBorai/calc-lang path: /src/lib/interpreter.rs use super::analyzer::{ AnalyzedExpression, AnalyzedFactor, AnalyzedProgram, AnalyzedStatement, AnalyzedTerm, }; use super::parser::{ExpressionOperator, TermOperator}; use super::symbol_table::SymbolTable; fn eval_term(variables: &SymbolTa...
code_fim
hard
{ "lang": "rust", "repo": "EstebanBorai/calc-lang", "path": "/src/lib/interpreter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match statement { AnalyzedStatement::Assignment(handle, expr) => { variables.set(*handle, eval_expression(variables, expr)); } AnalyzedStatement::Declaration(_) => {} AnalyzedStatement::InputOperation(handle) => { let mut text = String::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "EstebanBorai/calc-lang", "path": "/src/lib/interpreter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>l: String, pub firstname: String, pub lastname: String, }<|fim_prefix|>// repo: Neil399399/Rust-API path: /httpapi/src/models.rs use serde::Deserialize; //Requests #[derive(Debug, Deserialize)<|fim_middle|>] pub struct RequestUserInfo { pub email: String, } #[derive(Debug, Deserialize)] pub...
code_fim
medium
{ "lang": "rust", "repo": "Neil399399/Rust-API", "path": "/httpapi/src/models.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Neil399399/Rust-API path: /httpapi/src/models.rs use serde::Deserialize; //Requests #[derive(Debug, Deserialize)<|fim_suffix|>(Debug, Deserialize)] pub struct RequestUpdateUser { pub email: String, pub firstname: String, pub lastname: String, }<|fim_middle|>] pub struct RequestUserI...
code_fim
medium
{ "lang": "rust", "repo": "Neil399399/Rust-API", "path": "/httpapi/src/models.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// need the parameter "dbname" for checkin if its existing already fn init_db() -> Result<bool, ErrorList> { let url = "mysql://root:root@localhost:3306/sandbox"; let pool = Pool::new(Opts::from_url(url)?)?; let mut conn = pool.get_conn()?; } fn get_struct_player_data(mut data: Data) -> Resu...
code_fim
medium
{ "lang": "rust", "repo": "DatPriest/RustGettingStarted", "path": "/rust_api_sandbox/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DatPriest/RustGettingStarted path: /rust_api_sandbox/src/main.rs extern crate rocket; use mysql::prelude::Queryable; use mysql::{from_row, Opts, Pool}; use rocket::Data; use rocket::{post, routes}; use serde::{Deserialize, Serialize}; use thiserror::Error; // Access Token 168f3f23-82e5-4db7-9d81...
code_fim
medium
{ "lang": "rust", "repo": "DatPriest/RustGettingStarted", "path": "/rust_api_sandbox/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let url = "mysql://root:root@localhost:3306/sandbox"; let pool = Pool::new(Opts::from_url(url).unwrap()).unwrap(); let mut conn = pool.get_conn().unwrap(); conn.query_iter("SELECT steamID, level, experience, inventory FROM playerdata") .unwrap() .for_each(|row| { ...
code_fim
hard
{ "lang": "rust", "repo": "DatPriest/RustGettingStarted", "path": "/rust_api_sandbox/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OSSystems/sendgrid-amqp-bridge path: /src/amqp.rs // Copyright (C) 2018 O.S. Systems Sofware LTDA // // SPDX-License-Identifier: MIT use crate::config; use lapin::{ message::Delivery, options::{ BasicAckOptions, BasicConsumeOptions, BasicNackOptions, ConfirmSelectOptions, ...
code_fim
hard
{ "lang": "rust", "repo": "OSSystems/sendgrid-amqp-bridge", "path": "/src/amqp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Amqp { pub(crate) fn from_config(config: &config::Config) -> Self { Self { config: config.amqp.clone(), } } pub(crate) async fn create_consumers<F>( self, message_handler: F, logger: slog::Logger, ) -> Result<Connection, lapin::Erro...
code_fim
hard
{ "lang": "rust", "repo": "OSSystems/sendgrid-amqp-bridge", "path": "/src/amqp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>File::open(path).unwrap(); // let mut data = String::new(); // file.read_to_string(&mut data).unwrap(); // return data; // }<|fim_prefix|>// repo: yanweixin/Rcmd path: /src/util/file.rs use std::fs::File; use std::io::Read; use log::{info, warn,}; // pu<|fim_middle|>b fn read_to_string(path:...
code_fim
medium
{ "lang": "rust", "repo": "yanweixin/Rcmd", "path": "/src/util/file.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yanweixin/Rcmd path: /src/util/file.rs use std::fs::File; use std::io::Read; use log::{info, warn,}; // pu<|fim_suffix|>File::open(path).unwrap(); // let mut data = String::new(); // file.read_to_string(&mut data).unwrap(); // return data; // }<|fim_middle|>b fn read_to_string(path:...
code_fim
medium
{ "lang": "rust", "repo": "yanweixin/Rcmd", "path": "/src/util/file.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: keiono/egraph-rs path: /crates/quality-metrics/src/stress.rs use petgraph::graph::IndexType; use petgraph_layout_force_simulation::Coordinates; pub fn stress<Ix: IndexType>(coordinates: &Coordinates<Ix>, d: &[&[f32]]) -> f32 { let n = coordinates.len(); let mut s = 0.; for j in 1..n { ...
code_fim
medium
{ "lang": "rust", "repo": "keiono/egraph-rs", "path": "/crates/quality-metrics/src/stress.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>let norm = (dx * dx + dy * dy).sqrt(); let dij = d[i][j]; let e = (norm - dij) / dij; s += e * e; } } s }<|fim_prefix|>// repo: keiono/egraph-rs path: /crates/quality-metrics/src/stress.rs use petgraph::graph::IndexType; use petgraph_layout_force_simulation::Coordinates; pub fn...
code_fim
medium
{ "lang": "rust", "repo": "keiono/egraph-rs", "path": "/crates/quality-metrics/src/stress.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: friedm/regex-matcher path: /src/expr/mod.rs use std::str::FromStr; use std::collections::vec_deque::VecDeque; #[cfg(test)] mod spec; static UNARY_POSTFIX_OPERATORS: &'static [char] = &['?', '*', '+']; static BINARY_OPERATORS: &'static [char] = &['|']; static SPECIAL_CHARS: &'static [char] = &[...
code_fim
hard
{ "lang": "rust", "repo": "friedm/regex-matcher", "path": "/src/expr/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } while !operator_stack.is_empty() { pop_infix_operator(operator_stack.pop().unwrap(), &mut output_queue); } // build sequence tree from queue while output_queue.len() > 1 { let right = output_queue.pop_back().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "friedm/regex-matcher", "path": "/src/expr/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lostmsu/hashlife path: /src/main.rs use std::rc::Rc; struct QuadTreeInnerNode<T, InnerData> { top_left: Rc<QuadTreeNode<T, InnerData>>, top_right: Rc<QuadTreeNode<T, InnerData>>, bottom_left: Rc<QuadTreeNode<T, InnerData>>, bottom_right: Rc<QuadTreeNode<T, InnerData>>, data:...
code_fim
hard
{ "lang": "rust", "repo": "lostmsu/hashlife", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return QuadTreeInnerNode{ data: LifeInnerData { level: top_left.getLevel() + 1, alive: top_left.isAlive() && top_right.isAlive() && bottom_left.isAlive() && bottom_right.isAlive() }, top_left: top_left, top_right: top_right, botto...
code_fim
hard
{ "lang": "rust", "repo": "lostmsu/hashlife", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { QuadTreeNode::Leaf(isAlive) => *isAlive, QuadTreeNode::Inner(inner) => inner.isAlive(), } } } fn make_next_level(top_left: Rc<LifeNode>, top_right: Rc<LifeNode>, bottom_left: Rc<LifeNode>, bottom_right: Rc<LifeNode>) -> LifeInner...
code_fim
hard
{ "lang": "rust", "repo": "lostmsu/hashlife", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noobLue/tmc-langs-rust path: /tmc-langs-plugins/src/lib.rs #![deny(clippy::print_stdout, clippy::print_stderr)] mod error; pub mod tmc_zip; pub use error::PluginError; pub use tmc_langs_framework::{ ExerciseDesc, ExercisePackagingConfiguration, Language, NothingIsStudentFilePolicy, RunResu...
code_fim
hard
{ "lang": "rust", "repo": "noobLue/tmc-langs-rust", "path": "/tmc-langs-plugins/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_language_plugin_type(path: &Path) -> Result<PluginType, PluginError> { let plugin_type = if NoTestsPlugin::is_exercise_type_correct(path) { log::info!( "Detected project at {} as {}", path.display(), NoTestsPlugin::PLUGIN_NAME ); P...
code_fim
hard
{ "lang": "rust", "repo": "noobLue/tmc-langs-rust", "path": "/tmc-langs-plugins/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> session .query( "CREATE TABLE IF NOT EXISTS ks.durations (event text, duration tuple<int, text>, primary key (event))", &[], ) .await.unwrap(); let duration1 = (3, "hours"); let duration2 = CqlValue::Tuple(vec![ Some(CqlValue::Int(2)), ...
code_fim
hard
{ "lang": "rust", "repo": "mkawalec/scylla-rust-driver", "path": "/scylla/src/frame/cql_collections_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mkawalec/scylla-rust-driver path: /scylla/src/frame/cql_collections_test.rs use crate::{frame::response::result::CqlValue, IntoTypedRows, SessionBuilder}; use std::{collections::HashMap, env}; #[tokio::test] async fn test_cql_collections() { // Create connection let uri = env::var("SCYL...
code_fim
hard
{ "lang": "rust", "repo": "mkawalec/scylla-rust-driver", "path": "/scylla/src/frame/cql_collections_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(vec![mret, sig]) }) .outarg::<&str, _>("reply") .inarg::<&str, _>("name"), ) .add_s(signal8), ), )*/ ...
code_fim
hard
{ "lang": "rust", "repo": "joshua-stone/hardwaremanagerd", "path": "/hardwaremanagerd/src/lib/daemon.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joshua-stone/hardwaremanagerd path: /hardwaremanagerd/src/lib/daemon.rs extern crate dbus; #[path = "memory.rs"] mod memory; #[path = "devicereader.rs"] mod devicereader; #[path = "cpu.rs"] mod cpu; use memory::get_mem_info; use devicereader::list_devices; use cpu::Cpu; use dbus::blocking::Loc...
code_fim
hard
{ "lang": "rust", "repo": "joshua-stone/hardwaremanagerd", "path": "/hardwaremanagerd/src/lib/daemon.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sig = signal5 .msg(m.path.get_name(), m.iface.get_name()) .append1(&*name); Ok(vec![mret, sig]) }) .outar...
code_fim
hard
{ "lang": "rust", "repo": "joshua-stone/hardwaremanagerd", "path": "/hardwaremanagerd/src/lib/daemon.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: parallaxsecond/parsec-client-rust path: /src/auth.rs // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 //! Client app authentication data use crate::error::{Error, Result}; use parsec_interface::requests::{request::RequestAuth, AuthType}; use std::conve...
code_fim
hard
{ "lang": "rust", "repo": "parallaxsecond/parsec-client-rust", "path": "/src/auth.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match (self, other) { (Authentication::None, Authentication::None) => true, (Authentication::UnixPeerCredentials, Authentication::UnixPeerCredentials) => true, (Authentication::Direct(app_name), Authentication::Direct(other_app_name)) => { app_na...
code_fim
hard
{ "lang": "rust", "repo": "parallaxsecond/parsec-client-rust", "path": "/src/auth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sam-wright/Advent-of-Code path: /2020/day17/src/lib.rs use std::collections::HashMap; use std::fs::File; use std::io::Read; type Grid = HashMap<(i32, i32, i32, i32), Cell>; #[derive(Debug, PartialEq)] pub enum Cell { Inactive, Active, } pub fn read_input(filename: &str) -> Vec<String> ...
code_fim
hard
{ "lang": "rust", "repo": "sam-wright/Advent-of-Code", "path": "/2020/day17/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = read_input("example1.txt"); let grid = input_to_grid_3d(&input); assert_eq!(count_active(&grid), 5); //0-cycles assert_eq!(count_active_neighbors(&grid, &(1, 1, 0, 0)), 5); assert_eq!(count_active_neighbors(&grid, &(2, 0, 0, 0)), 2); assert_eq!(c...
code_fim
hard
{ "lang": "rust", "repo": "sam-wright/Advent-of-Code", "path": "/2020/day17/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn part_1_example() { let input = read_input("example1.txt"); let grid = input_to_grid_3d(&input); assert_eq!(count_active(&grid), 5); //0-cycles assert_eq!(count_active_neighbors(&grid, &(1, 1, 0, 0)), 5); ...
code_fim
hard
{ "lang": "rust", "repo": "sam-wright/Advent-of-Code", "path": "/2020/day17/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChrisDenton/wintls path: /src/raw_internal.rs // FIXME: Currently all access to the thread-local is implemented in terms of // getting a pointer to the thread local. This could (and probably should) be // optimized to read directly into a register if the data fits. // A very unsafe type that al...
code_fim
hard
{ "lang": "rust", "repo": "ChrisDenton/wintls", "path": "/src/raw_internal.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] pub unsafe fn static_ptr_from_module<T>(module: u32, key: u32) -> *mut T { let mut ptr: *mut T = tls_array().cast(); let key = key as usize; let index = module as usize; asm!( "mov {ptr}, [{ptr} + {index} * {multiplier}]", "lea {ptr}, [{key} + {ptr}]", ptr = inout(reg) ptr, i...
code_fim
hard
{ "lang": "rust", "repo": "ChrisDenton/wintls", "path": "/src/raw_internal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] pub unsafe fn get_static_from_module<T: Copy>(module: u32, key: u32) -> T { *static_ptr_from_module(module, key) } /// Convenience macro for setting the static thread-local value by its /// identifier. #[macro_export] macro_rules! set_static { ($name:ident, $value:expr) => { $crate:...
code_fim
hard
{ "lang": "rust", "repo": "ChrisDenton/wintls", "path": "/src/raw_internal.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let i = combination_vec[combination_vec.len() - 1]; for j in 0..n { if combination_set.contains(&j) { continue; } if components[i].1 == components[j].1 { let tmp = components[j].0; components[j].0 = components[j].1; components...
code_fim
hard
{ "lang": "rust", "repo": "vindvaki/advent-of-code-2017", "path": "/src/bin/day_24.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut iter = input .split('/') .map(|s| s.parse::<usize>().unwrap()); let a = iter.next().unwrap(); let b = iter.next().unwrap(); (a, b) } #[cfg(test)] mod tests { #[test] fn test_part_1() { use part_1; let input = "0/2 2/2 2/3 3/4 3/5 0/1 10/1 9/...
code_fim
hard
{ "lang": "rust", "repo": "vindvaki/advent-of-code-2017", "path": "/src/bin/day_24.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vindvaki/advent-of-code-2017 path: /src/bin/day_24.rs extern crate aoc2017; use aoc2017::read_fixture; use std::collections::HashSet; fn main() { let input = read_fixture(); println!("part_1: {}", part_1(&input)); println!("part_2: {}", part_2(&input)); } fn part_1(input: &str) -...
code_fim
hard
{ "lang": "rust", "repo": "vindvaki/advent-of-code-2017", "path": "/src/bin/day_24.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Bin { pub fn read_from_data(data: &[u8], hashes: &BinHashes) -> std::io::Result<Bin> { BinReader::read_bin(data, hashes) } pub fn read_from_file(file: File, hashes: &BinHashes) -> std::io::Result<Bin> { let mut file = file; let mut buf = Vec::new(); file.r...
code_fim
hard
{ "lang": "rust", "repo": "moonshadow565/rbin", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for BinValue { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.format_to(f) } } impl Debug for BinValue { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.format_to(f) } } #[derive(Clone, Debug)] pub struct ...
code_fim
hard
{ "lang": "rust", "repo": "moonshadow565/rbin", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moonshadow565/rbin path: /src/lib.rs mod hashes; mod reader; pub use hashes::*; use reader::BinReader; use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::fmt::{Debug, Display}; #[derive(Clone)] pub enum BinValue { None, Bool(bool), Signed(i64), Unsign...
code_fim
hard
{ "lang": "rust", "repo": "moonshadow565/rbin", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hobofan/ucsf-nmr path: /src/lib.rs n std::error::Error + 'static>> { //! let file_bytes = fs::read("./tests/data/15n_hsqc.ucsf")?; //! // _remaining_bytes should be empty and can usually be discarded. //! // ucsf_file contains our data of interest //! let (_remaining_bytes, ucsf_file...
code_fim
hard
{ "lang": "rust", "repo": "hobofan/ucsf-nmr", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct AbsolutePosValIter<'a> { tile: &'a Tile<'a>, next_index: usize, } impl<'a> AbsolutePosValIter<'a> { pub fn as_2d(&'a mut self) -> AbsolutePosValIter2D<'a> { AbsolutePosValIter2D { iter: self } } pub fn as_3d(&'a mut self) -> AbsolutePosValIter3D<'a> { Absol...
code_fim
hard
{ "lang": "rust", "repo": "hobofan/ucsf-nmr", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct AbsolutePosValIter4D<'a> { iter: &'a mut AbsolutePosValIter<'a>, } impl<'a> Iterator for AbsolutePosValIter4D<'a> { type Item = ((usize, usize, usize, usize), f32); fn next(&mut self) -> Option<Self::Item> { self.iter .next() .map(|(axis_abs, val)| ...
code_fim
hard
{ "lang": "rust", "repo": "hobofan/ucsf-nmr", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mixalturek/spirit path: /spirit-tokio/src/installer.rs //! Installer of futures. //! //! The [`FutureInstaller`] is an [`Installer`] that allows installing (spawning) futures, but also //! canceling them when they are no longer required by the configuration. //! //! [`FutureInstaller`]: crate::i...
code_fim
hard
{ "lang": "rust", "repo": "mixalturek/spirit", "path": "/spirit-tokio/src/installer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<R, O, C> Installer<R, O, C> for FutureInstaller<R> where R: IntoFuture<Item = (), Error = ()> + Send + 'static, R::Future: Send + 'static, { type UninstallHandle = RemoteDrop; fn install(&mut self, resource: R, name: &'static str) -> RemoteDrop { let (drop_send, drop_recv) = o...
code_fim
hard
{ "lang": "rust", "repo": "mixalturek/spirit", "path": "/spirit-tokio/src/installer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: truchi/lay path: /src/layer/cell/cell/mod.rs mod layer; use crate::*; /// A terminal [`Cell`](crate::Cell). /// /// Should only contain a graphical `char`. #[derive(Copy, Clone, Eq, PartialEq, Default)] pub struct Cell(pub Option<Styled<char>>); /// ### Consts impl Cell { /// An empty ter...
code_fim
hard
{ "lang": "rust", "repo": "truchi/lay", "path": "/src/layer/cell/cell/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a new [`Cell`](crate::Cell). // TODO useless now impl From<Option<Cell>> for Cell { /// Returns a new [`Cell`](crate::Cell). fn from(cell: Option<Cell>) -> Self { match cell { Some(cell) => cell.into(), None => Self::NONE, } } } impl AsRef<O...
code_fim
hard
{ "lang": "rust", "repo": "truchi/lay", "path": "/src/layer/cell/cell/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zoujiaqing/rust_asio path: /src/ip/addr.rs (self.bytes[0] & 0xF0) == 0xE0 } /// Returns true for if this is a link-local address. /// /// The link-local address ranges: /// /// - 169.254.0.0/16 /// /// # Examples /// ``` /// use asyncio::ip::IpAddrV4; ...
code_fim
hard
{ "lang": "rust", "repo": "zoujiaqing/rust_asio", "path": "/src/ip/addr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zoujiaqing/rust_asio path: /src/ip/addr.rs ult will represent the LL-address a:b:c:d:e:f. /// /// # Example /// /// ``` /// use asyncio::ip::LlAddr; /// /// let mac = LlAddr::new(0,0,0,0,0,0); /// ``` pub fn new(a: u8, b: u8, c: u8, d: u8, e: u8, f: u8) -> LlA...
code_fim
hard
{ "lang": "rust", "repo": "zoujiaqing/rust_asio", "path": "/src/ip/addr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns 4 octets bytes. /// /// # Examples /// ``` /// use asyncio::ip::IpAddrV4; /// /// assert_eq!(IpAddrV4::new(169,254,0,1).as_bytes(), &[169,254,0,1]); /// ``` pub fn as_bytes(&self) -> &[u8; 4] { &self.bytes } /// Returns `u32` in host byte or...
code_fim
hard
{ "lang": "rust", "repo": "zoujiaqing/rust_asio", "path": "/src/ip/addr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct Guardclass {{ pub the_prodmsgobj: Prodmsgclass, pub myrand: Myrand, }} impl Guardclass {{ pub fn new( the_prodmsgobj: Prodmsgclass,_seed: u16 ) -> Guardclass {{ Guardclass {{ the_prodmsgobj: the_prodmsgobj, myrand: Myrand::new(_se...
code_fim
hard
{ "lang": "rust", "repo": "willy610/fsm2fsm-main", "path": "/tool/src/applic_folder/fsm_folder/gen_folder/genrust_folder/genguardclass.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> state: &String, inmsg: &String, rows: &Vec<RowToStateEventGroup>, ) -> String { return format!( "let cond_to_set ; {test_match} match cond_to_set{{ {all_conds} }} ", test_match = build_test_match(state, inmsg, ...
code_fim
hard
{ "lang": "rust", "repo": "willy610/fsm2fsm-main", "path": "/tool/src/applic_folder/fsm_folder/gen_folder/genrust_folder/genguardclass.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: willy610/fsm2fsm-main path: /tool/src/applic_folder/fsm_folder/gen_folder/genrust_folder/genguardclass.rs use crate::applic_folder::fsm_folder::fsm::Fsm; use crate::applic_folder::fsm_folder::gen_folder::genrust_folder::genall::build_cnd_id; use crate::applic_folder::fsm_folder::gen_folder::genr...
code_fim
hard
{ "lang": "rust", "repo": "willy610/fsm2fsm-main", "path": "/tool/src/applic_folder/fsm_folder/gen_folder/genrust_folder/genguardclass.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sKyanfIre/rust path: /collection/src/generic.rs pub struct Animal<T> { weight:T, height:T, } pub enum Type<K>{ PIG(K), DOG(K), } #[derive(Debug)] pub struct Complex<K,V> { k:K, v:V, } impl<K,V> Complex<K,V> { pub fn com<S,T>(self,other:Complex<S,T>) -> Complex<K,T>{ ...
code_fim
hard
{ "lang": "rust", "repo": "sKyanfIre/rust", "path": "/collection/src/generic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn max_char(vec:&[char])->char { let mut max = vec[0]; for &i in vec{ if max < i { max = i; } } max } pub fn max_generic<T:PartialOrd + Copy>(vec:&[T])->T { let mut max = vec[0]; for &i in vec{ if max < i { max = i; ...
code_fim
hard
{ "lang": "rust", "repo": "sKyanfIre/rust", "path": "/collection/src/generic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, S: ?Sized + Stream> Stream for &'a mut S { type Item = S::Item; type Error = S::Error; fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { (**self).poll() } } /// Class of types which can be converted themselves into a future. pub trait IntoFuture { type Fu...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/kernel-2", "path": "/src/abstractions/streams/stream.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where Self::Item: IntoFuture<Error = <Self as Stream>::Error>, Self: Sized { buffer_unordered::new(self, amt) } } impl<'a, S: ?Sized + Stream> Stream for &'a mut S { type Item = S::Item; type Error = S::Error; fn poll(&mut self) -> Poll<Option<Self::Item...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/kernel-2", "path": "/src/abstractions/streams/stream.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitter-badger/kernel-2 path: /src/abstractions/streams/stream.rs use abstractions::futures::future::Future; use abstractions::poll::Poll; use abstractions::futures::done::{done, Done}; use abstractions::streams::flatten::Flatten; use abstractions::streams::skip::Skip; use abstractions::streams::...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/kernel-2", "path": "/src/abstractions/streams/stream.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HamaguRe/dft_rust path: /src/main.rs // 離散フーリエ変換(Discrete Fourier Transform)を実装 extern crate gnuplot; use gnuplot::*; const PI: f64 = std::f64::consts::PI; type ComplexNum = (f64, f64); fn main() { // 合成波を生成 let mut wave = Vec::new(); let mut num: f64 = 0.0; while num <= 100.0...
code_fim
hard
{ "lang": "rust", "repo": "HamaguRe/dft_rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn scale(s: f64, j: ComplexNum) -> ComplexNum { ( s * j.0, s * j.1 ) } fn add(a: ComplexNum, b: ComplexNum) -> ComplexNum { ( a.0+b.0, a.1+b.1 ) } fn norm(a: ComplexNum) -> f64 { (a.0*a.0 + a.1*a.1).sqrt() }<|fim_prefix|>// repo: HamaguRe/dft_rust path: /src/main.rs // 離散フーリエ変換(Discrete Fou...
code_fim
hard
{ "lang": "rust", "repo": "HamaguRe/dft_rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cookies: [i32; ARSIZE] = [1, 2, 4, 8, 16, 32, 64, 128]; // some systems require preceding i32 with static to // enable array initialization let mut sum: i32 = sum_arr(&cookies[0..ARSIZE]); write!(stdout, "Total cookies eaten: {}\n", sum); sum = sum_arr(&cookies[0..3]); // firs...
code_fim
medium
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 7/arrfun4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust path: /Chapter 7/arrfun4.rs // arrfun4.rs -- functions with an array range use std::io; use std::io::prelude::*; const ARSIZE: usize = 8; <|fim_suffix|> Ok(()) } // return the sum of an integer array fn sum_arr(arr: &[i32]) -> i32 {...
code_fim
hard
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 7/arrfun4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut sum: i32 = sum_arr(&cookies[0..ARSIZE]); write!(stdout, "Total cookies eaten: {}\n", sum); sum = sum_arr(&cookies[0..3]); // first 3 elements write!(stdout, "First three eaters ate {} cookies.\n", sum); sum = sum_arr(&cookies[4..8]); // first 3 elements write!(stdout, "Last...
code_fim
hard
{ "lang": "rust", "repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust", "path": "/Chapter 7/arrfun4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ebottabi/datafuse path: /common/datavalues/src/arrays/ops/apply.rs // Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. use std::borrow::Cow; use std::sync::Arc; use common_arrow::arrow::array::*; use crate::arrays::DataArray; use crate::prelude::*; use crate...
code_fim
hard
{ "lang": "rust", "repo": "ebottabi/datafuse", "path": "/common/datavalues/src/arrays/ops/apply.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Apply a closure elementwise. This is fastest when the null check branching is more expensive /// than the closure application. Often it is. /// /// Null values remain null. /// /// ``` fn apply<F>(&'a self, f: F) -> Self where F: Fn(A) -> B + Copy; /// Apply a clos...
code_fim
hard
{ "lang": "rust", "repo": "ebottabi/datafuse", "path": "/common/datavalues/src/arrays/ops/apply.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thisKai/rgx path: /src/kit/mod.rs #![allow(dead_code)] pub use crate::core; pub use crate::core::{Bgra8, Rgba, Rgba8}; pub mod shape2d; pub mod sprite2d; use crate::math::{Matrix4, Ortho}; use std::time; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum Origin { Center, BottomLef...
code_fim
hard
{ "lang": "rust", "repo": "thisKai/rgx", "path": "/src/kit/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Model { fn new( layout: &core::BindingGroupLayout, transforms: &[Matrix4<f32>], dev: &core::Device, ) -> Self { let aligned = Self::aligned(transforms); let buf = dev.create_uniform_buffer(aligned.as_slice()); let binding = dev.create_binding_gr...
code_fim
hard
{ "lang": "rust", "repo": "thisKai/rgx", "path": "/src/kit/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn record_furniture(placed: PlacedFurniture) { FURNITURE.get().unwrap().write().unwrap().push(placed); } pub fn write_yaml() { let x = FURNITURE.get().unwrap().read().unwrap().clone(); let x = serde_yaml::to_string(&x).unwrap(); let mut file = File::create("data/furniture.yaml").expec...
code_fim
medium
{ "lang": "rust", "repo": "jguhlin/awakeningbw", "path": "/src/data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jguhlin/awakeningbw path: /src/data.rs use bevy::prelude::*; use hashbrown::HashMap; use once_cell::sync::OnceCell; use std::sync::{Arc, RwLock}; use yaml_rust::{yaml::Yaml, YamlLoader, YamlEmitter}; use std::fs; use std::fs::File; use std::io::prelude::*; <|fim_suffix|>use crate::furniture::*;...
code_fim
medium
{ "lang": "rust", "repo": "jguhlin/awakeningbw", "path": "/src/data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn write_yaml() { let x = FURNITURE.get().unwrap().read().unwrap().clone(); let x = serde_yaml::to_string(&x).unwrap(); let mut file = File::create("data/furniture.yaml").expect("Unable to write file"); file.write_all(x.as_bytes()).expect("Unable to write data file"); }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "jguhlin/awakeningbw", "path": "/src/data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarkOSIndustries/graphlite path: /src/main.rs mod keyset; use sled::Db; use std::path; pub mod graphlite_protocol { include!(concat!(env!("OUT_DIR"), "\\graphlite_protocol.rs")); } fn main() { let args: Vec<String> = std::env::args().collect(); let path = path::Path::new(if args.l...
code_fim
hard
{ "lang": "rust", "repo": "MarkOSIndustries/graphlite", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // scan forward let iter = tree.scan(&k); for x in iter { if let Ok((kk,v)) = x { let reconstructed = keyset::KeySet::deserialize(&v).unwrap(); println!("Iterated {} [{}] {:?} {:?}", kk[0], v.len(), &v, &reconstruc...
code_fim
hard
{ "lang": "rust", "repo": "MarkOSIndustries/graphlite", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "set" => { impl_trim( " set ", " ", " |,", " |,", x, &mut body, arg, methods, ignore, fn_name, ); } "select" => { let method_name = Ident::new(fn_name, Span::call_site()); let child_bod...
code_fim
hard
{ "lang": "rust", "repo": "rbatis/rbatis", "path": "/rbatis-codegen/src/codegen/parser_html.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let impl_body = parse(&x.childs, methods, &mut ignores, fn_name); let method_impl = crate::codegen::func::impl_fn( &body.to_string(), "", &format!("\"{}\"", collection), false, ...
code_fim
hard
{ "lang": "rust", "repo": "rbatis/rbatis", "path": "/rbatis-codegen/src/codegen/parser_html.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rbatis/rbatis path: /rbatis-codegen/src/codegen/parser_html.rs } Ok(mappers) } /// parse html to function TokenStream pub fn parse_html(html: &str, fn_name: &str, ignore: &mut Vec<String>) -> proc_macro2::TokenStream { let html = html .replace("\\\"", "\"") .replace("\...
code_fim
hard
{ "lang": "rust", "repo": "rbatis/rbatis", "path": "/rbatis-codegen/src/codegen/parser_html.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoelColledge/upload-stick path: /src/bin/upload_stick_prepare.rs extern crate upload_stick; use std::process::{self, Command}; use std::str; use upload_stick::upload_command::*; fn main() { println!("Preparing mass storage volume"); process::exit(match prepare() { Ok(_) => { ...
code_fim
hard
{ "lang": "rust", "repo": "JoelColledge/upload-stick", "path": "/src/bin/upload_stick_prepare.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } fn parted_find_last_free(parted_output: &str) -> Result<(String, String)> { let free_line = parted_output.lines() .filter(|line| line.trim().ends_with("free;")) .last() .ok_or(Error::PartitionFreeNotFound(parted_output.to_string()))?; match free_line.split(":...
code_fim
hard
{ "lang": "rust", "repo": "JoelColledge/upload-stick", "path": "/src/bin/upload_stick_prepare.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // It's more common convert stings to a numeric type. // we can use the parse function and provide the type for the function to parse the string value into // this can be done either without type inference or with the turbofish syntax. // A string will be converted to a type as long as the...
code_fim
medium
{ "lang": "rust", "repo": "kanishkd4/Rust-by-example", "path": "/src/bin/c6_conversions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kanishkd4/Rust-by-example path: /src/bin/c6_conversions.rs // Rust addresses conversion between types by using traits // From and Into are for generic conversions and there are more specific ones. fn main() { let my_str = "hello"; // the from trait allows for a type to create itself fr...
code_fim
medium
{ "lang": "rust", "repo": "kanishkd4/Rust-by-example", "path": "/src/bin/c6_conversions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gemini-15/fuzz path: /src/fmtp/parser.rs //! Nom parser for FMTP use nom::IResult; use nom::{be_u8, be_u16}; use nom::take_while1; use nom; use crate::fmtp::fmtp::*; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum MessageCode { FmtpMsgAccept, FmtpMsgReject, ...
code_fim
hard
{ "lang": "rust", "repo": "gemini-15/fuzz", "path": "/src/fmtp/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }