text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> Pow { location: Location, value: String, }, Custom { location: Location, value: String, }, } impl Operator { pub fn value(&self) -> &String { use Operator::*; match self { Add { value, .. } => value, Sub { value...
code_fim
hard
{ "lang": "rust", "repo": "jbassin/laser", "path": "/lib/parser/src/ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbassin/laser path: /lib/parser/src/ast.rs use std::fmt; #[derive(Clone, Debug, PartialEq)] pub struct Location { start: usize, end: usize, } impl Location { pub fn new(start: usize, end: usize) -> Self { Self { start, end, } } } #[deriv...
code_fim
hard
{ "lang": "rust", "repo": "jbassin/laser", "path": "/lib/parser/src/ast.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Atom { location: Location, value: String, }, Variable { location: Location, value: String, }, BinaryOperation { location: Location, operator: Operator, left: Box<Self>, right: Box<Self>, }, }<|fim_prefix|>// repo: jb...
code_fim
hard
{ "lang": "rust", "repo": "jbassin/laser", "path": "/lib/parser/src/ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// /// Adds a line in the trace formatted like this [{handle info}]{function name} - "{message to log}"] /// The handle info provide the address of the current handle and it's parent handle. /// For example for a connection handle : [Env_0x131904740][Conn_0x131805040] /// #[macro_export] macro_rules! tra...
code_fim
hard
{ "lang": "rust", "repo": "mongodb/mongo-odbc-driver", "path": "/odbc/src/api/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mongodb/mongo-odbc-driver path: /odbc/src/api/mod.rs pub(crate) mod definitions; pub(crate) mod diag; pub(crate) mod errors; mod functions; pub use functions::*; #[cfg(test)] mod col_attr_describe_tests; #[cfg(test)] mod connect_attr_tests; pub(crate) mod data; #[cfg(test)] mod data_tests; #[cfg...
code_fim
hard
{ "lang": "rust", "repo": "mongodb/mongo-odbc-driver", "path": "/odbc/src/api/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Happy-Ferret/synapse path: /src/torrent/picker/sequential.rs use torrent::{Bitfield, Peer}; use control::cio; #[derive(Clone, Debug)] pub struct Picker { /// The max block index that we've picked up to so far piece_idx: usize, pieces: Vec<Piece>, } #[derive(Clone, Debug)] struct Pi...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/synapse", "path": "/src/torrent/picker/sequential.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in self.piece_idx..self.pieces.len() { if self.pieces[i].status == PieceStatus::Complete { self.piece_idx += 1; } } } } #[cfg(test)] mod tests { use torrent::{Info, Peer, Bitfield}; use super::Picker; #[test] fn test_piece...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/synapse", "path": "/src/torrent/picker/sequential.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Write for Lockfile { fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> { self.raise_on_stale_lock()?; let mut lock = self.lock.as_ref().unwrap(); lock.write(buf) } fn flush(&mut self) -> Result<(), io::Error> { let mut lock = self.lock.as_ref()....
code_fim
hard
{ "lang": "rust", "repo": "rouge8/rug", "path": "/src/lockfile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rouge8/rug path: /src/lockfile.rs use std::fs::{self, File, OpenOptions}; use std::io::prelude::*; use std::io::{self, ErrorKind}; use std::path::{Path, PathBuf}; #[derive(Debug)] pub struct Lockfile { file_path: PathBuf, lock_path: PathBuf, pub lock: Option<File>, } impl Lockfile ...
code_fim
hard
{ "lang": "rust", "repo": "rouge8/rug", "path": "/src/lockfile.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kurayamisatoshi/NGC-224 path: /src/gameboy/spec.rs use log::warn; // Gameboy hardware specifications pub const SCREEN_W: usize = 160; pub const SCREEN_H: usize = 144; <|fim_suffix|>#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum Term { GB, // Original GameBoy (GameBoy Classic) G...
code_fim
medium
{ "lang": "rust", "repo": "kurayamisatoshi/NGC-224", "path": "/src/gameboy/spec.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_global_term() -> Term { unsafe { NOW_TERM } } pub fn set_global_term(t: Term) { unsafe { warn!( "Change the Emulator from {:?} to {:?}, it will affect global", NOW_TERM, t ); NOW_TERM = t } }<|fim_prefix|>// repo: kurayamisatoshi/NGC-...
code_fim
hard
{ "lang": "rust", "repo": "kurayamisatoshi/NGC-224", "path": "/src/gameboy/spec.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Color { btn_bg: C::rgba8(0x11, 0x11, 0x11, 0xff), btn_fg: C::YELLOW, btn_stroke: C::RED, btn_bg_hot: C::rgba8(0xff, 0x22, 0xee, 0xff), btn_bg_active: C::WHITE, };<|fim_prefix|>// repo: santokalayil/DRUID-LEARN path: /src/colors/sidebarbtn.rs use druid::Color as C; pub struct...
code_fim
medium
{ "lang": "rust", "repo": "santokalayil/DRUID-LEARN", "path": "/src/colors/sidebarbtn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: santokalayil/DRUID-LEARN path: /src/colors/sidebarbtn.rs use druid::Color as C; pub struct Color { pub btn_bg: C, pub btn_fg: C, pub <|fim_suffix|> Color { btn_bg: C::rgba8(0x11, 0x11, 0x11, 0xff), btn_fg: C::YELLOW, btn_stroke: C::RED, btn_bg_hot: C::rgba8(...
code_fim
medium
{ "lang": "rust", "repo": "santokalayil/DRUID-LEARN", "path": "/src/colors/sidebarbtn.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e: C::RED, btn_bg_hot: C::rgba8(0xff, 0x22, 0xee, 0xff), btn_bg_active: C::WHITE, };<|fim_prefix|>// repo: santokalayil/DRUID-LEARN path: /src/colors/sidebarbtn.rs use druid::Color as C; pub struct Color { pub btn_bg: C, pub btn_fg: C, pub btn_stroke: C, pub btn_bg_hot: ...
code_fim
medium
{ "lang": "rust", "repo": "santokalayil/DRUID-LEARN", "path": "/src/colors/sidebarbtn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: galibey/xsd-parser-rs path: /xsd-types/src/types/gmonth.rs use crate::types::utils::parse_timezone; use chrono::FixedOffset; use std::fmt; use std::str::FromStr; use xsd_macro_utils::UtilsDefaultSerde; #[derive(PartialEq, Debug, UtilsDefaultSerde)] pub struct GMonth { pub value: i32, p...
code_fim
hard
{ "lang": "rust", "repo": "galibey/xsd-parser-rs", "path": "/xsd-types/src/types/gmonth.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[yaserde(prefix = "t", rename = "Text")] pub text: String, } #[test] fn gmonth_serialize_test() { let expected = r#" <?xml version="1.0" encoding="utf-8"?> <t:Message xmlns:t="test"> <t:CreatedAt>--07+06:30</t:CreatedAt> ...
code_fim
hard
{ "lang": "rust", "repo": "galibey/xsd-parser-rs", "path": "/xsd-types/src/types/gmonth.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Kotoba::from_str("モノ"), Kotoba::from_str("食べ物"), Kotoba::from_str("ホットサンド"), Kotoba::from_vec(vec!["ツナチーズ"]), ], fuda: vec!["税込み"], neuchi: 500, comment: "ツナマヨとチーズ\n美味しい × 美味しい\n= すごく美味しい", ...
code_fim
hard
{ "lang": "rust", "repo": "alivelime/motenas", "path": "/omoinas/src/application/omise/comfull_co_jp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alivelime/motenas path: /omoinas/src/application/omise/comfull_co_jp.rs use crate::model::kotoba::Kotoba; use crate::model::mono::Mono; pub fn sendagi() -> Vec<Mono> { return vec![ Mono { namae: "お食事・ドリンクメニュー", category: vec![ Kotoba::from_str...
code_fim
hard
{ "lang": "rust", "repo": "alivelime/motenas", "path": "/omoinas/src/application/omise/comfull_co_jp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn proof_of_knowledge_of_signature() { let mut rng = &mut rand::thread_rng(); let l = 5; let mpk = setup(&mut rng); let keypair = BlindKeyPair::<Bls12>::generate(&mut rng, &mpk, l); let mut message1: Vec<Fr> = Vec::new(); for _i in 0..l { ...
code_fim
hard
{ "lang": "rust", "repo": "boltlabs-inc/libbolt", "path": "/src/cl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // let mut rng = XorShiftRng::seed_from_u64(0xbc4f6d44d62f276c); // let mut rng = XorShiftRng::seed_from_u64(0xb963afd05455863d); let mut rng = &mut rand::thread_rng(); let l = 5; let mpk = setup(&mut rng); let keypair = KeyPair::<Bls12>::generate(&mut rng,...
code_fim
hard
{ "lang": "rust", "repo": "boltlabs-inc/libbolt", "path": "/src/cl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boltlabs-inc/libbolt path: /src/cl.rs ase /// returns the proof state, including commitment a and a blind signature blindSig pub fn prove_commitment<R: Rng>(&self, rng: &mut R, mpk: &PublicParams<E>, signature: &Signature<E>, tOptional: Option<Vec<E::F...
code_fim
hard
{ "lang": "rust", "repo": "boltlabs-inc/libbolt", "path": "/src/cl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rue; } else { println!("hi, can I see your id??"); check_id = true; } } }<|fim_prefix|>// repo: aljo242/rust_crash_course path: /src/conditionals.rs pub fn run() { println!("\n"); let age: u8 = 18; let mut check_id = false; let mut done = false;...
code_fim
hard
{ "lang": "rust", "repo": "aljo242/rust_crash_course", "path": "/src/conditionals.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> done = true; } else if age < 21 && check_id { println!("young fart"); done = true; } else { println!("hi, can I see your id??"); check_id = true; } } }<|fim_prefix|>// repo: aljo242/rust_crash_course path: /src/conditionals...
code_fim
medium
{ "lang": "rust", "repo": "aljo242/rust_crash_course", "path": "/src/conditionals.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aljo242/rust_crash_course path: /src/conditionals.rs pub fn run() { println!("\n"); let age: u8 = 18; let mut check_id = false; let mut done = false; <|fim_suffix|> done = true; } else if age < 21 && check_id { println!("young fart"); done ...
code_fim
medium
{ "lang": "rust", "repo": "aljo242/rust_crash_course", "path": "/src/conditionals.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geofflittle/aws-pass path: /src/main.rs #[macro_use] mod macros; mod client; mod creds; mod dao; mod store; mod util; use rusoto_core::Region; use std::{env, path}; use store::default_pass_store::DefaultPassStore; use structopt::StructOpt; #[derive(Debug, StructOpt)] enum Command { /// Init...
code_fim
hard
{ "lang": "rust", "repo": "geofflittle/aws-pass", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] async fn main() { env_logger::init(); let store_dir = env::var("PASSWORD_STORE_DIR") .map(|psd| path::PathBuf::from(psd)) .unwrap_or(dirs::home_dir().unwrap().join(".aws-pass")); let opt: Opt = Opt::from_args(); let pass_store = DefaultPassStore::new(store_di...
code_fim
hard
{ "lang": "rust", "repo": "geofflittle/aws-pass", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pedrotojal/automaat path: /src/server/src/resources/task.rs , Queryable)] #[table_name = "tasks"] /// The model representing a task stored in the database. pub(crate) struct Task { pub(crate) id: i32, pub(crate) name: String, pub(crate) description: Option<String>, pub(crate) lab...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/server/src/resources/task.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(task) }) } fn create_or_update_associations( self, task: &Task, conn: &PgConnection, ) -> Result<(), Box<dyn error::Error>> { self.variables .into_iter() .try_for_each(|variable| variable.create_or_update(conn, tas...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/server/src/resources/task.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pedrotojal/automaat path: /src/server/src/resources/task.rs _name = "tasks"] /// The model representing a task stored in the database. pub(crate) struct Task { pub(crate) id: i32, pub(crate) name: String, pub(crate) description: Option<String>, pub(crate) labels: Vec<String>, } ...
code_fim
hard
{ "lang": "rust", "repo": "Pedrotojal/automaat", "path": "/src/server/src/resources/task.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> LoadOptionNumberIter<'a> { /// Create a new [`Self`]. pub fn new<VarManager>(var_manager: &'a VarManager) -> Result<Self, efivar::Error> where VarManager: efivar::VarManager + ?Sized, { let inner = var_manager.get_var_names()?; Ok(Self { inner }) } }<|f...
code_fim
hard
{ "lang": "rust", "repo": "MOZGIII/efibootnext", "path": "/efibootnext/src/load_option_number_iter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MOZGIII/efibootnext path: /efibootnext/src/load_option_number_iter.rs //! The iterator providing the available load option numbers. use std::iter::Iterator; /// The iterator providing the available load option numbers. pub struct LoadOptionNumberIter<'a> { /// The inner iterator. pub i...
code_fim
medium
{ "lang": "rust", "repo": "MOZGIII/efibootnext", "path": "/efibootnext/src/load_option_number_iter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.hue = self.hue + amount; self } } impl<T> ShiftHueAssign for Okhsv<T> where T: AddAssign, { type Scalar = T; #[inline] fn shift_hue_assign(&mut self, amount: Self::Scalar) { self.hue += amount; } } impl_color_add!(Okhsv<T>, [hue, saturation, value]);...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/palette", "path": "/palette/src/okhsv/properties.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ogeon/palette path: /palette/src/okhsv/properties.rs use core::ops::{Add, AddAssign, BitAnd, Sub, SubAssign}; #[cfg(feature = "approx")] use approx::{AbsDiffEq, RelativeEq, UlpsEq}; use crate::num::{ self, Arithmetics, FromScalarArray, IntoScalarArray, MinMax, One, PartialCmp, Real, Zero, ...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/palette", "path": "/palette/src/okhsv/properties.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> ShiftHueAssign for Okhsv<T> where T: AddAssign, { type Scalar = T; #[inline] fn shift_hue_assign(&mut self, amount: Self::Scalar) { self.hue += amount; } } impl_color_add!(Okhsv<T>, [hue, saturation, value]); impl_color_sub!(Okhsv<T>, [hue, saturation, value]); impl_...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/palette", "path": "/palette/src/okhsv/properties.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while !queue.is_empty() { let mut newQueue = vec![]; let mut level = vec![]; // 这一层节点的值 for node in queue.iter() { if let Some(node) = node.borrow().left.clone() { // 遇事不决就clone ...
code_fim
hard
{ "lang": "rust", "repo": "aiifabbf/leetcode-memo", "path": "/103.rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aiifabbf/leetcode-memo path: /103.rust/src/main.rs struct Solution; // Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[i...
code_fim
hard
{ "lang": "rust", "repo": "aiifabbf/leetcode-memo", "path": "/103.rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use std::cell::RefCell; use std::rc::Rc; impl Solution { pub fn zigzag_level_order(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<Vec<i32>> { if let Some(root) = root { let mut queue = vec![root]; let mut res = vec![]; let mut sequence = true; // true表示从左到右 ...
code_fim
hard
{ "lang": "rust", "repo": "aiifabbf/leetcode-memo", "path": "/103.rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dolphorama/rust-sandbox path: /delay.rs fn convert<T:Send>(f: fn~() -> T) -> ~fn() -> T { move f } <|fim_suffix|>fn main() { let x: fn~() -> ~str = delay!(~"foo" + "bar"); io::println(x().to_str()) }<|fim_middle|>macro_rules! delay( ($e:expr) => ( convert(|| $e) ) )
code_fim
easy
{ "lang": "rust", "repo": "dolphorama/rust-sandbox", "path": "/delay.rs", "mode": "psm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_suffix|> let x: fn~() -> ~str = delay!(~"foo" + "bar"); io::println(x().to_str()) }<|fim_prefix|>// repo: dolphorama/rust-sandbox path: /delay.rs fn convert<T:Send>(f: fn~() -> T) -> ~fn() -> T { move f } macro_rules! delay( ($e:expr) => ( convert(|| $e) ) ) <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "dolphorama/rust-sandbox", "path": "/delay.rs", "mode": "spm", "license": "WTFPL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seritools/cv-rs path: /src/core.rs //! Core data structures in OpenCV use libc::c_int; use errors::*; use super::wrapper::*; /// This wraps OpenCV's `Mat` class which is designed for n-dimensional dense /// array. It's the most widely used data structure in image/video processing /// since im...
code_fim
hard
{ "lang": "rust", "repo": "seritools/cv-rs", "path": "/src/core.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// 4-connected line Line4 = 4, /// 8-connected line Line8 = 8, /// antialiased line LineAA = 16, } /// A flag to specify how to flip the image. see /// [Mat::flip](struct.Mat.html#method.flip) #[derive(Debug, Clone, Copy)] pub enum FlipCode { /// Along x-axis: dst[i, j] = s...
code_fim
hard
{ "lang": "rust", "repo": "seritools/cv-rs", "path": "/src/core.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> example(&g, chapter, " Airports with 1,2 or 3 runways.", |g| { let results = g .v(()) .has(("runways", P::within(vec![1, 2, 3]))) .count() .to_list()?; Ok(format!("Found {:?} airports", results[0])) })?; Ok(()) } pub fn all() -> ...
code_fim
hard
{ "lang": "rust", "repo": "wolf4ood/gremlin-rs", "path": "/gremlin-tutorial/src/chapters/ch311/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wolf4ood/gremlin-rs path: /gremlin-tutorial/src/chapters/ch311/mod.rs use crate::chapters::example; use crate::chapters::TraversalExamples; use gremlin_client::process::traversal::{GraphTraversalSource, SyncTerminator}; use gremlin_client::structure::P; <|fim_suffix|> let chapter = "3.11"; ...
code_fim
medium
{ "lang": "rust", "repo": "wolf4ood/gremlin-rs", "path": "/gremlin-tutorial/src/chapters/ch311/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match *self { RetroRsError::NoFramebufferError => { write!(f, "This emulator does not have a framebuffer yet.") } RetroRsError::ImageBufferError => write!(f, "Failure in creating image buffer"), RetroRsError::TryFromIntError(ref err) ...
code_fim
medium
{ "lang": "rust", "repo": "JoeOsborn/retro-rs", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoeOsborn/retro-rs path: /src/error.rs use std::error::Error; use std::fmt::Display; #[derive(Debug)] pub enum RetroRsError { NoFramebufferError, ImageBufferError, TryFromIntError(std::num::TryFromIntError), RAMCopyDestTooSmallError, RAMCopySrcOutOfBoundsError, RAMMapOutO...
code_fim
medium
{ "lang": "rust", "repo": "JoeOsborn/retro-rs", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.history.as_str() } } Q_OBJECT! { Chat: slot fn send_msg(String); slot fn get_history(); // workaround because no properties } fn main() { let mut engine = qmlrs::Engine::new(); engine.set_property("chat", Chat::new()); engine.load_local_file("main.qml"); engine.exec(); }<|fim_pr...
code_fim
hard
{ "lang": "rust", "repo": "romariorios/some-kind-of-chat-app", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: romariorios/some-kind-of-chat-app path: /src/main.rs #[macro_use] extern crate qmlrs; truct Chat { history: String } impl Chat { fn new() -> Chat { Chat { history: String::new() } } fn send_msg(&mut self, msg: String) -> String { <|fim_suffix|> engine.set_property("chat", Chat::n...
code_fim
hard
{ "lang": "rust", "repo": "romariorios/some-kind-of-chat-app", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> engine.set_property("chat", Chat::new()); engine.load_local_file("main.qml"); engine.exec(); }<|fim_prefix|>// repo: romariorios/some-kind-of-chat-app path: /src/main.rs #[macro_use] extern crate qmlrs; truct Chat { history: String } impl Chat { fn new() -> Chat { Chat { history: String::...
code_fim
medium
{ "lang": "rust", "repo": "romariorios/some-kind-of-chat-app", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pedrexus/lambda.strategy path: /src/main.rs use crate::handler::{handler, HandlerError}; use lambda::handler_fn; <|fim_suffix|>#[tokio::main] async fn main() -> Result<(), HandlerError> { lambda::run(handler_fn(handler)).await }<|fim_middle|>mod handler; // mod models; mod aws; mod notifica...
code_fim
medium
{ "lang": "rust", "repo": "Pedrexus/lambda.strategy", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] async fn main() -> Result<(), HandlerError> { lambda::run(handler_fn(handler)).await }<|fim_prefix|>// repo: Pedrexus/lambda.strategy path: /src/main.rs use crate::handler::{handler, HandlerError}; use lambda::handler_fn; <|fim_middle|>mod handler; // mod models; mod aws; mod notifica...
code_fim
medium
{ "lang": "rust", "repo": "Pedrexus/lambda.strategy", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/System/RestartManager/mod.rs st RmStatusErrorOnStop: RM_APP_STATUS = RM_APP_STATUS(16i32); pub const RmStatusErrorOnRestart: RM_APP_STATUS = RM_APP_STATUS(32i32); pub const RmStatusShutdownMasked: RM_APP_STATUS = RM_APP_STATUS(64i32); pub cons...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/RestartManager/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Win32/System/RestartManager/mod.rs cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct RM_APP_STATUS(pub i32); pub con...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/RestartManager/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self(value) } } unsafe impl ::windows::core::Abi for RM_REBOOT_REASON { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub str...
code_fim
hard
{ "lang": "rust", "repo": "Corallus-Caninus/windows-rs", "path": "/src/Windows/Win32/System/RestartManager/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zed0/advent-of-code path: /2019/src/bin/aoc-11/main.rs use std::fs; use std::env; use intcode::VirtualMachine; use std::sync::mpsc; use std::thread; use std::collections::HashMap; fn main() { let args: Vec<String> = env::args().collect(); let code: Vec<i64> = fs::read_to_string(&args[1]...
code_fim
hard
{ "lang": "rust", "repo": "zed0/advent-of-code", "path": "/2019/src/bin/aoc-11/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let new_colour = match output_rx.recv() { Err(_) => break, Ok(colour) => colour, }; map.insert(pos, new_colour); let steering_direction = match output_rx.recv() { Err(_) => break, Ok(direction) => direction, }; ...
code_fim
hard
{ "lang": "rust", "repo": "zed0/advent-of-code", "path": "/2019/src/bin/aoc-11/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/winrt-rs path: /crates/libs/sys/src/Windows/Win32/System/SideShow/mod.rs pub type ISideShowBulkCapabilities = *mut ::core::ffi::c_void; pub type ISideShowCapabilities = *mut ::core::ffi::c_void; pub type ISideShowCapabilitiesCollection = *mut ::core::ffi::c_void; pub type ISideShowCont...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/winrt-rs", "path": "/crates/libs/sys/src/Windows/Win32/System/SideShow/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> *self } } #[repr(C, packed(1))] #[doc = "*Required features: `\"Win32_System_SideShow\"`*"] pub struct EVENT_DATA_HEADER { pub cbEventDataHeader: u32, pub guidEventType: ::windows_sys::core::GUID, pub dwVersion: u32, pub cbEventDataSid: u32, } impl ::core::marker::Copy for EVEN...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/winrt-rs", "path": "/crates/libs/sys/src/Windows/Win32/System/SideShow/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn if_2() { let result = match format_message("CSML/basic_test/syntax/if/if_2.csml".to_owned()) { Ok(_) => false, Err(_) => true, }; assert!(result); }<|fim_prefix|>// repo: salimclevy/csml-interpreter path: /tests/if.rs mod support; use csmlinterpreter::data::ast::F...
code_fim
hard
{ "lang": "rust", "repo": "salimclevy/csml-interpreter", "path": "/tests/if.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: salimclevy/csml-interpreter path: /tests/if.rs mod support; use csmlinterpreter::data::ast::Flow; use csmlinterpreter::error_format::ErrorInfo; use csmlinterpreter::parser::parse_flow; <|fim_suffix|> let result = match format_message("CSML/basic_test/syntax/if/if_2.csml".to_owned()) { ...
code_fim
hard
{ "lang": "rust", "repo": "salimclevy/csml-interpreter", "path": "/tests/if.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let result = match format_message("CSML/basic_test/syntax/if/if_1.csml".to_owned()) { Ok(_) => true, Err(_) => false, }; assert!(result); } //////////////////////////////////////////////////////////////////////////////// /// IF INVALID SYNTAX /////////////////////////////////...
code_fim
medium
{ "lang": "rust", "repo": "salimclevy/csml-interpreter", "path": "/tests/if.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evopen/maligog path: /src/image_view.rs use std::sync::Arc; use ash::vk::{self, Handle}; use crate::{Device, Image}; pub struct ImageViewRef { pub(crate) device: Device, pub(crate) handle: vk::ImageView, pub(crate) image: Image, } #[derive(Clone)] pub struct ImageVie...
code_fim
hard
{ "lang": "rust", "repo": "evopen/maligog", "path": "/src/image_view.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Drop for ImageViewRef { fn drop(&mut self) { unsafe { self.device.handle().destroy_image_view(self.handle, None); } } } impl Image { pub fn create_view(&self) -> ImageView { ImageView::new(&self.inner.device, self) } }<|fim_prefix|>// r...
code_fim
hard
{ "lang": "rust", "repo": "evopen/maligog", "path": "/src/image_view.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for row in message { println!("{:#?}", row?); } } _ => { println!("You should use [c, r] to create or read messages.") } }; Ok(()) }<|fim_prefix|>// repo: steadylearner/Rust-Full-Stack path: /database/sqlite_rust/src/mai...
code_fim
hard
{ "lang": "rust", "repo": "steadylearner/Rust-Full-Stack", "path": "/database/sqlite_rust/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steadylearner/Rust-Full-Stack path: /database/sqlite_rust/src/main.rs use std::io::stdin; use rusqlite::NO_PARAMS; use rusqlite::{params, Connection, Result}; use chrono::naive::NaiveDateTime; #[derive(Debug)] struct Message { query: String, // Query is unique so use it as id. created...
code_fim
medium
{ "lang": "rust", "repo": "steadylearner/Rust-Full-Stack", "path": "/database/sqlite_rust/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/core/src/physical_optimizer/combine_partial_final_agg.rs Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright owners...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/core/src/physical_optimizer/combine_partial_final_agg.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Arc::new(ParquetExec::new( FileScanConfig { object_store_url: ObjectStoreUrl::parse("test:///").unwrap(), file_schema: schema.clone(), file_groups: vec![vec![PartitionedFile::new("x".to_string(), 100)]], statistics: Statis...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/core/src/physical_optimizer/combine_partial_final_agg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// To compare the group expressions between the final and partial aggregations, need to discard all the column indexes and compare fn normalize_group_exprs(group_exprs: GroupExprsRef) -> GroupExprs { let (group, agg, filter) = group_exprs; let new_group_expr = group .expr() .iter()...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/core/src/physical_optimizer/combine_partial_final_agg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let map = &mut HashMap::new(); map.insert(22, format!("Hello, world")); map.insert(44, format!("Goodbye, world")); process_or_insert_default(map, 22); process_or_insert_default(map, 66); assert_eq!(map[&66], ""); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/t...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/nll/process_or_insert_default.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/process_or_insert_default.rs // run-pass use std::collections::HashMap; fn process_or_insert_default(map: &mut HashMap<usize, String>, key: usize) { match map.get_mut(&key) { Some(value) => { process(value); ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/nll/process_or_insert_default.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn process(x: &str) { assert_eq!(x, "Hello, world"); } fn main() { let map = &mut HashMap::new(); map.insert(22, format!("Hello, world")); map.insert(44, format!("Goodbye, world")); process_or_insert_default(map, 22); process_or_insert_default(map, 66); assert_eq!(map[&66], ""...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/nll/process_or_insert_default.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn update_consumer(consumer : Consumer, connection : DbConn) -> Consumer { let db_con = &*connection; diesel::update(consumers::table) .set(&consumer) .get_result(db_con) .expect("Could not update consumer") } pub fn delete_consumer(uuid : Uuid, connection : DbConn) ->...
code_fim
medium
{ "lang": "rust", "repo": "noah-brabec/FarmersMarket", "path": "/the-barn/src/api/components/consumer/service.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noah-brabec/FarmersMarket path: /the-barn/src/api/components/consumer/service.rs use diesel::prelude::*; use uuid::Uuid; use crate::schema::{consumers}; use crate::api::components::consumer::model::Consumer; use crate::database::DbConn; <|fim_suffix|>pub fn get_consumer_by_id(uuid : Uuid, conne...
code_fim
hard
{ "lang": "rust", "repo": "noah-brabec/FarmersMarket", "path": "/the-barn/src/api/components/consumer/service.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VREDUCEPS, operand1: Some(Direct(ZMM1)), operand2: Some(Direct(ZMM0)), operand3: Some(Literal8(75)), operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: true, mask: Some(MaskReg::K4), broadcast: None }, &[98, 243, 125, 1...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_vreduceps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_vreduceps.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; ...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_vreduceps.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VREDUCEPS, operand1: Some(Direct(ZMM1)), operand2: Some(IndirectScaledIndexed(EDI, EBX, Four, Some(OperandSize::Zmmword), None)), operand3: Some(Literal8(118)), operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false, ...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_vreduceps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ans += 1; } } ans } }<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/easy/number_of_strings_that_appear_as_substrings_in_word.rs impl Solution { pub fn num_of_strings(patterns: Vec<String>, word: String) -> i32 { let mut ans = 0; f...
code_fim
medium
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/easy/number_of_strings_that_appear_as_substrings_in_word.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/easy/number_of_strings_that_appear_as_substrings_in_word.rs impl Solution { pub fn num_of_strings(patterns: Vec<String<|fim_suffix|>p in &patterns { if word.find(p).is_some() { ans += 1; } } ans ...
code_fim
medium
{ "lang": "rust", "repo": "stackcats/leetcode", "path": "/algorithms/easy/number_of_strings_that_appear_as_substrings_in_word.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mguomanila/miro path: /src/opengl/renderer.rs 32.0; lazy_static! { static ref CURRENT_TIME_LENGTH: usize = "00:00:00".chars().count(); static ref CPU_LOAD_LENGTH: usize = "CPU:00%".chars().count(); } const HEADER_TOP_PADDING: f32 = 15.0; const HEADER_WIDTH_PADDING: f32 = 13.0; const G...
code_fim
hard
{ "lang": "rust", "repo": "mguomanila/miro", "path": "/src/opengl/renderer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (has_color, ft_glyph, cell_width, cell_height) = { let font = self.fonts.cached_font(style)?; let mut font = font.borrow_mut(); let (height, width, _) = font.get_metrics()?; let has_color = font.has_color(info.font_idx)?; // This clon...
code_fim
hard
{ "lang": "rust", "repo": "mguomanila/miro", "path": "/src/opengl/renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let key = GlyphKey { font_idx: info.font_idx, glyph_pos: info.glyph_pos, style: style.clone() }; let mut cache = self.glyph_cache.borrow_mut(); if let Some(entry) = cache.get(&key) { return Ok(Rc::clone(entry)); } let glyph = self.load_gly...
code_fim
hard
{ "lang": "rust", "repo": "mguomanila/miro", "path": "/src/opengl/renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Awhiteweb/wasm-menu-planner path: /src/graphql.rs #[cynic::query_module( schema_path = r#"../schemas/schema.graphql"#, query_module = "query_dsl", )] mod queries { use super::{query_dsl, types::*}; #[derive(cynic::FragmentArguments, Debug)] pub struct InsertWeekArguments { ...
code_fim
hard
{ "lang": "rust", "repo": "Awhiteweb/wasm-menu-planner", "path": "/src/graphql.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(cynic::QueryFragment, Debug)] #[cynic(graphql_type = "WeekDay")] pub struct WeekDay { pub meals: Option<Vec<Option<WeekDayMeal>>>, pub title: Option<String>, } #[derive(cynic::QueryFragment, Debug)] #[cynic(graphql_type = "WeekDayMeal")] pub struct Wee...
code_fim
hard
{ "lang": "rust", "repo": "Awhiteweb/wasm-menu-planner", "path": "/src/graphql.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut dir = Path::new("."); if let Some(_dir) = args.get(1) { dir = Path::new(_dir); } match print(&dir, 1, 0, 0) { Ok((dc, fc)) => { println!("\n{} directories, {} files", dc, fc); }, Err(_e) => {} } }<|fim_prefix|>// repo: rektrex/tree ...
code_fim
medium
{ "lang": "rust", "repo": "rektrex/tree", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match print(&dir, 1, 0, 0) { Ok((dc, fc)) => { println!("\n{} directories, {} files", dc, fc); }, Err(_e) => {} } }<|fim_prefix|>// repo: rektrex/tree path: /src/main.rs pub mod lib; use lib::print; use std::path::Path; use std::env; <|fim_middle|>fn main() { ...
code_fim
medium
{ "lang": "rust", "repo": "rektrex/tree", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rektrex/tree path: /src/main.rs pub mod lib; use lib::print; use std::path::Path; use std::env; fn main() { let args: Vec<String> = env::args().collect(); let mut dir = Path::new("."); <|fim_suffix|> match print(&dir, 1, 0, 0) { Ok((dc, fc)) => { println!("\n{} ...
code_fim
medium
{ "lang": "rust", "repo": "rektrex/tree", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: knut0815/unfold path: /src/half_edge/mesh.rs .filter(|&eid| self.is_border_half_edge(eid)) .collect() } /// Returns a list of all of the indices of the vertices along the border of the mesh. pub fn boundary_vertices(&self) -> Vec<VertexIndex> { self.boundary_edg...
code_fim
hard
{ "lang": "rust", "repo": "knut0815/unfold", "path": "/src/half_edge/mesh.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> // edge -> next -> prev should equal edge assert_eq!(hem.half_edge(hem.half_edge(curr).next_id).prev_id, curr); // edge -> prev -> next should equal edge assert_eq!(hem.half_edge(hem.half_edge(curr).prev_id).next_id, curr); // edge -> next -> f...
code_fim
hard
{ "lang": "rust", "repo": "knut0815/unfold", "path": "/src/half_edge/mesh.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: knut0815/unfold path: /src/half_edge/mesh.rs dge. The vector will /// always be oriented such that it points from the half-edge's origin vertex towards the /// half-edge's "destination" vertex (edge -> next -> origin). pub fn edge_vector(&self, eid: HalfEdgeIndex) -> Vec3 { l...
code_fim
hard
{ "lang": "rust", "repo": "knut0815/unfold", "path": "/src/half_edge/mesh.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phototools/phototools path: /src/filetools.rs use chrono::offset::Utc; use chrono::DateTime; use std::fs::{self, Metadata}; use std::io; use std::path::Path; use std::time::SystemTime; <|fim_suffix|>fn format_time(t: SystemTime) -> String { let datetime: DateTime<Utc> = DateTime::from(t); ...
code_fim
hard
{ "lang": "rust", "repo": "phototools/phototools", "path": "/src/filetools.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn format_time(t: SystemTime) -> String { let datetime: DateTime<Utc> = DateTime::from(t); let dt = datetime.format("%Y-%m-%d %T"); format!("{}", dt) } // TODO unit tests<|fim_prefix|>// repo: phototools/phototools path: /src/filetools.rs use chrono::offset::Utc; use chrono::DateTime; use st...
code_fim
hard
{ "lang": "rust", "repo": "phototools/phototools", "path": "/src/filetools.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let datetime: DateTime<Utc> = DateTime::from(t); let dt = datetime.format("%Y-%m-%d %T"); format!("{}", dt) } // TODO unit tests<|fim_prefix|>// repo: phototools/phototools path: /src/filetools.rs use chrono::offset::Utc; use chrono::DateTime; use std::fs::{self, Metadata}; use std::io; use ...
code_fim
hard
{ "lang": "rust", "repo": "phototools/phototools", "path": "/src/filetools.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn calc_num_passphrases(v :&Vec<Vec<&str>>, strict: bool) -> u32 { let mut sum = 0; for line in v.iter() { let mut unique = false; let mut set = HashSet::new(); for word in line.iter() { let mut str_word = String::from(*word); if strict { let mut chars: Vec<char> = word.chars().collect()...
code_fim
medium
{ "lang": "rust", "repo": "vechema/AdventOfCode2017", "path": "/04passphrase/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vechema/AdventOfCode2017 path: /04passphrase/src/main.rs extern crate utilities; use std::collections::HashSet; fn main() { let input = utilities::read_file("input.txt"); // Turn string into array of array of strings let mut v = Vec::new(); for line in input.split("\r\n") { let mut line_...
code_fim
medium
{ "lang": "rust", "repo": "vechema/AdventOfCode2017", "path": "/04passphrase/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn handle_interrupt(gb: &mut GameBoy, flags: u8, interrupt: u8) { gb.cpu.interrupt_enable_master = false; gb.memory .set_register(Register::InterruptFlag, flags & !interrupt); let pc = gb.cpu.pc; push_word(gb, pc); gb.cpu.pc = get_interrupt_handler_addr(interrupt); } ...
code_fim
hard
{ "lang": "rust", "repo": "nwessing/gameboy", "path": "/gameboy/src/interrupts.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nwessing/gameboy path: /gameboy/src/interrupts.rs use crate::game_boy::GameBoy; use crate::memory::Register; use crate::util::push_word; const V_BLANK: u8 = 0x01; const LCD_STAT: u8 = 0x02; const TIMER: u8 = 0x04; const SERIAL: u8 = 0x08; const JOYPAD: u8 = 0x10; <|fim_suffix|>fn han...
code_fim
hard
{ "lang": "rust", "repo": "nwessing/gameboy", "path": "/gameboy/src/interrupts.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Create a TCP listener on the server host and lmtp ssl port pub fn lmtp_ssl_listener(&self) -> Option<Result<TcpListener>> { self.generic_listener(self.conf.lmtp_ssl_port) } pub fn imap_ssl(&self, stream: TcpStream) -> Stream { if let Ok(addr) = stream.local_addr() { ...
code_fim
hard
{ "lang": "rust", "repo": "dgurnani12/SEGIMAP", "path": "/core/src/server/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgurnani12/SEGIMAP path: /core/src/server/mod.rs use std::collections::HashMap; use std::io::{Read, Result, Write}; use std::net::{Shutdown, TcpListener, TcpStream}; use std::result::Result as StdResult; use std::sync::Arc; use bufstream::{BufStream, IntoInnerError}; use openssl::ssl::{SslAccep...
code_fim
hard
{ "lang": "rust", "repo": "dgurnani12/SEGIMAP", "path": "/core/src/server/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Load the user data from the specified user data file. let users = load_users(&conf.users)?; let ssl_acceptor = conf.get_ssl_acceptor().ok(); Ok(Server { conf: conf, users: users, ssl_acceptor: ssl_acceptor, }) } /// C...
code_fim
hard
{ "lang": "rust", "repo": "dgurnani12/SEGIMAP", "path": "/core/src/server/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // get api key scopes from db let mut db = request.guard::<PgsqlConn>().unwrap(); let query = "SELECT scopes FROM api_keys WHERE api_key = $1;"; let rows = db.query(query, &[&api_key]).unwrap(); if let Some(row) = rows.get(0) { Outcome::Success(...
code_fim
hard
{ "lang": "rust", "repo": "ItsaMeTuni/calendar-server", "path": "/src/authentication/auth_guard.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ItsaMeTuni/calendar-server path: /src/authentication/auth_guard.rs use rocket::request::{FromRequest, Outcome}; use rocket::Request; use rocket::http::Status; use crate::connection_pool::PgsqlConn; use crate::database_helpers::{get_cell_from_row}; use rocket::outcome::IntoOutcome; use uuid::Uuid...
code_fim
hard
{ "lang": "rust", "repo": "ItsaMeTuni/calendar-server", "path": "/src/authentication/auth_guard.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }