text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: sanmubai/rust-practice path: /tmp/bubble_sort.rs fn bubble_sort(v:&mut Vec<i32>){ let mut n=v.len(); while n>0{ let (mut i,mut ptr_max)=(1,0); while i<n{ if v[i-1]>v[i]{ v.swap(i-1,i); ptr_max=i; } i+=1; ...
code_fim
easy
{ "lang": "rust", "repo": "sanmubai/rust-practice", "path": "/tmp/bubble_sort.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args = iter::once(CString::new(resolve_executable(&executable))) .chain(std::env::args().skip(2).map(|arg| CString::new(arg))) .collect::<Result<Vec<CString>, _>>() .unwrap(); let c_args = args.iter() .map(|arg| arg.as_ptr()) .chain(iter::once(std::ptr:...
code_fim
medium
{ "lang": "rust", "repo": "vmalloc/pwatch", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vmalloc/pwatch path: /src/main.rs extern crate errno; extern crate libc; use std::iter; use std::ffi::CString; use std::io::Write; use std::path::Path; use libc::{c_char, execv, prctl, PR_SET_PDEATHSIG, SIGTERM}; use errno::errno; fn resolve_executable(s: &str) -> String { let path = Path:...
code_fim
hard
{ "lang": "rust", "repo": "vmalloc/pwatch", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ed error message . pub fn enter ( ) - > Result < Enter EnterError > { ENTERED . with ( | c | { if c . get ( ) { Err ( EnterError { _priv : ( ) } ) } else { c . set ( true ) ; Ok ( Enter { _priv : ( ) } ) } } ) } impl fmt : : Debug for Enter { fn fmt ( & self f : & mut fmt : : Formatter < ' _ > ) - > fmt :...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/futures-executor/src/enter.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/futures-executor/src/enter.rs use std : : cell : : Cell ; use std : : fmt ; thread_local ! ( static ENTERED : Cell < bool > = Cell : : new ( false ) ) ; / / / Represents an executor context . / / / / / / For more details see [ enter documentati...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/futures-executor/src/enter.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atoav/bender-worker path: /src/work/optimize.rs use ::*; use std::collections::HashMap; use bender_config::GenResult; use bender_job::Task; use blend::Blend; use std::io; use std::process::Command; use bender_job::common::tempfile::NamedTempFile; #[cfg(unix)] use std::os::unix::fs::PermissionsE...
code_fim
hard
{ "lang": "rust", "repo": "atoav/bender-worker", "path": "/src/work/optimize.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Execute the checked blend-file at blend_path with the python file at python_path /// The final command will look something like this: /// ```text /// blender -b myfile.blend --disable-autoexec --python path/to/optimize_blend.py /// ``` fn run_with_python<S>(path: S, pythonpath: S) -> GenResult<String>...
code_fim
hard
{ "lang": "rust", "repo": "atoav/bender-worker", "path": "/src/work/optimize.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn swift_genericized( full_type: &'static str, sanitized_name: &'static str, bound_type: DataType) -> DataType { if let DataType::SwiftStruct(swift_type) = bound_type { DataType::SwiftGenericized(SwiftGenericizedDataTypeBuilder::default() .full_type(full_type) ...
code_fim
hard
{ "lang": "rust", "repo": "johnhurt/four-fours", "path": "/four-fours-core/build/gen/data_type.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johnhurt/four-fours path: /four-fours-core/build/gen/data_type.rs lazy_static! { pub static ref LONG : DataType = DataType::Primitive( PrimitiveDataTypeBuilder::default() .name("Long") .rust_name("i64") .swift_name("Int64") .build().unwrap() ...
code_fim
hard
{ "lang": "rust", "repo": "johnhurt/four-fours", "path": "/four-fours-core/build/gen/data_type.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize,Builder,Default,Clone,Copy)] #[builder(default)] #[builder(public)] #[builder(pattern = "owned")] pub struct SwiftGenericDataType { pub symbol: Option<&'static str>, pub bound_type: SwiftStructDataType } #[derive(Serialize,Builder,Default,Clone,Copy)] #[builder(default)] #[builder(...
code_fim
hard
{ "lang": "rust", "repo": "johnhurt/four-fours", "path": "/four-fours-core/build/gen/data_type.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> write!(n, ":").unwrap(); print_code_location(&mut n, &location, &location).unwrap(); write!(out, "{:<p$}{}", "", n, p = self.padding,)?; } let file_names = error .trace() .0 .iter() .map(|el| { let resolved_path = self.resolver.resolve(&el.location.0); // TODO: Process all...
code_fim
hard
{ "lang": "rust", "repo": "pjtsearch/jrsonnet", "path": "/crates/jrsonnet-evaluator/src/trace/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pjtsearch/jrsonnet path: /crates/jrsonnet-evaluator/src/trace/mod.rs mod location; use crate::{error::Error, EvaluationState, LocError}; pub use location::*; use std::path::PathBuf; /// The way paths should be displayed pub enum PathResolver { /// Only filename FileName, /// Absolute path ...
code_fim
hard
{ "lang": "rust", "repo": "pjtsearch/jrsonnet", "path": "/crates/jrsonnet-evaluator/src/trace/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // done signal module.add_stmt(v::Parallel::Assign( "ap_done".into(), v::Expr::new_logical_or( v::Expr::new_gt("counter", "timeout"), v::Expr::new_eq( "memories_sent", v::Expr::new_ulit_bin(memories.len() as u32, "1"), ...
code_fim
hard
{ "lang": "rust", "repo": "lorenzoditucci/calyx", "path": "/src/backend/xilinx/toplevel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lorenzoditucci/calyx path: /src/backend/xilinx/toplevel.rs use super::{ axi, control_axi::ControlInterface, fsm, memory_axi::bram, memory_axi::MemoryInterface, utils, }; use crate::backend::traits::Backend; use calyx::{ errors::{CalyxResult, Error}, ir, }; use vast::v05::ast as v...
code_fim
hard
{ "lang": "rust", "repo": "lorenzoditucci/calyx", "path": "/src/backend/xilinx/toplevel.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // add system signals module.add_input("ap_clk", 1); module.add_input("ap_rst_n", 1); // module.add_output("ap_interrupt", 1); // axi control signals let axi4 = axi::AxiInterface::control_channels( address_width, data_width, "s_axi_control_", ); axi...
code_fim
hard
{ "lang": "rust", "repo": "lorenzoditucci/calyx", "path": "/src/backend/xilinx/toplevel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // we don't know to where; we'll comback chunk.push_code(0, 0); chunk.push_code(0, 0); // compile the "if" block; this will be jumped over if the condition is false compile_block(if_else_stmt_node.if_block, chunk, compiler); // at the end of the "if" we need to jump past the "els...
code_fim
hard
{ "lang": "rust", "repo": "rodya-mirov/burstlang", "path": "/compiler/src/ast/compile.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodya-mirov/burstlang path: /compiler/src/ast/compile.rs use bytecode::{Chunk, FnValue, OpCode, Value}; use super::*; pub fn compile_ast(ast: AST) -> Chunk { let mut compiler = Compiler::init(); let mut chunk = Chunk::init(); compile_program(ast.root, &mut chunk, &mut compiler); ...
code_fim
hard
{ "lang": "rust", "repo": "rodya-mirov/burstlang", "path": "/compiler/src/ast/compile.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl FromStr for Input { type Err = io::Error; fn from_str(s: &str) -> Result<Self> { let mut buf = Vec::new(); for ch in s.chars() { if ch == '1' { buf.push(true); } else if ch == '0' { buf.push(false); } else {...
code_fim
hard
{ "lang": "rust", "repo": "cpjreynolds/fsm", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpjreynolds/fsm path: /src/main.rs use std::str::FromStr; use std::io::prelude::*; use std::io; use std::io::Result; fn main() { let input = Input::from_stdin(); let mut state_machine = StateMachine::new(State::X); for i in input.buf { state_machine.step(i); } let ...
code_fim
hard
{ "lang": "rust", "repo": "cpjreynolds/fsm", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Input { fn from_stdin() -> Input { loop { match prompt::<Input>("> ") { Ok(i) => return i, Err(..) => println!("Please enter a valid input string.\n"), } } } } impl FromStr for Input { type Err = io::Error; fn ...
code_fim
hard
{ "lang": "rust", "repo": "cpjreynolds/fsm", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kakashy/rustyfault path: /src/print.rs pub fn run() { // Show hello fault as output println!("Print.rs sent me"); // Basic format println!("{} is from {}", "Babe", 9); <|fim_suffix|> // Named Args println!("{name} likes to listen to {artist}", name = "Jane", artist = "K...
code_fim
medium
{ "lang": "rust", "repo": "kakashy/rustyfault", "path": "/src/print.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Placeholder for debug traits println!("{:?}", (12, true, "Strwing")); // Basic math println!("10 + 10 = {}", 10 + 10); }<|fim_prefix|>// repo: kakashy/rustyfault path: /src/print.rs pub fn run() { // Show hello fault as output println!("Print.rs sent me"); // Basic forma...
code_fim
medium
{ "lang": "rust", "repo": "kakashy/rustyfault", "path": "/src/print.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: optozorax/olymp path: /contests/codeforces/1490/src/d.rs fn calc_depth(depth: &mut [usize], a: &[usize], pos: usize, inside: usize) { depth[pos] = inside; let left_max = a[0..pos] .iter() .enumerate() .max_by_key(|(_, x)| *x) .map(|(pos2, _)| calc_depth(&mut depth[0..pos], &a[0..pos], ...
code_fim
hard
{ "lang": "rust", "repo": "optozorax/olymp", "path": "/contests/codeforces/1490/src/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: woboq/embedded-snake path: /src/main.rs #![no_std] #![no_main] // pick a panicking behavior extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics // extern crate panic_abort; // requires nightly // extern crate panic_itm; // logs messages over ITM; requires...
code_fim
hard
{ "lang": "rust", "repo": "woboq/embedded-snake", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn advance(snake: &mut Snake, turn_left : bool, turn_right: bool) { if turn_left { let ndx = snake.dy; snake.dy = -snake.dx; snake.dx = ndx; } else if turn_right { let ndx = - snake.dy; snake.dy = snake.dx; snake.dx = ndx; } let p = snak...
code_fim
hard
{ "lang": "rust", "repo": "woboq/embedded-snake", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: terrorizer1980/hhvm path: /hphp/hack/src/oxidized_by_rc/manual/mod.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. <|fim_suffix|>pub mod ast_defs_impl; mod e...
code_fim
hard
{ "lang": "rust", "repo": "terrorizer1980/hhvm", "path": "/hphp/hack/src/oxidized_by_rc/manual/mod.rs", "mode": "psm", "license": "Zend-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod ast_defs_impl; mod errors_impl; mod typing_defs_core_impl;<|fim_prefix|>// repo: terrorizer1980/hhvm path: /hphp/hack/src/oxidized_by_rc/manual/mod.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "...
code_fim
hard
{ "lang": "rust", "repo": "terrorizer1980/hhvm", "path": "/hphp/hack/src/oxidized_by_rc/manual/mod.rs", "mode": "spm", "license": "Zend-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TianTianForever/Rust-Tutorial path: /sixty_two_days_of_rust/src/bin/main.rs extern crate sixty_two_days_of_rust; use sixty_two_days_of_rust::ThreadPool; use std::net::TcpListener; use std::net::TcpStream; use std::thread; use std::time::Duration; use std::sync::mpsc; use std::sync::Arc; use std:...
code_fim
hard
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/sixty_two_days_of_rust/src/bin/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Create a thread pool with a configurable numble of threads. let pool = ThreadPool::new(5); let mut counter = 0; for stream in listener.incoming() { if counter == 2 { println!("Shutting down."); break; } counter +=1; let stream = ...
code_fim
hard
{ "lang": "rust", "repo": "TianTianForever/Rust-Tutorial", "path": "/sixty_two_days_of_rust/src/bin/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmgolembiowski/pgx path: /pgx-pg-sys/src/pg11_oids.rs YOID as isize, VARBITOID = crate::VARBITOID as isize, VARBITARRAYOID = crate::VARBITARRAYOID as isize, NUMERICOID = crate::NUMERICOID as isize, REFCURSOROID = crate::REFCURSOROID as isize, REFCURSORARRAYOID = crate::REFCUR...
code_fim
hard
{ "lang": "rust", "repo": "dmgolembiowski/pgx", "path": "/pgx-pg-sys/src/pg11_oids.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmgolembiowski/pgx path: /pgx-pg-sys/src/pg11_oids.rs = crate::INETARRAYOID as isize, CIDRARRAYOID = crate::CIDRARRAYOID as isize, CSTRINGARRAYOID = crate::CSTRINGARRAYOID as isize, BPCHAROID = crate::BPCHAROID as isize, VARCHAROID = crate::VARCHAROID as isize, DATEOID = crat...
code_fim
hard
{ "lang": "rust", "repo": "dmgolembiowski/pgx", "path": "/pgx-pg-sys/src/pg11_oids.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>BuiltInOids::PATHARRAYOID), crate::BOXARRAYOID => Some(crate::PgBuiltInOids::BOXARRAYOID), crate::FLOAT4ARRAYOID => Some(crate::PgBuiltInOids::FLOAT4ARRAYOID), crate::FLOAT8ARRAYOID => Some(crate::PgBuiltInOids::FLOAT8ARRAYOID), crate::ABSTIMEARRAYOID => Som...
code_fim
hard
{ "lang": "rust", "repo": "dmgolembiowski/pgx", "path": "/pgx-pg-sys/src/pg11_oids.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sumeet/twitchchat path: /src/encode/tests.rs use super::*; fn test_encode( mut func: impl FnMut(&mut Encoder<Vec<u8>>) -> Result<(), crate::Error>, expected: impl AsRef<str>, ) { let mut encoder = Encoder::new(vec![]); func(&mut encoder).unwrap(); assert_eq!( std::st...
code_fim
hard
{ "lang": "rust", "repo": "sumeet/twitchchat", "path": "/src/encode/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn encode_r9kbeta() { test_encode( |enc| enc.r9k_beta("#museun"), "PRIVMSG #museun :/r9kbeta\r\n", ) } #[test] fn encode_r9kbetaoff() { test_encode( |enc| enc.r9k_beta_off("#museun"), "PRIVMSG #museun :/r9kbetaoff\r\n", ) } #[test] fn encode_raid()...
code_fim
hard
{ "lang": "rust", "repo": "sumeet/twitchchat", "path": "/src/encode/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DutchGhost/requires path: /examples/test.rs use requires::*; #[requires(P > 10 && Q == P)] #[requires(even = P & 1 == 0)] #[requires(uneven = P & 1 == 1)] pub struct Validate<const P: usize, const Q: usize> { n: usize, } <|fim_suffix|> //Validate::<{ 11 }, { 11 }>::new(0usize); dbg...
code_fim
hard
{ "lang": "rust", "repo": "DutchGhost/requires", "path": "/examples/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { //Validate::<{ 11 }, { 11 }>::new(0usize); dbg!("DONE"); Validate::<{ 12 }, { 12 }>::blah(); Validate::<{ 11 }, { 11 }>::blah2(); }<|fim_prefix|>// repo: DutchGhost/requires path: /examples/test.rs use requires::*; #[requires(P > 10 && Q == P)] #[requires(even = P & 1 == 0)]...
code_fim
medium
{ "lang": "rust", "repo": "DutchGhost/requires", "path": "/examples/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //Validate::<{ 11 }, { 11 }>::new(0usize); dbg!("DONE"); Validate::<{ 12 }, { 12 }>::blah(); Validate::<{ 11 }, { 11 }>::blah2(); }<|fim_prefix|>// repo: DutchGhost/requires path: /examples/test.rs use requires::*; #[requires(P > 10 && Q == P)] #[requires(even = P & 1 == 0)] #[requires(...
code_fim
hard
{ "lang": "rust", "repo": "DutchGhost/requires", "path": "/examples/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Error codes from https://github.com/meilisearch/MeiliSearch/blob/v0.12.0/meilisearch-error/src/lib.rs match message.get("errorCode").and_then(|v| v.as_str()) { Some("index_not_found") => Error::IndexNotFound, Some("index_already_exists") => Error::IndexAlreadyExi...
code_fim
hard
{ "lang": "rust", "repo": "Aeledfyr/meilisearch-rust", "path": "/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aeledfyr/meilisearch-rust path: /src/errors.rs #[derive(Debug)] /// Struct representing errors. /// Unknow Errors are unexpected. You should consider panicking and open a GitHub issue (after ensuring you are using the supported version of the MeiliSearch server). pub enum Error { /// There i...
code_fim
hard
{ "lang": "rust", "repo": "Aeledfyr/meilisearch-rust", "path": "/src/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbartussek/kernel path: /src/main.rs pub mod cli; pub mod disassemble; pub mod parameters; pub mod qemu; pub mod xtool; use crate::{ cli::Command, parameters::Parameters, qemu::run_qemu, xtool::{build::build, clippy::clippy}, }; use disassemble::disassemble; use std::{error::Err...
code_fim
hard
{ "lang": "rust", "repo": "dbartussek/kernel", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(parent) = path.parent() { destination.push(parent); } destination.push(format!( "{}.asm", path.file_name().unwrap().to_str().unwrap() )); disassemble(pa...
code_fim
hard
{ "lang": "rust", "repo": "dbartussek/kernel", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(msg.prefix, None); assert_eq!(msg.command, "PING".to_string()); assert_eq!(msg.params, vec!["freenode".to_string()]); assert_eq!(msg.trail, None); } #[test] fn parse_multiple_args() { let msg: IrcMessage = "USER mythmon mythmon localhost :Unk...
code_fim
hard
{ "lang": "rust", "repo": "mythmon/rearguard", "path": "/src/message.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mythmon/rearguard path: /src/message.rs use std::iter::Iterator; use std::string::ToString; use std::str::FromStr; /// Messages to pass to and from client handlers #[derive(Debug)] #[derive(Clone)] pub struct IrcMessage { pub prefix: Option<String>, pub command: String, pub params: ...
code_fim
hard
{ "lang": "rust", "repo": "mythmon/rearguard", "path": "/src/message.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(msg.prefix, Some("mythmon".to_string())); assert_eq!(msg.command, "PRIVMSG".to_string()); assert_eq!(msg.params, vec!["#osu-lug".to_string()]); assert_eq!(msg.trail, Some("It works!".to_string())); } #[test] fn to_string_full() { let msg = Ir...
code_fim
hard
{ "lang": "rust", "repo": "mythmon/rearguard", "path": "/src/message.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn reverse(&self) -> Graph { let mut reversed = Graph::default(); for (node, edges) in self.0.iter() { reversed.0.entry(*node).or_insert_with(Vec::new); for referent in edges.iter() { reversed .0 ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/bindgen/ir/analysis/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/bindgen/ir/analysis/mod.rs mod template_params; pub(crate) use self::template_params::UsedTemplateParameters; mod derive; pub use self::derive::DeriveTrait; pub(crate) use self::derive::{as_cannot_...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/bindgen/ir/analysis/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> self.graph.0.keys().cloned().collect() } fn constrain(&mut self, node: Node) -> ConstrainResult { let original_size = self .reachable ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/bindgen/ir/analysis/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: standardgalactic/triple_accel path: /tests/basic_tests.rs nshtein_naive_k_with_opts(a10, b10, 5, false, EditCosts::new(3, 1, 0, None)).unwrap(); assert!(res.0 == 2); assert!(res.1.is_none()); let a11 = b"abc"; let b11 = b"ac"; res = levenshtein_naive_k_with_opts(a11, b11, 5,...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/triple_accel", "path": "/tests/basic_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let a1 = b"abcde"; let b1 = b" ab dce"; let mut res = rdamerau(a1, b1); assert!(res == 3); let a2 = b"abcde"; let b2 = b""; res = rdamerau(a2, b2); assert!(res == 5); let a3 = b"abcde"; let b3 = b"bacdee"; res = rdamerau(a3, b3); assert!(res == 2); le...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/triple_accel", "path": "/tests/basic_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: standardgalactic/triple_accel path: /tests/basic_tests.rs et a5 = b"abcde"; let b5 = b"abbde"; res = rdamerau(a5, b5); assert!(res == 1); } #[test] fn test_basic_rdamerau_exp() { let a1 = b"abcde"; let b1 = b" ab dce"; let mut res = rdamerau_exp(a1, b1); assert!(res ...
code_fim
hard
{ "lang": "rust", "repo": "standardgalactic/triple_accel", "path": "/tests/basic_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RichoDemus/advent-of-code-2019 path: /src/eleven.rs use std::cmp; use std::collections::HashMap; use num::range_inclusive; use crate::eleven::Direction::{Down, Left, Right, Up}; use crate::intputer::Intputer; use crate::intputer::Result::{AwaitingInput, Done, Output, Processing}; use crate::re...
code_fim
hard
{ "lang": "rust", "repo": "RichoDemus/advent-of-code-2019", "path": "/src/eleven.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Eq, PartialEq, Hash, Clone)] struct Point { y: i32, x: i32, } impl Point { fn travel(&self, direction: &Direction) -> Point { let y = self.y; let x = self.x; match direction { Up => Point::from(y + 1, x), Down => Point::from(y - ...
code_fim
hard
{ "lang": "rust", "repo": "RichoDemus/advent-of-code-2019", "path": "/src/eleven.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bernardoamc/labs path: /rust/aoc_2021/day_19/src/main.rs use itertools::Itertools; use std::hash::{Hash, Hasher}; use std::{ collections::HashSet, ops::{Add, Sub}, }; #[macro_use] extern crate lazy_static; lazy_static! { static ref FILE_CONTENTS: String = std::fs::read_to_string("d...
code_fim
hard
{ "lang": "rust", "repo": "bernardoamc/labs", "path": "/rust/aoc_2021/day_19/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut scanners: Vec<Vec<Point>> = FILE_CONTENTS .trim() .split("\n\n") .map(|scanner| { scanner .lines() .skip(1) .map(|line| line.split(',').map(|n| n.parse().unwrap()).collect()) .map(|positions: Ve...
code_fim
hard
{ "lang": "rust", "repo": "bernardoamc/labs", "path": "/rust/aoc_2021/day_19/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request<B>) -> Self::Future { let inner = self.inner.clone(); match req.uri().path() { "/yql.Yql/Execute" => { #[allow(non_camel_case_types)] stru...
code_fim
hard
{ "lang": "rust", "repo": "sunli829/yql", "path": "/libs/protocol/src/yql.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunli829/yql path: /libs/protocol/src/yql.rs #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExecuteRequest { #[prost(string, tag = "1")] pub sql: ::prost::alloc::string::String, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExecuteResponse { #[prost(oneof = "ex...
code_fim
hard
{ "lang": "rust", "repo": "sunli829/yql", "path": "/libs/protocol/src/yql.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, request: tonic::Request<super::ExecuteRequest>, ) -> Self::Future { let inner = self.0.clone(); let fut = async move { (*inner).execute(request).await }; ...
code_fim
hard
{ "lang": "rust", "repo": "sunli829/yql", "path": "/libs/protocol/src/yql.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evernym/indy-sdk path: /libindy/src/commands/cache.rs ::RefCell; use std::collections::HashMap; use std::rc::Rc; use std::time::{SystemTime, UNIX_EPOCH}; use domain::wallet::Tags; use errors::prelude::*; use services::wallet::WalletService; use api::{WalletHandle, PoolHandle}; use commands::{Co...
code_fim
hard
{ "lang": "rust", "repo": "evernym/indy-sdk", "path": "/libindy/src/commands/cache.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while let Some(record) = search.fetch_next_record()? { self.wallet_service.delete_record(wallet_handle, SCHEMA_CACHE, record.get_id())?; } let res = (); trace!("purge_schema_cache <<< res: {:?}", res); Ok(res) } fn purge_cred_def_cache(&self,...
code_fim
hard
{ "lang": "rust", "repo": "evernym/indy-sdk", "path": "/libindy/src/commands/cache.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] pub fn compile_unbound_script<'s>( scope: &mut HandleScope<'s>, mut source: Source, options: CompileOptions, no_cache_reason: NoCacheReason, ) -> Option<Local<'s, UnboundScript>> { unsafe { scope.cast_local(|sd| { v8__ScriptCompiler__CompileUnboundScript( sd.g...
code_fim
hard
{ "lang": "rust", "repo": "denoland/rusty_v8", "path": "/src/script_compiler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq)] pub(crate) enum BufferPolicy { BufferNotOwned = 0, BufferOwned, } impl Source { #[inline(always)] pub fn new( source_string: Local<String>, origin: Option<&ScriptOrigin>, ) -> Self { let mut buf = MaybeUninit::<...
code_fim
hard
{ "lang": "rust", "repo": "denoland/rusty_v8", "path": "/src/script_compiler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: denoland/rusty_v8 path: /src/script_compiler.rs // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license. use std::{marker::PhantomData, mem::MaybeUninit}; use crate::support::int; use crate::Function; use crate::Local; use crate::Module; use crate::Object; use crate::ScriptOri...
code_fim
hard
{ "lang": "rust", "repo": "denoland/rusty_v8", "path": "/src/script_compiler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FineTralfazz/AdventOfCode path: /2019/day03/src/main.rs use std::cmp::{max, min}; use std::collections::HashSet; use std::io::{self, Read}; use std::iter::FromIterator; #[derive(Eq, PartialEq, Hash, Clone)] struct Point { x: i32, y: i32, } type Path = Vec<Point>; fn main() { let m...
code_fim
hard
{ "lang": "rust", "repo": "FineTralfazz/AdventOfCode", "path": "/2019/day03/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut first = true; if new_x > start_x || new_y > start_y { for x in (range_start_x)..=(range_end_x) { for y in (range_start_y)..=(range_end_y) { if first { first = false } else { ...
code_fim
hard
{ "lang": "rust", "repo": "FineTralfazz/AdventOfCode", "path": "/2019/day03/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let range_start_x = min(start_x, new_x); let range_end_x = max(start_x, new_x); let range_start_y = min(start_y, new_y); let range_end_y = max(start_y, new_y); let mut first = true; if new_x > start_x || new_y > start_y { for x in (range_start_x...
code_fim
hard
{ "lang": "rust", "repo": "FineTralfazz/AdventOfCode", "path": "/2019/day03/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: incker/stratum path: /protocols/v2/binary-sv2/serde-sv2/src/primitives/byte_arrays/mod.rs pub mod b016m; pub mod b0255; pub mod b032; pub mod b064k; pub mod bytes; #[test] fn test_b0_64k() { use crate::ser::to_bytes; use core::convert::TryInto; let test: b064k::B064K = (&[1, 2, 9][...
code_fim
medium
{ "lang": "rust", "repo": "incker/stratum", "path": "/protocols/v2/binary-sv2/serde-sv2/src/primitives/byte_arrays/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match test { Ok(_) => assert!(false, "vector bigger than 64K should return an error"), Err(_) => assert!(true), } } #[test] fn test_b0_16m() { use crate::ser::to_bytes; use core::convert::TryInto; let test: b016m::B016M = (&[1 as u8, 2, 9][..]) .try_into() ...
code_fim
medium
{ "lang": "rust", "repo": "incker/stratum", "path": "/protocols/v2/binary-sv2/serde-sv2/src/primitives/byte_arrays/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_b0_64k_3() { use crate::error::Error; use core::convert::TryInto; let test: Result<b064k::B064K, Error> = (&[10; 70000][..]).try_into(); match test { Ok(_) => assert!(false, "vector bigger than 64K should return an error"), Err(_) => assert!(true), } }...
code_fim
hard
{ "lang": "rust", "repo": "incker/stratum", "path": "/protocols/v2/binary-sv2/serde-sv2/src/primitives/byte_arrays/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> TraitCandidate(trait_ref) => { let predicate = trait_ref.to_predicate(); let obligation = traits::Obligation::new(cause, self.param_env, predicate); if !self.predicate_may_hold(&obligation) { ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_typeck/check/method/probe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_typeck/check/method/probe.rs let (impl_ty, impl_substs) = self.impl_ty_and_substs(impl_def_id); let impl_ty = impl_ty.subst(self.tcx, impl_substs); // Determine the receiver type that the method itself expects. ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_typeck/check/method/probe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_typeck/check/method/probe.rs WhereClauseCandidate(_) => TraitSource(candidate.item.container.id()), TraitCandidate(trait_ref) => self.probe(|_| { let _ = self.at(&ObligationCause::dummy(), self.param_env) ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_typeck/check/method/probe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { StcpBackendInterface::MacVtap { interface: _, destroy: Some(ref name), } => { let _ = Command::new("pkexec") .args(&["ip", "link", "delete", name]) .status(); } ...
code_fim
hard
{ "lang": "rust", "repo": "yehudaNahon/usnet", "path": "/usnet_sockets/src/device.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yehudaNahon/usnet path: /usnet_sockets/src/device.rs use smoltcp::time::{Duration, Instant}; use std::fmt; use std::fs::remove_file; extern crate usnet_devices; #[cfg(feature = "netmap")] use self::usnet_devices::Netmap; use self::usnet_devices::{RawSocket, TapInterface, UnixDomainSocket}; us...
code_fim
hard
{ "lang": "rust", "repo": "yehudaNahon/usnet", "path": "/usnet_sockets/src/device.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let typedesc = match self { StcpBackendInterface::Raw(_) => "direct raw socket", StcpBackendInterface::MacVtap { interface: _, destroy: _, } => "direct macvtap", StcpBackendInterface::Tap { interface: _...
code_fim
hard
{ "lang": "rust", "repo": "yehudaNahon/usnet", "path": "/usnet_sockets/src/device.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dantepippi/zellij path: /zellij-server/src/unit/tab_tests.rs anes .get(&PaneId::Terminal(1)) .unwrap() .position_and_size() .cols, 50, "pane 1 column count" ); assert_eq!( tab.panes .get(&PaneId::Terminal...
code_fim
hard
{ "lang": "rust", "repo": "dantepippi/zellij", "path": "/zellij-server/src/unit/tab_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let position_and_size = PositionAndSize { cols: 121, rows: 30, x: 0, y: 0, ..Default::default() }; let mut tab = create_new_tab(position_and_size); tab.horizontal_split(PaneId::Terminal(2)); tab.vertical_split(PaneId::Terminal(3)); tab.move_f...
code_fim
hard
{ "lang": "rust", "repo": "dantepippi/zellij", "path": "/zellij-server/src/unit/tab_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dantepippi/zellij path: /zellij-server/src/unit/tab_tests.rs ; let new_pane_id_2 = PaneId::Terminal(3); let new_pane_id_3 = PaneId::Terminal(4); tab.vertical_split(new_pane_id_1); tab.move_focus_left(); tab.horizontal_split(new_pane_id_2); tab.horizontal_split(new_pane_i...
code_fim
hard
{ "lang": "rust", "repo": "dantepippi/zellij", "path": "/zellij-server/src/unit/tab_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>6cc1b6a0b617eec9f2124a23e94bcc611f091aa2e077c53ceb18d220365901cc4428640d3273b6e8a3696c17a39cb924a6b21b9988ce7bd7552633969b035c5c53d8ccab0f3025a33f15b1553b935d5834f8fbdb29a4e8fcaf61db3a6fd421affa01c04f34f3db1fb18e144e45f8563b20ae20e81f121af3d2d6b7eb8a37bf02f2d0c02f448d13e381dce5630f8c523936c21639fe9142f596...
code_fim
hard
{ "lang": "rust", "repo": "glatan/ghash", "path": "/crate/hash/ripemd/tests/ripemd/short_msg_kat_160.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glatan/ghash path: /crate/hash/ripemd/tests/ripemd/short_msg_kat_160.rs ( // Len = 1352 "5c0f02a39b3f6abd0c936aaea65bdc0f6498acab165cc45dd8b514bf78bc1663d7d2bda227252ade9e25c58f4c03b88912b0be6d226001e83edc6072bfdc2038e53627bae5c1330c9ca89cbd3a10cd3286d6811ae5cf982ccaf3e6103b05d68ee617f6ec22e...
code_fim
hard
{ "lang": "rust", "repo": "glatan/ghash", "path": "/crate/hash/ripemd/tests/ripemd/short_msg_kat_160.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>567552f502b7e9764d94874e6cada768724ce52a3c07a3ba1f02cfa9b8196a13830d78e1ca093df2deea", "8f5b476404810dc2108f80bf6465909bab5672a8" ), ( // Len = 1432 "8da27a722f624b6929dce24784e9a36076304c136eeb86569cc1b77385a89571d39c8c391cc11231104297da2805ec9a12ee11e6d423368bffd5325aebf52cd029d62224e97cdb66d077...
code_fim
hard
{ "lang": "rust", "repo": "glatan/ghash", "path": "/crate/hash/ripemd/tests/ripemd/short_msg_kat_160.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TianyiShi2001/rosalind path: /src/bin/fib.rs fn main() { let mut args = rosalind::utils::parse_args::<u32>(include_str!("fib.txt")); let n = args.next().unwrap() - 1; let k = args.next().unwrap(); let res = FibRabbit::new(k).nth(n as usize).unwrap(); dbg!(res); } <|fim_suffi...
code_fim
hard
{ "lang": "rust", "repo": "TianyiShi2001/rosalind", "path": "/src/bin/fib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tmp = self.n_2 * self.k + self.n_1; // dbg!(tmp); Some(std::mem::replace( &mut self.n_2, std::mem::replace(&mut self.n_1, tmp), )) } }<|fim_prefix|>// repo: TianyiShi2001/rosalind path: /src/bin/fib.rs fn main() { let mut args = rosalind...
code_fim
medium
{ "lang": "rust", "repo": "TianyiShi2001/rosalind", "path": "/src/bin/fib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-command/tests/commands/random/chars.rs use nu_test_support::nu; #[test] fn generates_chars_of_specified_length() { <|fim_suffix|> let result = actual.out; assert_eq!(result, "15"); }<|fim_middle|> let actual = nu!(r#" random chars -l 15 | size ...
code_fim
medium
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/tests/commands/random/chars.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = actual.out; assert_eq!(result, "15"); }<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-command/tests/commands/random/chars.rs use nu_test_support::nu; #[test] fn generates_chars_of_specified_length() { <|fim_middle|> let actual = nu!(r#" random chars -l 15 | size ...
code_fim
medium
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-command/tests/commands/random/chars.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yoyoliyang/rust_learn path: /src/string.rs fn main() { let mut my_string = String::from("你 好 世界!"); println!("字符串长度: {}", my_string.len()); println!("字符串是空的吗? {}", my_string.is_empty()); my_string.push_str("hello world!"); for t in my_string.split_whitespace() { pr...
code_fim
medium
{ "lang": "rust", "repo": "yoyoliyang/rust_learn", "path": "/src/string.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut str1 = "hello,world".to_string(); str1.push_str("你好世界"); str1 = str1 + "liyang"; let str2 = "o"; let str3 = "c"; let str1 = format!("{}-{}", str2, str3); println!("{}", str1); //遍历字符串 let str1 = "hello,world!你好世界!"; for i in str1.chars() { println!(...
code_fim
medium
{ "lang": "rust", "repo": "yoyoliyang/rust_learn", "path": "/src/string.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamesmarva/The-Rust-Programming-Language path: /code/ch13/code_13_19/src/main.rs fn main() { } struct Shoe { size: u32, style: String, } fn shoes_in_my_size(shoes: Vec<Shoe>, shoe_size: u32) -> Vec<Shoe> { <|fim_suffix|> // shoes.into_iter().filter(|s| s.size == shoe_size).collect...
code_fim
medium
{ "lang": "rust", "repo": "jamesmarva/The-Rust-Programming-Language", "path": "/code/ch13/code_13_19/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // shoes.into_iter().filter(|s| s.size == shoe_size).collect() t }<|fim_prefix|>// repo: jamesmarva/The-Rust-Programming-Language path: /code/ch13/code_13_19/src/main.rs fn main() { } struct Shoe { size: u32, style: String, } fn shoes_in_my_size(shoes: Vec<Shoe>, shoe_size: u32) -> Ve...
code_fim
medium
{ "lang": "rust", "repo": "jamesmarva/The-Rust-Programming-Language", "path": "/code/ch13/code_13_19/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YangKeao/auxv-pid path: /examples/procfs_show_auxv.rs extern crate auxv; fn main() { match auxv::procfs::iterate_procfs_auxv() { Ok(iter) => { <|fim_suffix|>ln!("{}\t{}", pair.key, pair.value), Err(e) => println!("Error {:?}", e) } } ...
code_fim
hard
{ "lang": "rust", "repo": "YangKeao/auxv-pid", "path": "/examples/procfs_show_auxv.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } } Err(e) => println!("Could not open procfs auxv {:?}", e) } }<|fim_prefix|>// repo: YangKeao/auxv-pid path: /examples/procfs_show_auxv.rs extern crate auxv; fn main() { match auxv::procfs::iterate_procfs_auxv() { Ok(iter) => { <|fim_middle|> ...
code_fim
hard
{ "lang": "rust", "repo": "YangKeao/auxv-pid", "path": "/examples/procfs_show_auxv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn apply(&self, state: &mut TestState) { state.value_three = true; } } #[test] fn simple_usage() { let _ = env_logger::builder().is_test(true).try_init(); let conditions: [&dyn Condition<TestState>; 3] = [ &TestConditionOne::default(), &TestCon...
code_fim
hard
{ "lang": "rust", "repo": "jaynus/survival", "path": "/external/goap/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaynus/survival path: /external/goap/src/lib.rs #![allow(dead_code)] use derivative::Derivative; use rayon::prelude::*; use std::{fmt::Debug, hash::Hash, marker::PhantomData}; pub trait State: Clone + Debug + Send + Sync {} impl<T> State for T where T: Clone + Debug + Send + Sync {} pub trait...
code_fim
hard
{ "lang": "rust", "repo": "jaynus/survival", "path": "/external/goap/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sogapalag/contest path: /atcoder/cf17-relay-open/h.rs #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = ...
code_fim
hard
{ "lang": "rust", "repo": "sogapalag/contest", "path": "/atcoder/cf17-relay-open/h.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fschutt/printpdf path: /src/svg.rs //! Abstraction class for images. Please use this class //! instead of adding `ImageXObjects` yourself use crate::{PdfLayerReference, Pt, Px, XObject, XObjectRef}; use lopdf::{Object, Stream}; use std::{error, fmt}; /// SVG - wrapper around an `XObject` to al...
code_fim
hard
{ "lang": "rust", "repo": "fschutt/printpdf", "path": "/src/svg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Let's add an SVG graphic to this file. // We need to load its source first and manually parse it into a usvg Tree. let tree = usvg::Tree::from_str(svg, &usvg::Options::default().to_ref()) .map_err(|err| format!("usvg parse: {err}"))?; // Then, we will write it to the page as th...
code_fim
hard
{ "lang": "rust", "repo": "fschutt/printpdf", "path": "/src/svg.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: indeterminateoutcomesstudios/gemini path: /src/ship/mod.rs use astronomicals::System; use entities::Faction; use resources::ShipResource; use std::fmt; /// Ship currently owned by the player. #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Ship { integrity: u32, fuel: u32, ...
code_fim
hard
{ "lang": "rust", "repo": "indeterminateoutcomesstudios/gemini", "path": "/src/ship/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Extend shipyard with more ships. pub fn add_ships(&mut self, resource: ShipResource) { self.ships.extend(resource.ships); } /// Get all available ships. pub fn get_available(&self, system: &System) -> Vec<ShipCharacteristics> { self.ships .iter() ...
code_fim
hard
{ "lang": "rust", "repo": "indeterminateoutcomesstudios/gemini", "path": "/src/ship/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Shipyard { /// Returns a new shipyard. pub fn new() -> Shipyard { Shipyard { ships: vec![] } } /// Extend shipyard with more ships. pub fn add_ships(&mut self, resource: ShipResource) { self.ships.extend(resource.ships); } /// Get all available ships. ...
code_fim
hard
{ "lang": "rust", "repo": "indeterminateoutcomesstudios/gemini", "path": "/src/ship/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amling/r4 path: /operation/src/shell.rs use ars_opts::parser::OptionsPile; use ars_opts::parser::Optionsable; use ars_opts::vals::BasicOption; use std::io::BufRead; use std::io::BufReader; use std::io::LineWriter; use std::io::Write; use std::process::Command; use std::process::Stdio; use std::s...
code_fim
hard
{ "lang": "rust", "repo": "amling/r4", "path": "/operation/src/shell.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Optionsable for ImplBe { type Options = BasicOption<Vec<String>>; fn options(opt: &mut OptionsPile<BasicOption<Vec<String>>>) { opt.match_extra_hard(BasicOption::push_all, "[external] command to run"); } } impl OperationBe for ImplBe { fn names() -> Vec<&'static str> { ...
code_fim
hard
{ "lang": "rust", "repo": "amling/r4", "path": "/operation/src/shell.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }