text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>rial::*; pub use ray::Ray; pub use vec3::Vec3;<|fim_prefix|>// repo: joce/ToyRayTrace path: /rust/src/raytrace/mod.rs pub mod camera; pub mod hitable; pub mod mate<|fim_middle|>rial; pub mod ray; pub mod vec3; pub use camera::Camera; pub use hitable::*; pub use mate
code_fim
medium
{ "lang": "rust", "repo": "joce/ToyRayTrace", "path": "/rust/src/raytrace/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joce/ToyRayTrace path: /rust/src/raytrace/mod.rs pub mod camera; pub mod hitable; pub mod mate<|fim_suffix|>rial::*; pub use ray::Ray; pub use vec3::Vec3;<|fim_middle|>rial; pub mod ray; pub mod vec3; pub use camera::Camera; pub use hitable::*; pub use mate
code_fim
medium
{ "lang": "rust", "repo": "joce/ToyRayTrace", "path": "/rust/src/raytrace/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThePerkinrex/PercOSv2 path: /src/shell/mod.rs use keyboard::*; use core::fmt::Debug; use core::str; mod pshell; pub use self::pshell::PShell; pub const MAX_CMD_LEN: u8 = 100 as u8; const EMPTY_CMD: [u8; MAX_CMD_LEN as usize] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, ...
code_fim
hard
{ "lang": "rust", "repo": "ThePerkinrex/PercOSv2", "path": "/src/shell/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.shell.print_shell_start(result); } } pub trait Shell { const EXIT_OS: usize = 0; const OK: usize = 1; fn exec_command(&mut self, command: &str) -> usize; fn print_shell_start(&mut self, last_command_out: usize) { if last_command_out != Self::OK { print...
code_fim
hard
{ "lang": "rust", "repo": "ThePerkinrex/PercOSv2", "path": "/src/shell/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn update(&mut self, key_in: KeyHandlerOut) -> u8 { let mut ret_flags: u8 = 0; if key_in.clone().get_flag(KEY_ENTER){ println!(""); let command_result = self.shell.exec_command(&str::from_utf8(&self.current_command[0..(self.current_cmd_len as usize)]).expect...
code_fim
hard
{ "lang": "rust", "repo": "ThePerkinrex/PercOSv2", "path": "/src/shell/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-client-api/src/discovery/get_capabilities/iter.rs //! Iterator implementation for `Capabilities` use std::{borrow::Cow, collections::btree_map}; use serde_json::Value as JsonValue; use super::Capabilities; /// Reference to a capability. #[derive(Debug)] pub struc...
code_fim
hard
{ "lang": "rust", "repo": "ruma/ruma", "path": "/crates/ruma-client-api/src/discovery/get_capabilities/iter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { match self.pos { 0 => { self.pos += 1; Some(CapabilityRef { name: "m.change_password", value: None, caps: self.caps }) } 1 => { self.pos += 1; Some(Cap...
code_fim
hard
{ "lang": "rust", "repo": "ruma/ruma", "path": "/crates/ruma-client-api/src/discovery/get_capabilities/iter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ns = NormalStruct { a: 1, b: 2 }; let ts = TupleStruct(1, 2); // shortcut to initialize the fields of a struct using the values of the // fields of another struct let ns2 = NormalStruct { a: 5, ..ns }; let ts2 = TupleStruct { 0: 1, ..ts }; // for TupleStruct it needs curly bra...
code_fim
medium
{ "lang": "rust", "repo": "Alfex4936/Rust-Studies", "path": "/src/syntax/tuple_struct.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alfex4936/Rust-Studies path: /src/syntax/tuple_struct.rs struct TupleStruct(i32, i32); struct NormalStruct { a: i32, b: i32, } <|fim_suffix|> println!("Accessing Normal Struct by name - {}, {}", ns.a, ns.b); println!("accessing Tuple Struct by name - {}, {}", ts.0, ts.1); }<|fim_...
code_fim
hard
{ "lang": "rust", "repo": "Alfex4936/Rust-Studies", "path": "/src/syntax/tuple_struct.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn sawtooth(f: f32, t: f32) -> f32 { 2.0 * f * (t % (1.0 / f )) - 1.0 } fn w(f: f32) -> f32 { return f * 2.0 * PI; }<|fim_prefix|>// repo: wrbs/software-synth path: /src/synth/osc.rs use std::f32::consts::PI; pub fn lfo(f: f32, t: f32, val: f32) -> f32 { f + val / 2.0 / PI / t } pub f...
code_fim
hard
{ "lang": "rust", "repo": "wrbs/software-synth", "path": "/src/synth/osc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wrbs/software-synth path: /src/synth/osc.rs use std::f32::consts::PI; pub fn lfo(f: f32, t: f32, val: f32) -> f32 { f + val / 2.0 / PI / t } pub fn sin(f: f32, t: f32) -> f32 { (w(f) * t).sin() } <|fim_suffix|>pub fn triangle(f: f32, t: f32) -> f32 { (w(f) * t).sin().asin() * 2.0 ...
code_fim
medium
{ "lang": "rust", "repo": "wrbs/software-synth", "path": "/src/synth/osc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.clear() } fn len(&self) -> usize { self.len() } fn is_empty(&self) -> bool { self.is_empty() } fn split_off(&mut self, at: usize) -> Vec<T> { self.split_off(at) } } #[cfg(test)] mod tests { use super::*; struct U64Vec(Vec<u64>); ...
code_fim
hard
{ "lang": "rust", "repo": "dureuill/delegable-derive", "path": "/examples/vec_facade/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where F: FnMut(&mut T, &mut T) -> bool, { self.dedup_by(same_bucket) } fn push(&mut self, value: T) { self.push(value) } fn pop(&mut self) -> Option<T> { self.pop() } fn append(&mut self, other: &mut Vec<T>) { self.append(other) }...
code_fim
hard
{ "lang": "rust", "repo": "dureuill/delegable-derive", "path": "/examples/vec_facade/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dureuill/delegable-derive path: /examples/vec_facade/src/lib.rs #![feature(proc_macro)] extern crate delegable_derive; use delegable_derive::delegable; #[delegable] pub trait VecFacade<T> { fn capacity(&self) -> usize; fn reserve(&mut self, additional: usize); fn reserve_exact(&mu...
code_fim
hard
{ "lang": "rust", "repo": "dureuill/delegable-derive", "path": "/examples/vec_facade/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { let start = PreciseTime::now(); let s = solution1(input, 1); let end = PreciseTime::now(); println!("solution: {} ({:?})", s, start.to(end)); } { let start = PreciseTime::now(); let s = solution2(input, 1); let end = PreciseTime::now(); println!("solution: {}...
code_fim
hard
{ "lang": "rust", "repo": "hluk/advent-of-code-2017-rust", "path": "/advent01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hluk/advent-of-code-2017-rust path: /advent01/src/main.rs extern crate time; use time::PreciseTime; // Dumb iteration fn solution1(input: &str, step: usize) -> u64 { let chars = input.as_bytes(); let mut sum = 0u64; let len = chars.len(); for i in 0..len { let c1 = chars...
code_fim
hard
{ "lang": "rust", "repo": "hluk/advent-of-code-2017-rust", "path": "/advent01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Proposal assertions enumeration pub enum ProposalAssertions { /// Reached depth limit of nested proposals DepthLimit, /// Proposal has self-references SelfReference } /// Perform some assertions on proposal object pub fn assert_proposal<T: Config, BatchItem: BatchItemKindT<T>>( ba...
code_fim
medium
{ "lang": "rust", "repo": "AlexShkor/deip-polkadot", "path": "/pallets/deip_proposal/src/batch_assertions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexShkor/deip-polkadot path: /pallets/deip_proposal/src/batch_assertions.rs /// Module contains some assertions on proposal's batch use crate::proposal::{ProposalBatchX, ProposalId}; use crate::batch_item_kind::{BatchItemKindT, BatchItemKind}; use crate::batch_tree::{traverse_batch_tree, Batch...
code_fim
hard
{ "lang": "rust", "repo": "AlexShkor/deip-polkadot", "path": "/pallets/deip_proposal/src/batch_assertions.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Perform some assertions on proposal object pub fn assert_proposal<T: Config, BatchItem: BatchItemKindT<T>>( batch: &ProposalBatchX<BatchItem>, proposal_id: &ProposalId, depth_limit: usize, ) -> Option<ProposalAssertions> { let mut res = None; traverse_batch_tree::<T, _, _>(&bat...
code_fim
hard
{ "lang": "rust", "repo": "AlexShkor/deip-polkadot", "path": "/pallets/deip_proposal/src/batch_assertions.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn session_state_responding_encrypt() { let (public_key, secret_key) = SecretKey::generate_pair(); let mut session = Session::new_responder( SessionId::generate(), SessionKey::generate(), public_key, secret_key, ) ...
code_fim
hard
{ "lang": "rust", "repo": "yuchennil/wrench", "path": "/src/session.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuchennil/wrench path: /src/session.rs mod chain_ratchet; mod normal_state; mod prep_state; mod public_ratchet; mod skipped_keys; use std::mem; use crate::crypto::{Handshake, Message, Plaintext, PublicKey, SecretKey, SessionId, SessionKey}; use crate::error::Error::{self, *}; use crate::sessio...
code_fim
hard
{ "lang": "rust", "repo": "yuchennil/wrench", "path": "/src/session.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vanderlokken/rust-vst-gui path: /src/win32/com_pointer.rs use std::ptr::null_mut; use winapi::Interface; use winapi::shared::winerror::S_OK; use winapi::shared::minwindef::LPVOID; use winapi::um::unknwnbase::IUnknown; pub struct ComPointer<T: Interface> { pointer: *mut T, } <|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "vanderlokken/rust-vst-gui", "path": "/src/win32/com_pointer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Interface> Drop for ComPointer<T> { fn drop(&mut self) { if self.pointer != null_mut() { unsafe { (*(self.pointer as *mut IUnknown)).Release(); } } } }<|fim_prefix|>// repo: vanderlokken/rust-vst-gui path: /src/win32/com_pointer.rs u...
code_fim
hard
{ "lang": "rust", "repo": "vanderlokken/rust-vst-gui", "path": "/src/win32/com_pointer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let req_builder = CibouletteRequestBuilder::new(INTENTION, &parsed_url, &None); let request = req_builder.build(&ciboulette_store).unwrap(); let ciboulette_request = CibouletteDeleteRequest::try_from(request).unwrap(); let err = Ciboulette2PgBuilder::gen_delete(&ciboulette_store, &...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette2pg", "path": "/src/builder/tests/delete/delete_rel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: basiliqio/ciboulette2pg path: /src/builder/tests/delete/delete_rel.rs use super::*; #[test] fn simple_single_rel() { let ciboulette_store = gen_bag(); let table_store = gen_table_store(&ciboulette_store); let parsed_url = Url::parse("http://localhost/peoples/6720877a-e27e-4e...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette2pg", "path": "/src/builder/tests/delete/delete_rel.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Set data selectors mov eax, {user_data_seg_selector} mov ds, eax mov es, eax mov eax, {user_fs_seg_selector} mov fs, eax mov eax, {user_gs_seg_selector} mov gs, eax // Set up iret stack ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/kernel", "path": "/src/arch/x86/start.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/kernel path: /src/arch/x86/start.rs /// This function is where the kernel sets up IRQ handlers /// It is increcibly unsafe, and should be minimal in nature /// It must create the IDT with the correct entries, those entries are /// defined in other files inside of the `arch` module use ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/kernel", "path": "/src/arch/x86/start.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunshine-protocol/kusama-bounty-chain path: /node/src/chain_spec.rs use hex_literal::hex; use sc_service::{ config::MultiaddrWithPeerId, ChainType, }; // use sc_telemetry::TelemetryEndpoints; use kb_runtime::{ AccountId, AuraConfig, BalancesConfig, GenesisConfig, Gran...
code_fim
hard
{ "lang": "rust", "repo": "sunshine-protocol/kusama-bounty-chain", "path": "/node/src/chain_spec.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> initial_authorities: &[(AccountId, AccountId, AuraId, GrandpaId)], endowed_accounts: &[AccountId], ) -> GenesisConfig { GenesisConfig { frame_system: Some(SystemConfig { code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), }), pal...
code_fim
hard
{ "lang": "rust", "repo": "sunshine-protocol/kusama-bounty-chain", "path": "/node/src/chain_spec.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(even_store.borrow().clone(), vec![0, 2, 4, 6, 8]); assert_eq!(odd_store.borrow().clone(), vec![1, 3, 5, 7, 9]); assert_eq!(numbers_store.borrow().clone(), (0..10).collect::<Vec<_>>()); } #[test] fn merge_unsubscribe_work() { let numbers = Subject::new(); // enabling m...
code_fim
hard
{ "lang": "rust", "repo": "tashoecraft/rx_rs", "path": "/src/ops/merge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tashoecraft/rx_rs path: /src/ops/merge.rs use crate::{ErrComplete, Observable, Subscription}; use std::cell::RefCell; use std::rc::Rc; /// combine two Observables into one by merging their emissions /// /// # Example /// /// ``` /// # use rx_rs::{ /// ops::{Filter, Merge}, Observable, Observe...
code_fim
hard
{ "lang": "rust", "repo": "tashoecraft/rx_rs", "path": "/src/ops/merge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qzhang1229/gurobi_demo path: /src/main.rs extern crate gurobi; use gurobi::*; fn main() { let env = Env::new("logfile.log").unwrap(); // create an empty model which associated with `env`: let mut model = env.new_model("model1").unwrap(); // add decision variables. let x1 = model.add...
code_fim
medium
{ "lang": "rust", "repo": "qzhang1229/gurobi_demo", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // set the expression of objective function. model.set_objective(8.0 * &x1 + &x2, Minimize).unwrap(); assert_eq!(model.get(attr::IsMIP).unwrap(), 1, "Model is not a MIP."); // write constructed model to the file. model.write("logfile.lp").unwrap(); // optimize the model. model.optimize()....
code_fim
medium
{ "lang": "rust", "repo": "qzhang1229/gurobi_demo", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init(client: RedisClient, handle: &Handle, config: Rc<RefCell<RedisConfig>>, state: Arc<RwLock<ClientState>>, error_tx: Rc<RefCell<VecDeque<UnboundedSender<RedisError>>>>, message_tx: Rc<RefCell<VecDeque<UnboundedSender<(String, RedisValue...
code_fim
hard
{ "lang": "rust", "repo": "bsherman/fred.rs", "path": "/src/mocks/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bsherman/fred.rs path: /src/mocks/mod.rs #![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] mod types; mod commands; mod utils; use std::sync::Arc; use ::types::*; use ::protocol::types::*; use ::RedisClient; use error::{ RedisError, RedisErrorKind }; use ::prot...
code_fim
hard
{ "lang": "rust", "repo": "bsherman/fred.rs", "path": "/src/mocks/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> multiplexer_utils::set_command_tx(&command_tx, tx); multiplexer_utils::emit_connect(&connect_tx, remote_tx, &client); let _ = multiplexer_utils::emit_reconnect(&reconnect_tx, &client); utils::create_command_ft(rx, expiration_tx) } pub fn init(client: RedisClient, handle: &Handle, ...
code_fim
hard
{ "lang": "rust", "repo": "bsherman/fred.rs", "path": "/src/mocks/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noirotm/advent-of-code-2018 path: /src/solutions/day08.rs use crate::solver::Solver; use std::io::{self, BufRead, BufReader}; pub struct Problem; impl Solver for Problem { type Input = Vec<u32>; type Output1 = u32; type Output2 = u32; fn parse_input<R: io::Read>(&self, r: R) -...
code_fim
hard
{ "lang": "rust", "repo": "noirotm/advent-of-code-2018", "path": "/src/solutions/day08.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>struct Node { children: Vec<Node>, metadata: Vec<u32>, meta_sum: u32, value: u32, } fn parse_nodes<'a>(it: &mut impl Iterator<Item = &'a u32>) -> Option<Node> { let num_nodes = it.next()?; let num_meta = it.next()?; let mut node = Node { children: vec![], meta...
code_fim
hard
{ "lang": "rust", "repo": "noirotm/advent-of-code-2018", "path": "/src/solutions/day08.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn solve_second(&self, input: &Vec<u32>) -> u32 { let mut it = input.iter(); let tree = parse_nodes(&mut it); tree.unwrap().value } } struct Node { children: Vec<Node>, metadata: Vec<u32>, meta_sum: u32, value: u32, } fn parse_nodes<'a>(it: &mut impl Iter...
code_fim
hard
{ "lang": "rust", "repo": "noirotm/advent-of-code-2018", "path": "/src/solutions/day08.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: funnyzpc/cargo_test path: /src/history/main19.rs /// /// 生命周期 /// fn main() { // process01(); // process02(); } // 测试01 fn process01(){ <|fim_suffix|> let r; { let i = 1; r = &i; // i的作用域只在代码块内 故赋值后r没有足够的存活时间 println!("i:{}",i); } println!...
code_fim
medium
{ "lang": "rust", "repo": "funnyzpc/cargo_test", "path": "/src/history/main19.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// 测试02 fn process02(){ let r; { let i = 1; r = &i; // i的作用域只在代码块内 故赋值后r没有足够的存活时间 println!("i:{}",i); } println!("r:{}",r); }<|fim_prefix|>// repo: funnyzpc/cargo_test path: /src/history/main19.rs /// /// 生命周期 /// fn main() { // process01(); // pro...
code_fim
medium
{ "lang": "rust", "repo": "funnyzpc/cargo_test", "path": "/src/history/main19.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> test!( forin_statement_const, r#"for(const a in b);"#, { match decl { node::Statement::ForInStatement(decl) => { match *decl.body { node::Statement::EmptyStatement(_) => {} _ => pani...
code_fim
hard
{ "lang": "rust", "repo": "hrvolapeter/javascript-es9-parser", "path": "/components/parser/src/statement_declaration.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hrvolapeter/javascript-es9-parser path: /components/parser/src/statement_declaration.rs ement::ForOfStatement(node::ForOfStatement { left: node::ForInStatementLeft::Pattern(left.1.into()), right: right.1, body: box body.1, await_: false, })...
code_fim
hard
{ "lang": "rust", "repo": "hrvolapeter/javascript-es9-parser", "path": "/components/parser/src/statement_declaration.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hrvolapeter/javascript-es9-parser path: /components/parser/src/statement_declaration.rs AsyncGeneratorMethod |*/ MethodDefinition5 | MethodDefinition6 )); fn MethodDefinition1( tokens: Input<InputWrapper>, ) -> IResult<Input<InputWrapper>, node::MethodDefinition> { let name = ...
code_fim
hard
{ "lang": "rust", "repo": "hrvolapeter/javascript-es9-parser", "path": "/components/parser/src/statement_declaration.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn generate_name() -> String { let mut name = generate_chars(); name.push_str(generate_number().as_str()); name } impl Robot { pub fn new() -> Robot { Robot { name: generate_name() } } pub fn name<'a>(&'a self) -> &'a str { self.name.as_str() } pub f...
code_fim
medium
{ "lang": "rust", "repo": "sayden/exercism-rust", "path": "/robot-name/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sayden/exercism-rust path: /robot-name/src/lib.rs extern crate rand; pub struct Robot { name: String, } use rand::{thread_rng, Rng}; pub fn generate_number() -> String { thread_rng().gen_range::<u32>(100, 999).to_string() } pub fn generate_chars() -> String { let choices = vec!['...
code_fim
medium
{ "lang": "rust", "repo": "sayden/exercism-rust", "path": "/robot-name/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn name<'a>(&'a self) -> &'a str { self.name.as_str() } pub fn reset_name(&mut self) { self.name = generate_name() } }<|fim_prefix|>// repo: sayden/exercism-rust path: /robot-name/src/lib.rs extern crate rand; pub struct Robot { name: String, } use rand::{thread...
code_fim
medium
{ "lang": "rust", "repo": "sayden/exercism-rust", "path": "/robot-name/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/libstd/sys/unix/backtrace/printing/mod.rs mod dladdr; use crate::sys::backtrace::BacktraceContext; use crate::sys_common::backtrace::Frame; use crate::io; <|fim_suffix|>#[cfg(target_os = "emscripten")] pub fn foreach_symbol_fileline<F>(_: Frame, _: F,...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/libstd/sys/unix/backtrace/printing/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(target_os = "emscripten")] pub fn foreach_symbol_fileline<F>(_: Frame, _: F, _: &BacktraceContext) -> io::Result<bool> where F: FnMut(&[u8], u32) -> io::Result<()> { Ok(false) } #[cfg(not(target_os = "emscripten"))] pub use crate::sys_common::gnu::libbacktrace::foreach_symbol_fileline; #[c...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/libstd/sys/unix/backtrace/printing/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_format_go() { let example = r###" // WithContext创建基于ctx的db // 第2行注释 func (d *Dao) WithContext(ctx context.Context) (db *gorm.DB) { a := "第1个" b := ` 多行string 第2行 ` re := regexp.MustCompile(`regexp不处理`) re1 := regexp.Compile("regexp不处理") t := time.Parse("2006年01月02日 15:04", ...
code_fim
hard
{ "lang": "rust", "repo": "SuMingXuan/autocorrect", "path": "/src/lib/src/go.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SuMingXuan/autocorrect path: /src/lib/src/go.rs // autocorrect: false use super::*; use pest::Parser as P; use pest_derive::Parser; #[derive(Parser)] #[grammar = "../grammar/go.pest"] struct GoParser; <|fim_suffix|> let expect = r###" // WithContext 创建基于 ctx 的 db // 第 2 行注释 func (d *Dao) Wi...
code_fim
hard
{ "lang": "rust", "repo": "SuMingXuan/autocorrect", "path": "/src/lib/src/go.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maekawatoshiki/naglfar path: /src/dom.rs use std::collections::{HashMap, HashSet}; use std::path::{Path, PathBuf}; use std::{fmt, iter}; use css; pub type AttrMap = HashMap<String, String>; #[derive(Debug, Clone, PartialEq)] pub struct Node { // data specific to each node type: pub dat...
code_fim
hard
{ "lang": "rust", "repo": "maekawatoshiki/naglfar", "path": "/src/dom.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Functions for displaying fn walk(node: &Node, indent: usize, f: &mut fmt::Formatter) -> fmt::Result { try!(write!( f, "{}", iter::repeat(" ").take(indent).collect::<String>() )); try!(write!(f, "{}\n", node.data)); for child in &node.children { try!(walk...
code_fim
hard
{ "lang": "rust", "repo": "maekawatoshiki/naglfar", "path": "/src/dom.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>html) //! - Uint64 - [`u64`](https://doc.rust-lang.org/std/primitive.u64.html) //! - Double - [`f64`](https://doc.rust-lang.org/std/primitive.f64.html) //! - String - `Box<str>`, //! - Buffer - `Box<[u8]>`, //! - Slice - `ByteArray` pub use genet_abi::variant::{Value, Variant};<|fim_prefix|>// repo: tan-...
code_fim
medium
{ "lang": "rust", "repo": "tan-wei/genet", "path": "/genet-sdk/src/variant.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tan-wei/genet path: /genet-sdk/src/variant.rs //! Dynamic-typed values. //! //! Type Variant represents a dynamic-typed value. //! Variant can contain one of these types: //! //! - Nil <|fim_suffix|>ve.f64.html) //! - String - `Box<str>`, //! - Buffer - `Box<[u8]>`, //! - Slice - `ByteArray` pu...
code_fim
hard
{ "lang": "rust", "repo": "tan-wei/genet", "path": "/genet-sdk/src/variant.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leven-the-blog/tenjin path: /src/context/toml.rs use context::Context; use error::{Error, Result}; use path::Path; use render::Chomp; use toml::Value; use std::io::Write; impl<W: Write> Context<W> for Value { fn truthy(&self, path: Path) -> bool { use self::Value::*; let mu...
code_fim
hard
{ "lang": "rust", "repo": "leven-the-blog/tenjin", "path": "/src/context/toml.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn inject(&self, path: Path, sink: &mut W) -> Result<()> { use self::Value::*; let mut value = self; for part in path.parts() { if let Some(next_value) = value.get(part) { value = next_value; } else { return Err(Error::U...
code_fim
hard
{ "lang": "rust", "repo": "leven-the-blog/tenjin", "path": "/src/context/toml.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>low(unused_imports)] pub(crate) use ruff_formatter::prelude::*;<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff_python_formatter/src/prelude.rs #[allow(unused_imports)] pub(crate) use crate::{ builders:<|fim_middle|>:PyFormatterExtensions, AsFormat, FormatNodeRule, FormattedIterExt as _, Into...
code_fim
medium
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff_python_formatter/src/prelude.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff_python_formatter/src/prelude.rs #[allow(unused_imports)] pub(crate) use crate::{ builders:<|fim_suffix|>low(unused_imports)] pub(crate) use ruff_formatter::prelude::*;<|fim_middle|>:PyFormatterExtensions, AsFormat, FormatNodeRule, FormattedIterExt as _, Into...
code_fim
medium
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff_python_formatter/src/prelude.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhboner/realm path: /src/cmd/mod.rs use clap::{Command, ArgMatches}; use realm_core::realm_io; use realm_core::realm_syscall; use crate::conf::CmdOverride; use crate::conf::EndpointConf; use crate::conf::{Config, LogConf, DnsConf, NetConf}; use crate::VERSION; use crate::consts::FEATURES; mo...
code_fim
hard
{ "lang": "rust", "repo": "zhboner/realm", "path": "/src/cmd/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(target_os = "linux")] { use realm_io::set_pipe_size; if let Some(page) = matches.value_of("pipe_page") { if let Ok(page) = page.parse::<usize>() { set_pipe_size(page * 0x1000); println!("pipe capacity: {}", page * 0x1000); ...
code_fim
hard
{ "lang": "rust", "repo": "zhboner/realm", "path": "/src/cmd/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> session .query( "CREATE TABLE IF NOT EXISTS ks.t (pk bigint primary key)", &[], ) .await?; let prepared = session.prepare("INSERT INTO ks.t (pk) VALUES (?)").await?; for pk in (0..100_i64).chain(99840..99936_i64) { session ....
code_fim
hard
{ "lang": "rust", "repo": "tomzhang/scylla-rust-driver", "path": "/examples/compare-tokens.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let t = murmur3_token(prepared.compute_partition_key(&scylla::values!(pk))).value; let qt = session .query(format!("SELECT token(pk) FROM ks.t where pk = {}", pk), &[]) .await? .unwrap() .iter() .next() .expect("token...
code_fim
hard
{ "lang": "rust", "repo": "tomzhang/scylla-rust-driver", "path": "/examples/compare-tokens.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomzhang/scylla-rust-driver path: /examples/compare-tokens.rs use anyhow::Result; use scylla::routing::murmur3_token; use scylla::transport::session::Session; use std::env; #[tokio::main] async fn main() -> Result<()> { let uri = env::var("SCYLLA_URI").unwrap_or("127.0.0.1:9042".to_string()...
code_fim
hard
{ "lang": "rust", "repo": "tomzhang/scylla-rust-driver", "path": "/examples/compare-tokens.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StoriqaTeam/delivery path: /src/services/companies.rs //! Companies Service, presents CRUD operations use diesel::connection::AnsiTransactionManager; use diesel::pg::Pg; use diesel::Connection; use r2d2::ManageConnection; use failure::Error as FailureError; use stq_types::{Alpha3, CompanyId}; ...
code_fim
hard
{ "lang": "rust", "repo": "StoriqaTeam/delivery", "path": "/src/services/companies.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Find specific company by ID fn find_company(&self, company_id: CompanyId) -> ServiceFuture<Option<Company>> { let repo_factory = self.static_context.repo_factory.clone(); let user_id = self.dynamic_context.user_id; self.spawn_on_pool(move |conn| { let compa...
code_fim
hard
{ "lang": "rust", "repo": "StoriqaTeam/delivery", "path": "/src/services/companies.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn freq_counter(text_rcv: Receiver<String>, freq_snd: Sender<HashMap<char, usize>>) { let mut freq = HashMap::new(); for text in text_rcv.iter() { for c in text .to_lowercase() .chars() .filter(|c| !c.is_ascii_punctuation() && !c.is_digit(10)) ...
code_fim
hard
{ "lang": "rust", "repo": "jakm/exercism-rust", "path": "/parallel-letter-frequency/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakm/exercism-rust path: /parallel-letter-frequency/src/lib.rs use std::collections::HashMap; use crossbeam::channel::{bounded, Receiver, Sender}; use crossbeam::thread; pub fn frequency(input: &[&str], worker_count: usize) -> HashMap<char, usize> { let (total_snd, total_rcv) = bounded(1);...
code_fim
hard
{ "lang": "rust", "repo": "jakm/exercism-rust", "path": "/parallel-letter-frequency/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // collector { let freq_rcv = freq_rcv.clone(); let total_snd = total_snd.clone(); s.spawn(move |_| { let mut freq: HashMap<char, usize> = HashMap::new(); for res in freq_rcv.iter() { for (k, v) in res....
code_fim
hard
{ "lang": "rust", "repo": "jakm/exercism-rust", "path": "/parallel-letter-frequency/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: asterycs/aoc2019 path: /src/bin/12_2.rs use std::env; use std::fs; use std::path::PathBuf; use regex::Regex; use std::str::FromStr; use std::num::ParseIntError; #[derive(Debug, Clone, Copy)] struct Moon { pos: [isize; 3], vel: [isize; 3], } impl FromStr for Moon { type Err = ParseI...
code_fim
hard
{ "lang": "rust", "repo": "asterycs/aoc2019", "path": "/src/bin/12_2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for axis in 0..3 { let mut t = 1; loop { for i in 0..moons.len() { for j in i..moons.len() { moons[i].vel[axis] += get_acc(moons[i].pos[axis], moons[j].pos[axis]); moons[j].vel[axis] -= get_acc(moons[i].pos[axis], moon...
code_fim
hard
{ "lang": "rust", "repo": "asterycs/aoc2019", "path": "/src/bin/12_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let compiler = Compiler::new(); let tree = compiler.compile(&String::from("(:top = :next = 100).right.right")); let mut execution_context = SELExecutionContext::new(); let result = get_node_result(&tree, tree.get_root(), &mut execution_context); let value: i64 = fr...
code_fim
hard
{ "lang": "rust", "repo": "chadrc/simple-expression-language", "path": "/sel_executor/src/opexec/access.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chadrc/simple-expression-language path: /sel_executor/src/opexec/access.rs use super::SELExecutionContext; use crate::opexec::execution_result::SELExecutionResult; use crate::opexec::get_node_result; use sel_common::sel_types::associative_list::AssociativeList; use sel_common::sel_types::list::L...
code_fim
hard
{ "lang": "rust", "repo": "chadrc/simple-expression-language", "path": "/sel_executor/src/opexec/access.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(result.get_type(), DataType::Unit); } #[test] fn executes_list_pair_access() { let compiler = Compiler::new(); let tree = compiler.compile(&String::from( "(:name = (:first = \"Panda\", :last = \"Bear\")).right.1.right", )); let mu...
code_fim
hard
{ "lang": "rust", "repo": "chadrc/simple-expression-language", "path": "/sel_executor/src/opexec/access.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>RCD3, // InspIRCd 3.0 "702" => RPL_MODLIST__RATBOX, // RatBox "702" => RPL_COMMANDS__INSPIRCD2, // InspIRCd 2.0 "703" => RPL_ENDOFMODLIST__RATBOX, // RatBox "703" => RPL_COMMANDSEND__INSPIRCD2, // InspIRCd 2.0 "704" => RPL_HELPSTART__RATBOX, // RatBox "705" => RPL_HELPTXT__RATBOX, ...
code_fim
hard
{ "lang": "rust", "repo": "SplittyDev/zircond", "path": "/src/protocol/numerics.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SplittyDev/zircond path: /src/protocol/numerics.rs 07" => RPL_WHOISREGNICK__BAHAMUT_UNREAL, // Bahamut, Unreal "307" => RPL_SUSERHOST__AUSTHEX, // AustHex "308" => RPL_NOTIFYACTION__AIRCD, // aircd "308" => RPL_WHOISADMIN__BAHAMUT, // Bahamut "308" => RPL_RULESSTART__UNREAL, // U...
code_fim
hard
{ "lang": "rust", "repo": "SplittyDev/zircond", "path": "/src/protocol/numerics.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SplittyDev/zircond path: /src/protocol/numerics.rs amut "339" => RPL_BADCHANPASS__, // "339" => RPL_WHOISMARKS__NEFARIOUS, // Nefarious "340" => RPL_USERIP__IRCU, // ircu "341" => RPL_INVITING, // RFC1459 "342" => RPL_SUMMONING, // RFC1459 "343" => RPL_WHOISKILL__NEFARIOU...
code_fim
hard
{ "lang": "rust", "repo": "SplittyDev/zircond", "path": "/src/protocol/numerics.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> // Some functions are whitelisted until we figure out how to fix them. // We walk up the stack a few frames to also cover their callees. const WHITELIST: &[&str] = &[ // Uses mem::uninitialized "std::ptr::read", "std::sys::windows::mutex::Mutex::...
code_fim
hard
{ "lang": "rust", "repo": "apoelstra/miri", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // No more arguments assert!(args.next().is_none(), "exchange_malloc lang item has more arguments than expected"); Ok(()) } fn find_foreign_static( tcx: TyCtxtAt<'a, 'tcx, 'tcx>, def_id: DefId, ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { let ...
code_fim
hard
{ "lang": "rust", "repo": "apoelstra/miri", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apoelstra/miri path: /src/lib.rs #![feature(rustc_private)] #![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] #[macro_use] extern crate log; // From rustc. #[macro_use] extern crate rustc; extern crate rustc_data_structures; extern crate rustc_mir; extern crate rustc_target; extern...
code_fim
hard
{ "lang": "rust", "repo": "apoelstra/miri", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: untoldwind/t-rust-less path: /lib/src/block_store/sled.rs use std::{collections::HashMap, path::Path}; use sled::transaction::ConflictableTransactionError; use crate::memguard::weak::ZeroingWords; use super::{generate_block_id, BlockStore, Change, ChangeLog, RingContent, RingId, StoreError, S...
code_fim
hard
{ "lang": "rust", "repo": "untoldwind/t-rust-less", "path": "/lib/src/block_store/sled.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn change_logs(&self) -> StoreResult<Vec<ChangeLog>> { self .change_logs .iter() .map(|kv| { let (k, v) = kv?; let changes: Vec<Change> = rmp_serde::from_read(v.as_ref())?; Ok(ChangeLog { node: String::from_utf8_lossy(&k).to_string(), ch...
code_fim
hard
{ "lang": "rust", "repo": "untoldwind/t-rust-less", "path": "/lib/src/block_store/sled.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn commit(&self, changes: &[Change]) -> StoreResult<()> { self.change_logs.transaction::<_, _, StoreError>(|tx| { let new_changes = match tx.get(&self.node_id)? { Some(existing_raw) => { let mut existing: Vec<Change> = rmp_serde::from_read(existing_raw.as_ref()) ....
code_fim
hard
{ "lang": "rust", "repo": "untoldwind/t-rust-less", "path": "/lib/src/block_store/sled.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ge--"); sorts::merge::test(); println!("--insertion--"); sorts::insertion::test(); }<|fim_prefix|>// repo: lmj01/rust-meijie path: /mjalgorithm/examples/sorts.rs use mjalgorithm::sorts; fn main() { println!("--bubble--"); sorts::bubble::test(); <|fim_middle|> println!("--comb of...
code_fim
medium
{ "lang": "rust", "repo": "lmj01/rust-meijie", "path": "/mjalgorithm/examples/sorts.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lmj01/rust-meijie path: /mjalgorithm/examples/sorts.rs use mjalgorithm::sorts; fn main() { println!("--bubble--"); sorts::bubble::test(); <|fim_suffix|>ge--"); sorts::merge::test(); println!("--insertion--"); sorts::insertion::test(); }<|fim_middle|> println!("--comb of...
code_fim
medium
{ "lang": "rust", "repo": "lmj01/rust-meijie", "path": "/mjalgorithm/examples/sorts.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl JsonHandler for Accessories { fn handle( &mut self, _: Uri, _: Vec<u8>, _: &IdPtr, _: &EventSubscriptions, _: &ConfigPtr, _: &DatabasePtr, accessories: &AccessoryList, _: &EventEmitterPtr, ) -> Result<Response<Body>> { ...
code_fim
medium
{ "lang": "rust", "repo": "jmhodges/hap-rs", "path": "/src/transport/http/handler/accessories.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jmhodges/hap-rs path: /src/transport/http/handler/accessories.rs use hyper::{Body, Response, StatusCode, Uri}; use crate::{ config::ConfigPtr, db::{AccessoryList, DatabasePtr}, event::EventEmitterPtr, protocol::IdPtr, transport::http::{handler::JsonHandler, json_response, se...
code_fim
medium
{ "lang": "rust", "repo": "jmhodges/hap-rs", "path": "/src/transport/http/handler/accessories.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prisma/prisma-engines path: /psl/psl/tests/common/asserts.rs &str) -> walkers::ScalarFieldAttributeWalker<'_>; fn assert_name(&self, name: &str) -> &Self; fn assert_mapped_name(&self, name: &str) -> &Self; fn assert_clustered(&self, clustered: bool) -> &Self; fn assert_type(&self...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/psl/psl/tests/common/asserts.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[track_caller] fn assert_string(&self, expected: &str) -> &Self { match self { ast::Expression::StringValue(actual, _) => assert_eq!(actual, expected), _ => panic!("Not a string value"), } self } #[track_caller] fn assert_int(&self, ex...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/psl/psl/tests/common/asserts.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prisma/prisma-engines path: /psl/psl/tests/common/asserts.rs pub(crate) trait DefaultValueAssert { fn assert_autoincrement(&self) -> &Self; fn assert_auto(&self) -> &Self; fn assert_string(&self, val: &str) -> &Self; fn assert_int(&self, val: usize) -> &Self; fn assert_deci...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/psl/psl/tests/common/asserts.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let m_colr = wavelength_to_rgba(_lambda, transmit(n1, n2, d1, d2, d_sub, total_layers, &false, &_lambda)); _magn_colr = _magn_colr.blend(m_colr, blend_mode); } let magn: [u8; 4] = Srgba::from_linear(_magn_colr).into_format().into_raw(); magn } // make an image with quadrants...
code_fim
hard
{ "lang": "rust", "repo": "jeremyDudo/dichroic_mirror", "path": "/rusty_mirror/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeremyDudo/dichroic_mirror path: /rusty_mirror/src/lib.rs extern crate nalgebra as na; use na::{Matrix2, Complex}; extern crate palette; use palette::{LinSrgba, Srgba, Pixel, Blend}; use palette::blend::{Equations, Parameter}; extern crate image; use image::{ImageBuffer, Rgba}; // Matrices fo...
code_fim
hard
{ "lang": "rust", "repo": "jeremyDudo/dichroic_mirror", "path": "/rusty_mirror/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // rgba } // determine transmittivity (1 - reflectivity) fn transmit(n1:&f32, n2:&f32, d1:&f32, d2:&f32, d_sub:&f32, total_layers:&u32, polarization:&bool, lambda:&f32) -> f32 { let r = reflect(n1,n2,d1,d2,d_sub,total_layers,polarization,lambda); let t = 1.0 - r; t } // to improve from ...
code_fim
hard
{ "lang": "rust", "repo": "jeremyDudo/dichroic_mirror", "path": "/rusty_mirror/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut i = low; for j in low..high { if array[j] <= pivot { array.swap(i, j); i += 1; } } array.swap(i, high); i } fn select<T: Ord + Clone>(array: &mut [T], low: usize, high: usize, order: usize) -> T { if low < high { let p = part...
code_fim
hard
{ "lang": "rust", "repo": "Zach41/rust-algorithm-club", "path": "/src/kth_smallest/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zach41/rust-algorithm-club path: /src/kth_smallest/mod.rs pub fn kth_smallest<T: Ord + Clone>(array: &[T], k: usize) -> T { assert!(k < array.len()); let mut arr = array.to_vec(); let len = arr.len(); select(&mut arr, 0, len - 1, k) } fn get_pivot<T: Clone>(array: &mut [T], low...
code_fim
hard
{ "lang": "rust", "repo": "Zach41/rust-algorithm-club", "path": "/src/kth_smallest/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_duplicates() { let numbers = vec![1, 2, 1, 2, 3, 2, 3, 3]; assert_eq!(kth_smallest(&numbers, 0), 1); assert_eq!(kth_smallest(&numbers, 1), 1); assert_eq!(kth_smallest(&numbers, 3), 2); assert_eq!(kth_smallest(&numbers, 2), 2); assert_...
code_fim
hard
{ "lang": "rust", "repo": "Zach41/rust-algorithm-club", "path": "/src/kth_smallest/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[juniper::graphql_object] impl MutationRoot { fn create_human(new_human: NewHuman) -> FieldResult<Human> { Ok(Human { id: "1234".to_owned(), name: new_human.name, appears_in: new_human.appears_in, home_planet: new_human.home_planet, }) ...
code_fim
hard
{ "lang": "rust", "repo": "actix/examples", "path": "/graphql/juniper/src/schema.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: actix/examples path: /graphql/juniper/src/schema.rs use juniper::{EmptySubscription, FieldResult, RootNode}; #[derive(GraphQLEnum)] enum Episode { NewHope, Empire, Jedi, } use juniper::{GraphQLEnum, GraphQLInputObject, GraphQLObject}; #[derive(GraphQLObject)] #[graphql(description...
code_fim
hard
{ "lang": "rust", "repo": "actix/examples", "path": "/graphql/juniper/src/schema.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: david-sawatzke/Rust-8 path: /chip8/src/output.rs use crate::display::{Buffer, HEIGHT, WIDTH}; pub const DISPLAY_HEIGHT: u32 = 240; pub const DISPLAY_WIDTH: u32 = 320; const SCALE_X: u32 = DISPLAY_WIDTH as u32 / WIDTH as u32; const SCALE_Y: u32 = DISPLAY_HEIGHT as u32 / HEIGHT as u32; // Maybe us...
code_fim
hard
{ "lang": "rust", "repo": "david-sawatzke/Rust-8", "path": "/chip8/src/output.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.count.0 < SCALE_X { self.count.0 += 1; } else if self.buffer_pos.0 + 1 < WIDTH as u32 { // Begin next x buffer pixel self.buffer_pos.0 += 1; self.count.0 = 1; } else { // We're in the x overflow area le...
code_fim
hard
{ "lang": "rust", "repo": "david-sawatzke/Rust-8", "path": "/chip8/src/output.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }