text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // TODO: This should be a Option<Pane> because there might not be any. pub fn get_active_pane_mut(&mut self) -> Option<&mut Pane> { self.panes.get_mut(self.active_pane) } pub fn get_scroll_active_pane_mut(&mut self) -> Option<&mut Pane> { self.panes.get_mut(self.scroll_act...
code_fim
hard
{ "lang": "rust", "repo": "jimmyhmiller/PlayGround", "path": "/rust/editor/src/pane_manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jimmyhmiller/PlayGround path: /rust/editor/src/pane_manager.rs use std::cmp::{max, min}; use rand::Rng; use crate::{pane::{TextPane, Pane, AdjustablePosition}, Window, renderer::EditorBounds, ink::InkManager}; #[derive(Debug, Clone, Copy)] pub enum PaneSelector { Active, Id(usize), ...
code_fim
hard
{ "lang": "rust", "repo": "jimmyhmiller/PlayGround", "path": "/rust/editor/src/pane_manager.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_pane_by_id_mut(&mut self, pane_id: usize) -> Option<&mut Pane> { for pane in self.panes.iter_mut() { if pane.id() == pane_id { return Some(pane); } } None } pub fn get_pane_by_id(&self, pane_id: usize) -> Option<&Pane> ...
code_fim
hard
{ "lang": "rust", "repo": "jimmyhmiller/PlayGround", "path": "/rust/editor/src/pane_manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koshkin-na/geonames-lib path: /src/model/alternate_name.rs use serde::{Deserialize, Serialize}; use crate::err::{DeserializeErr}; #[derive(Deserialize, Serialize, Clone, Debug)] pub struct AlternateName { /// the id of this alternate name, int pub alternate_name_id: i32, /// geoname...
code_fim
medium
{ "lang": "rust", "repo": "koshkin-na/geonames-lib", "path": "/src/model/alternate_name.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use crate::model::AlternateName; #[test] fn deserialize_string_to_alternate_name() { use std::fs::File; use std::io::{BufRead, BufReader}; for line in BufReader::new(File::open("./test-data/alternate_name_gb.txt").unwrap()).lines() { ...
code_fim
hard
{ "lang": "rust", "repo": "koshkin-na/geonames-lib", "path": "/src/model/alternate_name.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> use std::fs::File; use std::io::{BufRead, BufReader}; for line in BufReader::new(File::open("./test-data/alternate_name_gb.txt").unwrap()).lines() { let _alternate_name = AlternateName::deserialize_from_string(&line.unwrap()).unwrap(); } } }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "koshkin-na/geonames-lib", "path": "/src/model/alternate_name.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /// Scales each vertex of this mesh. #[inline] pub fn scale_by(&mut self, s: &Vector<N>) { for c in self.coords.iter_mut() { for i in 0..DIM { c[i] = (*c)[i] * s[i]; } } // FIXME: do something for the normals? } /// Apply...
code_fim
hard
{ "lang": "rust", "repo": "dimforge/ncollide", "path": "/src/procedural/polyline.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Rotates each vertex and normal of this polyline. pub fn rotate_by(&mut self, r: &Rotation<N>) { for c in self.coords.iter_mut() { *c = r * &*c; } for n in self.normals.iter_mut() { for n in n.iter_mut() { *n = r * &*n; ...
code_fim
hard
{ "lang": "rust", "repo": "dimforge/ncollide", "path": "/src/procedural/polyline.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dimforge/ncollide path: /src/procedural/polyline.rs use crate::math::{Isometry, Point, Rotation, Translation, Vector, DIM}; use na::{self, RealField}; /// Geometric description of a polyline. #[derive(Clone)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Polyline<N: ...
code_fim
hard
{ "lang": "rust", "repo": "dimforge/ncollide", "path": "/src/procedural/polyline.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>s register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."] pub struct HPTXFSIZ_SPEC; impl crate::RegisterSpec for HPTXFSIZ_SPEC { type Ux = u32; } #[doc = "`read()` method returns [`hptxfsiz::R`](R) reader structure"] impl crate::Readable for HPTXFSIZ_SPEC {} #[doc = "`write(|w| ..)` ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h735/otg1_hs_global/hptxfsiz.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h7/src/stm32h735/otg1_hs_global/hptxfsiz.rs #[doc = "Register `HPTXFSIZ` reader"] pub type R = crate::R<HPTXFSIZ_SPEC>; #[doc = "Register `HPTXFSIZ` writer"] pub type W = crate::W<HPTXFSIZ_SPEC>; #[doc = "Field `PTXSA` reader - Host periodic TxFIFO start a...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h735/otg1_hs_global/hptxfsiz.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod bookmarks; pub use crate::bookmarks::Bookmark; pub mod content; mod creator; mod encodings; mod error; pub mod filters; #[cfg(not(feature = "nom_parser"))] #[cfg(feature = "pom_parser")] mod parser; #[cfg(feature = "nom_parser")] #[path = "nom_parser.rs"] mod parser; mod parser_aux; mod processor; mod...
code_fim
medium
{ "lang": "rust", "repo": "HeroicKatora/lopdf", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HeroicKatora/lopdf path: /src/lib.rs #[macro_use] mod object; mod datetime; pub use crate::object::{Dictionary, Object, ObjectId, Stream, StringFormat}; <|fim_suffix|>mod bookmarks; pub use crate::bookmarks::Bookmark; pub mod content; mod creator; mod encodings; mod error; pub mod filters; #[cf...
code_fim
medium
{ "lang": "rust", "repo": "HeroicKatora/lopdf", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: handle both bound and count arguments let bound = args.flag_bound.unwrap(); let sieve = primer::Sieve::new(bound); for prime in sieve.iter() { print!("{}, ", prime); } println!(); }<|fim_prefix|>// repo: scottwillmoore/rust-primer path: /src/main.rs #[macro_use] ...
code_fim
hard
{ "lang": "rust", "repo": "scottwillmoore/rust-primer", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] enum Format { Compact, } fn main() { let args: Args = docopt::Docopt::new(USAGE) .and_then(|docopt| { docopt .help(true) .version(Some(String::from(VERSION))) .deserialize() }) .unwra...
code_fim
hard
{ "lang": "rust", "repo": "scottwillmoore/rust-primer", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scottwillmoore/rust-primer path: /src/main.rs #[macro_use] extern crate serde_derive; extern crate docopt; extern crate primer; const USAGE: &'static str = " Usage: prime_sieve (--count=N | --bound=N) [--sieve=METHOD] prime_sieve --help prime_sieve --version Options: -h --help ...
code_fim
medium
{ "lang": "rust", "repo": "scottwillmoore/rust-primer", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johanlindblad/icfp2k6-vm path: /src/cpu.rs use operator::Operator; use std::fmt; use instruction::Instruction; use std::io; #[derive(Debug)] pub struct Cpu { registers: [u32; 8], platters: Vec<Box<[u32]>>, program_counter: usize, halted: bool, input_buffer: String } impl Cp...
code_fim
hard
{ "lang": "rust", "repo": "johanlindblad/icfp2k6-vm", "path": "/src/cpu.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 5 Operator::Division([a, b, c]) => { let value = self.registers[b as usize] / self.registers[c as usize]; self.registers[a as usize] = value; }, // 6 Operator::NotAnd([a, b, c]) => { let value =...
code_fim
hard
{ "lang": "rust", "repo": "johanlindblad/icfp2k6-vm", "path": "/src/cpu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 9 Operator::Abandonment(index_register) => { let index = self.registers[index_register as usize]; if index == 0 { panic!("Trying to abandon platter 0"); } self.platters[index as usize] = Box::n...
code_fim
hard
{ "lang": "rust", "repo": "johanlindblad/icfp2k6-vm", "path": "/src/cpu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let s = Show::new(&["2♡", "3♡", "4♡", "5♡"], "6♡"); assert_eq!( s.hand, Hand::new(&["2♡", "3♡", "4♡", "5♡"]), ) } #[test] fn test_show_constructor_3() { let s = Show::new(&vec!["2♡", "3♡", "4♡", "5♡"], "6♡"); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "harryscholes/cribbage", "path": "/src/hand.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harryscholes/cribbage path: /src/hand.rs use crate::card::{ Card, deck, }; use rand::{ thread_rng, seq::SliceRandom, // `choose_multiple` }; #[derive(Eq, PartialEq, Debug)] pub struct Hand { pub hand: Vec<Card>, } impl Hand { pub fn new(cs: &[&str]) -> Self { if...
code_fim
hard
{ "lang": "rust", "repo": "harryscholes/cribbage", "path": "/src/hand.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Hand::new(&vec!["2♡", "3♡", "4♡", "5♡"]), Hand::new(&["2♡", "3♡", "4♡", "5♡"]), ); } #[test] fn test_hand_rand_1() { assert_eq!( Hand::rand().hand.len(), 4, ); } #[test] fn test_hand_fn_1(...
code_fim
hard
{ "lang": "rust", "repo": "harryscholes/cribbage", "path": "/src/hand.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Performs the g-t-n integration with constant tensor field (coupled with itself) #[rustfmt::skip] pub fn mat_05_btn(&self, tt: &Tensor2) -> Matrix { let c = self.volume / 4.0; let mat = tt.to_matrix(); let (t00, t01, t02) = (mat.get(0,0), mat.get(0,1), mat.get(0,2));...
code_fim
hard
{ "lang": "rust", "repo": "cpmech/gemlab", "path": "/src/integ/analytical_tet4.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpmech/gemlab path: /src/integ/analytical_tet4.rs let x1 = pad.xxt.get(0, 0); let x2 = pad.xxt.get(0, 1); let x3 = pad.xxt.get(0, 2); let x4 = pad.xxt.get(0, 3); let y1 = pad.xxt.get(1, 0); let y2 = pad.xxt.get(1, 1); let y3 = pad.xxt.get(1, ...
code_fim
hard
{ "lang": "rust", "repo": "cpmech/gemlab", "path": "/src/integ/analytical_tet4.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpmech/gemlab path: /src/integ/analytical_tet4.rs (b30, b31, b32) = (self.bb.get(3,0), self.bb.get(3,1), self.bb.get(3,2)); Matrix::from(&[ [c*b00*(a00*b00 + a10*b01 + a20*b02) + c*b01*(a01*b00 + a11*b01 + a21*b02) + c*b02*(a02*b00 + a12*b01 + a22*b02), c*b10*(a00*b00 + a10*...
code_fim
hard
{ "lang": "rust", "repo": "cpmech/gemlab", "path": "/src/integ/analytical_tet4.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StewartCanva/rust-skia path: /skia-safe/src/core/image_generator.rs #[cfg(feature = "gpu")] use crate::gpu; use crate::{ image, prelude::*, AlphaType, ColorSpace, Data, ISize, ImageInfo, Matrix, Paint, Picture, SurfaceProps, }; use skia_bindings::{self as sb, SkImageGenerator}; use std::...
code_fim
hard
{ "lang": "rust", "repo": "StewartCanva/rust-skia", "path": "/skia-safe/src/core/image_generator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_encoded_with_alpha_type( encoded: impl Into<Data>, alpha_type: impl Into<Option<AlphaType>>, ) -> Option<Self> { Self::from_ptr(unsafe { sb::C_SkImageGenerator_MakeFromEncoded( encoded.into().into_ptr(), alpha_type ...
code_fim
hard
{ "lang": "rust", "repo": "StewartCanva/rust-skia", "path": "/skia-safe/src/core/image_generator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_encoded(encoded: impl Into<Data>) -> Option<Self> { Self::from_ptr(unsafe { sb::C_SkImageGenerator_MakeFromEncoded(encoded.into().into_ptr(), ptr::null()) }) } pub fn from_encoded_with_alpha_type( encoded: impl Into<Data>, alpha_type: im...
code_fim
hard
{ "lang": "rust", "repo": "StewartCanva/rust-skia", "path": "/skia-safe/src/core/image_generator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reklawnos/housecat path: /src/utils.rs pub fn get_caret_string(col: usize) -> String { let mut caret_string = String::with_capacity(col + 1); for _ in 0..col { caret_string.push(' '); } caret_string.push('^'); return caret_string; } <|fim_suffix|> #[test] fn ...
code_fim
easy
{ "lang": "rust", "repo": "reklawnos/housecat", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(&*get_caret_string(4), " ^"); } }<|fim_prefix|>// repo: reklawnos/housecat path: /src/utils.rs pub fn get_caret_string(col: usize) -> String { let mut caret_string = String::with_capacity(col + 1); for _ in 0..col { caret_string.push(' '); } caret_string....
code_fim
medium
{ "lang": "rust", "repo": "reklawnos/housecat", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Update::RefreshDom } extern "C" fn export_py(data: &mut RefAny, _info: &mut CallbackInfo) -> Update { Update::RefreshDom } extern "C" fn export_html(data: &mut RefAny, _info: &mut CallbackInfo) -> Update { Update::RefreshDom } extern "C" fn enable_debug_layout(data: &mut RefAny, _info: &mut...
code_fim
hard
{ "lang": "rust", "repo": "NNemec/azul", "path": "/examples/rust/xml.rs", "mode": "spm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NNemec/azul path: /examples/rust/xml.rs #![windows_subsystem = "windows"] use azul::{ app::{App, AppConfig, LayoutSolver}, css::Css, style::StyledDom, dom::Dom, menu::{Menu, MenuItem, StringMenuItem}, callbacks::{RefAny, CallbackInfo, Update, LayoutCallbackInfo}, win...
code_fim
hard
{ "lang": "rust", "repo": "NNemec/azul", "path": "/examples/rust/xml.rs", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|> window.show_all(); let window_preferences_clone = window_preferences.clone(); combo_add_cell(&combo_resize_filter, 0); combo_add_cell(&combo_resize_filter, 1); combo_resize_filter.set_active(0); let directory_clone = directory_entry.clone(); let store_errors = create_errors_store(&builder); ...
code_fim
hard
{ "lang": "rust", "repo": "eij/rs-convert", "path": "/src/ui/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eij/rs-convert path: /src/ui/mod.rs use std::path::PathBuf; use std::sync::atomic::Ordering; use gtk::prelude::*; use gtk::{ self, Builder, Button, CellRendererText, ComboBox, CheckButton, Entry, FileChooserDialog, ListBox, ProgressBar, TreeView, TreeStore, TreeViewColumn, Scale, ...
code_fim
hard
{ "lang": "rust", "repo": "eij/rs-convert", "path": "/src/ui/mod.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> window } fn create_errors_store(builder: &Builder) -> TreeStore { let tree_errors: TreeView = builder.get_object("tree_errors").unwrap(); let store_errors = TreeStore::new(&[String::static_type(), String::static_type()]); tree_errors.set_model(Some(&store_errors)); tree_errors.set_headers_visible(t...
code_fim
hard
{ "lang": "rust", "repo": "eij/rs-convert", "path": "/src/ui/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> fn grow<O: PropagatorOps, S: FnMut(u32, Sign, Level)>(&mut self, o: O, mut set: S) { let position = o.signs_len() - 1; self.factor.compute(position + 1); if position == 0 { set(0, Sign::Plus, MIN_LEVEL); } else { for k in self.factor[position +...
code_fim
hard
{ "lang": "rust", "repo": "andersk/discrepancy", "path": "/src/multiplicative_propagator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn grow<O: PropagatorOps, S: FnMut(u32, Sign, Level)>(&mut self, o: O, mut set: S) { let position = o.signs_len() - 1; self.factor.compute(position + 1); if position == 0 { set(0, Sign::Plus, MIN_LEVEL); } else { for k in self.factor[position + ...
code_fim
hard
{ "lang": "rust", "repo": "andersk/discrepancy", "path": "/src/multiplicative_propagator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andersk/discrepancy path: /src/multiplicative_propagator.rs use super::factor::Factor; use super::level::{Level, MIN_LEVEL}; use super::propagator::{PropagatorOps, Propagator}; use super::sign::Sign; use std::cmp; pub struct MultiplicativePropagator { factor: Factor, } impl Multiplicative...
code_fim
hard
{ "lang": "rust", "repo": "andersk/discrepancy", "path": "/src/multiplicative_propagator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let this_communicator_uid: Uid = Uid::generate_totally_unique() .expect("Failed to generate unique identifier"); let other_communicator_uid: Uid = Uid::generate_totally_unique() .expect("Failed to generate unique identifier"); let communication_key: Aes = Aes::new_random() .expect("Failed t...
code_fim
hard
{ "lang": "rust", "repo": "igorty/encrypted_communicator", "path": "/src/communicator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Tests `Communicator::process_incoming()` function's happy path. Checks /// `Operation::Establish` request from an&nbsp;already known communicator. /// Accepts it. #[test] fn communicator_process_incoming_establish_operation_accept_reestablish() { let own_identifier: Uid = Uid::generate_totally_...
code_fim
hard
{ "lang": "rust", "repo": "igorty/encrypted_communicator", "path": "/src/communicator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: igorty/encrypted_communicator path: /src/communicator.rs d here .expect("Internal error: Failed to serialize data structure for sending") ) } /// Prepares a&nbsp;connection request to `another_communicator` /// # Parameters /// * `another_communicator` &ndash; communicator a&nbsp;conn...
code_fim
hard
{ "lang": "rust", "repo": "igorty/encrypted_communicator", "path": "/src/communicator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let claims: &Claims = claim_mutex.inner(); let claim_list :&Vec<Claim> = &*claims.claim_list.lock().unwrap(); return json!(claim_list.clone()).to_string(); } fn main() { rocket::ignite() .manage(Claims { claim_list:Mutex::new(Vec::new()) }) .mount("/", ...
code_fim
hard
{ "lang": "rust", "repo": "MattLangsenkamp/fightyboiscorpse", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MattLangsenkamp/fightyboiscorpse path: /src/main.rs #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; #[macro_use] extern crate serde_derive; use rocket_contrib::json::Json; use rocket::State; use std::sync::{Mutex}; use serde_json::json; extern crate postgres; //u...
code_fim
hard
{ "lang": "rust", "repo": "MattLangsenkamp/fightyboiscorpse", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ValorCat/csis-616-automata-theory path: /proj1/src/automata.rs use std::collections::HashMap; use std::collections::HashSet; use crate::parser::AST; use crate::parser::Node; use crate::parser::CharClass; use crate::multimap::*; /// The max number of states is 2^16. pub type StateId = u16; /// ...
code_fim
hard
{ "lang": "rust", "repo": "ValorCat/csis-616-automata-theory", "path": "/proj1/src/automata.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Check whether a string is accepted by this DFA pub fn accepts(&self, input: &str) -> bool { let mut state = 0; for letter in input.chars() { match self.get(state).get(&letter) { None => return false, // reject if no transition defi...
code_fim
hard
{ "lang": "rust", "repo": "ValorCat/csis-616-automata-theory", "path": "/proj1/src/automata.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fwalch/rust-analyzer path: /crates/ra_syntax/src/ast/generated/tokens.rs elf.syntax, f) } } impl AstToken for CrateKw { fn can_cast(kind: SyntaxKind) -> bool { kind == CRATE_KW } fn cast(syntax: SyntaxToken) -> Option<Self> { if Self::can_cast(syntax.kind()) { Som...
code_fim
hard
{ "lang": "rust", "repo": "fwalch/rust-analyzer", "path": "/crates/ra_syntax/src/ast/generated/tokens.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn cast(syntax: SyntaxToken) -> Option<Self> { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxToken { &self.syntax } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TryKw { pub(...
code_fim
hard
{ "lang": "rust", "repo": "fwalch/rust-analyzer", "path": "/crates/ra_syntax/src/ast/generated/tokens.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sybila/biodivine-lib-param-bn path: /src/async_graph/_impl_async_graph.rs use crate::async_graph::{AsyncGraph, AsyncGraphEdgeParams, DefaultEdgeParams}; use crate::BooleanNetwork; impl AsyncGraph<DefaultEdgeParams> { /// Create a new `AsyncGraph` from the given `BooleanNetwork` using defaul...
code_fim
hard
{ "lang": "rust", "repo": "sybila/biodivine-lib-param-bn", "path": "/src/async_graph/_impl_async_graph.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Return an empty set of parameters. pub fn empty_params(&self) -> &Params::ParamSet { self.edges.empty_params() } /// Return a full set of parameters. pub fn unit_params(&self) -> &Params::ParamSet { self.edges.unit_params() } } #[cfg(test)] mod tests { use...
code_fim
hard
{ "lang": "rust", "repo": "sybila/biodivine-lib-param-bn", "path": "/src/async_graph/_impl_async_graph.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sergiineodnichyk/rpi4-rust-workspace path: /bcm2711-hal/src/eth/address.rs use core::fmt; #[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)] pub struct EthernetAddress(pub [u8; 6]); <|fim_suffix|> self.0 } } impl fmt::Display for EthernetAddress { fn f...
code_fim
hard
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/bcm2711-hal/src/eth/address.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let bytes = self.0; write!( f, "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5] ) } }<|fim_prefix|>// repo: sergiineodnichyk/rpi4-rust-workspace path: /bcm2711-hal/src/eth/address.rs use...
code_fim
hard
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/bcm2711-hal/src/eth/address.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.0 } } impl fmt::Display for EthernetAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let bytes = self.0; write!( f, "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes...
code_fim
medium
{ "lang": "rust", "repo": "sergiineodnichyk/rpi4-rust-workspace", "path": "/bcm2711-hal/src/eth/address.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/app/src/package_preview_2022_06/mod.rs { pub fn into_stream(self) -> azure_core::Pageable<models::ContainerAppCollection, azure_core::error::Error> { let make_request = move |continuation: Option<String>| { ...
code_fim
hard
{ "lang": "rust", "repo": "Azure/azure-sdk-for-rust", "path": "/services/mgmt/app/src/package_preview_2022_06/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|> let func = QbeFunction { exported: true, return_ty: None, name: "main".into(), arguments: Vec::new(), blocks: vec![QbeBlock { label: "start".into(), instructions: vec![QbeStatement::Volatile(QbeInstr::Ret(None))], }], }; ...
code_fim
hard
{ "lang": "rust", "repo": "jgarte/antimony", "path": "/src/generator/tests/qbe_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgarte/antimony path: /src/generator/tests/qbe_tests.rs /** * Copyright 2021 Alexey Yerin * * 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 * * https://www.a...
code_fim
hard
{ "lang": "rust", "repo": "jgarte/antimony", "path": "/src/generator/tests/qbe_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Trait for any APDU transport pub trait TransportWrapperTrait { /// Send an APDU command and receive a promise of a response back fn exchange_apdu(&self, apdu_command: &[u8]) -> js_sys::Promise; } /// Transport struct for non-wasm arch pub struct APDUTransport { /// Contain javascript tran...
code_fim
medium
{ "lang": "rust", "repo": "crypto-com/ledger-rs", "path": "/ledger-transport/src/apdu_transport_wasm.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use js_sys; use wasm_bindgen::JsValue; use wasm_bindgen_futures::JsFuture; /// Trait for any APDU transport pub trait TransportWrapperTrait { /// Send an APDU command and receive a promise of a response back fn exchange_apdu(&self, apdu_command: &[u8]) -> js_sys::Promise; } /// Transport struct ...
code_fim
medium
{ "lang": "rust", "repo": "crypto-com/ledger-rs", "path": "/ledger-transport/src/apdu_transport_wasm.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crypto-com/ledger-rs path: /ledger-transport/src/apdu_transport_wasm.rs /******************************************************************************* * (c) 2020 Zondax GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance...
code_fim
hard
{ "lang": "rust", "repo": "crypto-com/ledger-rs", "path": "/ledger-transport/src/apdu_transport_wasm.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattsse/cargo-memex path: /src/jpeg/decoder/decoder.rs pared if worker.is_none() { worker = Some(PlatformWorker::new()?); } let worker = worker.as_mut().unwrap(); let row_data = RowData { inde...
code_fim
hard
{ "lang": "rust", "repo": "mattsse/cargo-memex", "path": "/src/jpeg/decoder/decoder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if scan.successive_approximation_low == 0 { for (&i, component_finished) in scan.component_indices.iter().zip(&mut finished) { if self.coefficients_finished[i] == !0 { ...
code_fim
hard
{ "lang": "rust", "repo": "mattsse/cargo-memex", "path": "/src/jpeg/decoder/decoder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> expected_rst_num = (expected_rst_num + 1) % 8; mcus_left_until_restart = self.restart_interval; } Some(marker) => { return Err(Error::Format(format!( ...
code_fim
hard
{ "lang": "rust", "repo": "mattsse/cargo-memex", "path": "/src/jpeg/decoder/decoder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(clippy::clippy::too_many_arguments)] pub fn stack<I, O, OSvc, P>( Config { allow_discovery }: Config, inbound: Inbound<()>, outbound: O, profiles: P, ) -> impl svc::NewService< GatewayConnection, Service = impl tower::Service<I, Response = (), Error = impl Into<Error>, Futu...
code_fim
hard
{ "lang": "rust", "repo": "billmcchesney1/linkerd2-proxy", "path": "/linkerd/app/gateway/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: billmcchesney1/linkerd2-proxy path: /linkerd/app/gateway/src/lib.rs #![deny(warnings, rust_2018_idioms)] mod gateway; #[cfg(test)] mod tests; use self::gateway::NewGateway; use linkerd_app_core::{ config::ProxyConfig, detect, discovery_rejected, io, metrics, profiles, proxy::http, ...
code_fim
hard
{ "lang": "rust", "repo": "billmcchesney1/linkerd2-proxy", "path": "/linkerd/app/gateway/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jasondew/advent-of-code path: /2021/rust/src/day03.rs #[must_use] pub fn part1(input: &str) -> usize { let diagnostics: Vec<Vec<char>> = input.lines().map(|line| line.chars().collect()).collect(); let gamma_string: String = most_common_bits(&diagnostics).into_iter().collect(); let ga...
code_fim
hard
{ "lang": "rust", "repo": "jasondew/advent-of-code", "path": "/2021/rust/src/day03.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> index += 1; } let c02_scrubber_rating = usize::from_str_radix( &c02_scrubber_rating_candidates[0].iter().collect::<String>(), 2, ) .unwrap(); oxygen_generator_rating * c02_scrubber_rating } fn most_common_bits(diagnostics: &Vec<Vec<char>>) -> Vec<char> { ...
code_fim
hard
{ "lang": "rust", "repo": "jasondew/advent-of-code", "path": "/2021/rust/src/day03.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (*self).matches_with(actual, matcher, cascaded) } } /// Trait to convert a expected or actual complex object into a string that can be used for a mismatch pub trait DisplayForMismatch { /// Return a string representation that can be used in a mismatch to display to the user fn for_mismatch(&sel...
code_fim
hard
{ "lang": "rust", "repo": "audunhalland/pact-reference", "path": "/rust/pact_matching/src/matchingrules.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>/// Compare the expected and actual lists using the matching rule's logic pub fn compare_lists_with_matchingrule<T: Display + Debug + PartialEq + Clone + Sized>( rule: &MatchingRule, path: &[&str], expected: &Vec<T>, actual: &Vec<T>, context: &MatchingContext, callback: &dyn Fn(&[&str], &T, &T...
code_fim
hard
{ "lang": "rust", "repo": "audunhalland/pact-reference", "path": "/rust/pact_matching/src/matchingrules.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: audunhalland/pact-reference path: /rust/pact_matching/src/matchingrules.rs //! `matchingrules` module includes all the classes to deal with V3 format matchers use std::collections::HashMap; use std::fmt::{Debug, Display}; use std::str::{self, from_utf8}; use anyhow::anyhow; use log::*; use oni...
code_fim
hard
{ "lang": "rust", "repo": "audunhalland/pact-reference", "path": "/rust/pact_matching/src/matchingrules.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns true if UART currently enabled pub fn is_active(&self) -> bool { read_reg!(usart, self.uart, CR1, RE == Enabled) } /// Return length of internal buffer pub fn buffer_len(&self) -> usize { self.buffer.len() } /// Request a target baud rate. Returns ...
code_fim
hard
{ "lang": "rust", "repo": "xieren58/hs-probe-firmware", "path": "/hs-probe-bsp/src/uart.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.last_idx = new_last_idx; n1 + n2 } Ordering::Greater => { // New data, no wraparound: // Copy from last_idx to new dma_idx. let mut n = dma_idx - self.last_idx; // Ensure we don't ...
code_fim
hard
{ "lang": "rust", "repo": "xieren58/hs-probe-firmware", "path": "/hs-probe-bsp/src/uart.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xieren58/hs-probe-firmware path: /hs-probe-bsp/src/uart.rs // Copyright 2020 Adam Greig // Dual licensed under the Apache 2.0 and MIT licenses. use core::cmp::Ordering; use stm32ral::usart; use stm32ral::{modify_reg, read_reg, write_reg}; use super::dma::DMA; pub struct UART<'a> { uart: u...
code_fim
hard
{ "lang": "rust", "repo": "xieren58/hs-probe-firmware", "path": "/hs-probe-bsp/src/uart.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elvis-epx/rexif path: /src/types.rs al errors that may happen when an image is parsed. #[derive(Debug)] pub enum ExifError { IoError(io::Error), FileTypeUnknown, JpegWithoutExif(String), TiffTruncated, TiffBadPreamble(String), IfdTruncated, ExifIfdTruncated(String), ExifIfdEntryNotFound,...
code_fim
hard
{ "lang": "rust", "repo": "elvis-epx/rexif", "path": "/src/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl TagValue { /// Get value as an integer /// Out of bounds indexes and invalid types return `None` pub fn to_i64(&self, index: usize) -> Option<i64> { match *self { TagValue::U8(ref v) => v.get(index).cloned().map(From::from), TagValue::U16(ref v) => v.get(index).cloned().map(From::from), ...
code_fim
hard
{ "lang": "rust", "repo": "elvis-epx/rexif", "path": "/src/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Structure that represents a parsed EXIF tag. #[derive(Clone, Debug)] pub struct ExifEntry { /// Namespace of the tag. If Standard (0x0000), it is an EXIF tag defined in the /// official standard. Other namespaces accomodate manufacturer-specific tags that /// may be embedded in MarkerNote blob tag....
code_fim
hard
{ "lang": "rust", "repo": "elvis-epx/rexif", "path": "/src/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl Drop for DeviceInner { fn drop(&mut self) { unsafe { self.alto.0.api.alcCloseDevice(self.dev); } } } impl OutputDevice { fn make_attrs_vec(&self, attrs: Option<ContextAttrs>) -> AltoResult<Option<Vec<sys::ALCint>>> { let mut attrs_vec = Vec::with_capacity(17); if let Some(attrs) = attrs {...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/alto", "path": "/src/alc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/alto path: /src/alc.rs RY_SENDS)` /// Requires `ALC_EXT_EFX` fn max_aux_sends(&self) -> sys::ALCint; /// Return a new handle to this device. fn to_device(&self) -> Device; } pub(crate) struct DeviceInner { pub(crate) alto: Alto, spec: Option<CString>, pub(crate) dev: *mut sys::ALC...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/alto", "path": "/src/alc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/alto path: /src/alc.rs Inner { pub(crate) alto: Alto, spec: Option<CString>, pub(crate) dev: *mut sys::ALCdevice, pub(crate) exts: ext::AlcCache, } /// A regular output device. This is typically a device as reported by the operating system. pub struct OutputDevice(pub(crate) Arc<Devi...
code_fim
hard
{ "lang": "rust", "repo": "Atul9/alto", "path": "/src/alc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T:'static> list<T> { pub fn addEnd(&mut self, element: T) { let newList = list { element: element, next: None }; self.next = Some(box RefCell::new(newList)); } } pub fn main() { let ls = list { element: S, next: None };...
code_fim
medium
{ "lang": "rust", "repo": "moshg/rust-std-ja", "path": "/src/test/run-pass/issue-3447.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: moshg/rust-std-ja path: /src/test/run-pass/issue-3447.rs // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // h...
code_fim
medium
{ "lang": "rust", "repo": "moshg/rust-std-ja", "path": "/src/test/run-pass/issue-3447.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: discovercoding/modules path: /src/colors.rs use std::fmt::Display; use std::path::Path; use std::io::prelude::*; use std::fs::File; use std::fmt; <|fim_suffix|> pub fn save<P: AsRef<Path>>(&self, file_path: P) -> Result<(), ModError> { let mut f = try!(File::create(file_path))...
code_fim
hard
{ "lang": "rust", "repo": "discovercoding/modules", "path": "/src/colors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Color { pub fn new(red: u8, green: u8, blue: u8) -> Result<Color, ModError> { let me = Color { red: red, green: green, blue: blue }; if red == green || green == blue || red == blue { Err(ModError::Ugly(me)) } else { Ok(me) } } ...
code_fim
medium
{ "lang": "rust", "repo": "discovercoding/modules", "path": "/src/colors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct Color { red: u8, green: u8, blue: u8 } impl Color { pub fn new(red: u8, green: u8, blue: u8) -> Result<Color, ModError> { let me = Color { red: red, green: green, blue: blue }; if red == green || green == blue || red == blue { ...
code_fim
medium
{ "lang": "rust", "repo": "discovercoding/modules", "path": "/src/colors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pksunkara/reign path: /src/cli/tasks.rs use clap::Parser; use reign_task::Error; use std::process::Command; <|fim_suffix|>pub fn run_task(args: Vec<String>) -> Result<(), Error> { Command::new("cargo") .args(&["run", "-p", "xtask", "--"]) .args(args) .status() ...
code_fim
medium
{ "lang": "rust", "repo": "pksunkara/reign", "path": "/src/cli/tasks.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run_task(args: Vec<String>) -> Result<(), Error> { Command::new("cargo") .args(&["run", "-p", "xtask", "--"]) .args(args) .status() .map_err(|_| Error::Cargo)?; Ok(()) }<|fim_prefix|>// repo: pksunkara/reign path: /src/cli/tasks.rs use clap::Parser; use rei...
code_fim
medium
{ "lang": "rust", "repo": "pksunkara/reign", "path": "/src/cli/tasks.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone)] pub struct Monitor; impl Monitor { pub async fn start(interval: u32, manager: Sender<Command>) -> Result<Monitor> { debug!("starting monitor"); let handle = tokio::spawn(async move { let mut interval = time::interval(Duration::from_millis(interval a...
code_fim
medium
{ "lang": "rust", "repo": "neumaics/caminatus", "path": "/src/server/monitor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neumaics/caminatus path: /src/server/monitor.rs /// Pings the manager every so often, which will remove disconnected clients use std::time::Duration; use anyhow::Result; use tokio::sync::broadcast::Sender; use tokio::{join, time}; use tracing::{debug, trace}; <|fim_suffix|>#[derive(Debug, Clon...
code_fim
medium
{ "lang": "rust", "repo": "neumaics/caminatus", "path": "/src/server/monitor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Load bunny texture let tex_bunny = rl .load_texture(thread, "original/textures/resources/wabbit_alpha.png") .expect("texture missing: are you in the right directory?"); let mut bunnies = vec![Bunny::default(); MAX_BUNNIES]; let mut bunnies_count = 0; // Bunnies counter ...
code_fim
hard
{ "lang": "rust", "repo": "deltaphc/raylib-rs", "path": "/showcase/src/example/textures/textures_bunnymark.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deltaphc/raylib-rs path: /showcase/src/example/textures/textures_bunnymark.rs /******************************************************************************************* * * raylib [textures] example - Bunnymark * * This example has been created using raylib 1.6 (www.raylib.com) * raylib ...
code_fim
hard
{ "lang": "rust", "repo": "deltaphc/raylib-rs", "path": "/showcase/src/example/textures/textures_bunnymark.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dougfort/nodes path: /src/bin/nodecli.rs use anyhow::Error; use nodes::node::{Content, Node, NodeId}; use nodes::repo::{create_accept_all_filter, HashMapRepo, NodeRepo}; fn main() -> Result<(), Error> { let mut repo = HashMapRepo::new(); <|fim_suffix|> let res = repo.traverse(create_acc...
code_fim
hard
{ "lang": "rust", "repo": "dougfort/nodes", "path": "/src/bin/nodecli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let res = repo.traverse(create_accept_all_filter())?; for r in res { println!("{:?}", r); } Ok(()) }<|fim_prefix|>// repo: dougfort/nodes path: /src/bin/nodecli.rs use anyhow::Error; use nodes::node::{Content, Node, NodeId}; use nodes::repo::{create_accept_all_filter, HashMapRep...
code_fim
hard
{ "lang": "rust", "repo": "dougfort/nodes", "path": "/src/bin/nodecli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zydiig/secrets path: /src/sodium/signing.rs use super::_sodium; use failure::{err_msg, Error}; pub const PUBLIC_KEY_BYTES: usize = _sodium::crypto_sign_PUBLICKEYBYTES as usize; pub const SECRET_KEY_BYTES: usize = _sodium::crypto_sign_SECRETKEYBYTES as usize; pub const SIG_BYTES: usize = _sodium...
code_fim
hard
{ "lang": "rust", "repo": "zydiig/secrets", "path": "/src/sodium/signing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn verify_detached(data: &[u8], signature: &[u8], public_key: &[u8]) -> Result<bool, Error> { if public_key.len() != PUBLIC_KEY_BYTES { return Err(err_msg("Incorrect public key length")); } if signature.len() != SIG_BYTES { return Err(err_msg("Incorrect signature length"));...
code_fim
hard
{ "lang": "rust", "repo": "zydiig/secrets", "path": "/src/sodium/signing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: v4run/rust_crash_course path: /src/functions.rs pub fn run() { println!("functions.rs"); println!("{}", big(10, 2)); print_big(12, 3); <|fim_suffix|> println!("\nBlock value demo."); let a = if 10 > 2 { println!("10"); 10 } else { println!("2"); ...
code_fim
hard
{ "lang": "rust", "repo": "v4run/rust_crash_course", "path": "/src/functions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if a > b { a // skip ; to return the value } else { b } } fn block_value() { println!("\nBlock value demo."); let a = if 10 > 2 { println!("10"); 10 } else { println!("2"); 2 }; let value = { let mut i = 0; lo...
code_fim
hard
{ "lang": "rust", "repo": "v4run/rust_crash_course", "path": "/src/functions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("\nBlock value demo."); let a = if 10 > 2 { println!("10"); 10 } else { println!("2"); 2 }; let value = { let mut i = 0; loop { i += 1; if i == 20 { break; } } i...
code_fim
hard
{ "lang": "rust", "repo": "v4run/rust_crash_course", "path": "/src/functions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self::Sum(elems) } } impl Add for Box<DataType> { type Output = DataType; fn add(self, rhs: Self) -> Self::Output { let mut elems = Vec::new(); if let DataType::Sum(elems1) = *self { elems.append(&mut elems1.clone()) } else { elems.pus...
code_fim
hard
{ "lang": "rust", "repo": "ZippeyKeys12/seta", "path": "/src/ast/datatypes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZippeyKeys12/seta path: /src/ast/datatypes.rs Self::Complement(a)) | (Self::Complement(a), Self::Int(x)) => { if let Self::Int(_) = *a { res & typ } else { ...
code_fim
hard
{ "lang": "rust", "repo": "ZippeyKeys12/seta", "path": "/src/ast/datatypes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZippeyKeys12/seta path: /src/ast/datatypes.rs f::Variant(typs) => Self::Variant( typs.into_iter() .map(|(n, t)| (n.clone(), t.evaluate())) .collect(), ), // Set Self::Complement(a) => { l...
code_fim
hard
{ "lang": "rust", "repo": "ZippeyKeys12/seta", "path": "/src/ast/datatypes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: persianace/rust_winapi_examples path: /src/bin/02_window.rs #![cfg(windows)] // Let's put this so that it won't open the console #![windows_subsystem = "windows"] /// Example 2: Simple window that responds to a click event /// /// Clicking on the window shows a message dialog /// Example build ...
code_fim
hard
{ "lang": "rust", "repo": "persianace/rust_winapi_examples", "path": "/src/bin/02_window.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(handle) } } // Message handling loop fn run_message_loop(hwnd: HWND) -> WPARAM { unsafe { let mut msg: MSG = std::mem::uninitialized(); loop { // Get message from message queue if GetMessageW(&mut msg, hwnd, 0, 0) > 0 { TranslateM...
code_fim
hard
{ "lang": "rust", "repo": "persianace/rust_winapi_examples", "path": "/src/bin/02_window.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }