text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: agatan/nsh path: /src/history.rs //! //! History management. `~/.nsh_history` is a text file where each line is a JSON represented //! by `History` struct. We don't simply save the whole history as a JSON array since appending //! to a *large* history array would be very slow. //! use std::path:...
code_fim
hard
{ "lang": "rust", "repo": "agatan/nsh", "path": "/src/history.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuxxi/OS-Project path: /src/os/process.rs use crate::os::memory::MemoryRange; use crate::records::ProcessData; use std::cmp::Ordering; use std::fmt; pub type PID = i32; /** The Process Control Block (PCB) for each process */ pub struct ProcessControlBlock { pub info: ProcessData, // proces...
code_fim
medium
{ "lang": "rust", "repo": "tuxxi/OS-Project", "path": "/src/os/process.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for ProcessControlBlock { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let pid = self.pid; let name = &self.info.process_name; let state = &self.state; let blocks = &self.memory_map; write!(f, "{}\t{}\t{}\t\t\t{:?}", pid, name, blocks...
code_fim
hard
{ "lang": "rust", "repo": "tuxxi/OS-Project", "path": "/src/os/process.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrimati1992/abi_stable_crates path: /abi_stable/src/type_layout/tl_enums.rs austiveness: IsExhaustive, discriminants: TLDiscriminants) -> Self { Self { exhaustiveness, discriminants, } } /// Constructs a `GenericTLEnum` for an exhaustive enum. ...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/abi_stable_crates", "path": "/abi_stable/src/type_layout/tl_enums.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrimati1992/abi_stable_crates path: /abi_stable/src/type_layout/tl_enums.rs } } /////////////////////////// /// Every property about an enum specifically. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct TLEnum { /// The amount of fields of each variant. pub field_count: RSlic...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/abi_stable_crates", "path": "/abi_stable/src/type_layout/tl_enums.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if err { Err(IncompatibleWithNonExhaustive { full_type: layout.full_type().to_string().into(), module_path: layout.mod_path(), type_size: self.original_size(), type_alignment: self.original_alignment(), sto...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/abi_stable_crates", "path": "/abi_stable/src/type_layout/tl_enums.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { Type::Constant { parameters, .. } => { for parameter in parameters { parameter.apply_rule(left, ty); } } Type::Var(v, span) => { if v == left { *self = ty.clone(...
code_fim
hard
{ "lang": "rust", "repo": "AngelOfSol/weiss-schwarz-dsl", "path": "/rules/src/executor/semantic_analysis/hm/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AngelOfSol/weiss-schwarz-dsl path: /rules/src/executor/semantic_analysis/hm/types.rs use crate::{executor::semantic_analysis::hm::substitution::Substitution, parsing::Span}; use derivative::Derivative; use std::{ collections::{HashMap, HashSet}, fmt::Display, iter::FromIterator, }; ...
code_fim
hard
{ "lang": "rust", "repo": "AngelOfSol/weiss-schwarz-dsl", "path": "/rules/src/executor/semantic_analysis/hm/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> y: 22.263_918_778_199_81, }, ] .to_vec(), ), [LineString( [ Coordinate { x: 114.187_324_047_088_64_f64, ...
code_fim
hard
{ "lang": "rust", "repo": "lelongg/geo-geojson", "path": "/src/tests/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lelongg/geo-geojson path: /src/tests/mod.rs use crate::from_str; use geo_types::{Coordinate, Geometry, GeometryCollection, LineString, Point, Polygon}; use once_cell::sync::Lazy; static DEMO_JSON: Lazy<&str> = Lazy::new(|| include_str!("demo.json")); #[test] fn test_demo() { let expected =...
code_fim
hard
{ "lang": "rust", "repo": "lelongg/geo-geojson", "path": "/src/tests/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let space_event: Vec<String> = events .filter(event_space_id.eq(&space.id)) .select(event_name) .load::<String>(&conn)?; if space_event .iter() .any(|i| &i.to_lowercase() == &item.event_name.to_lowercase()) { return Ok(OptionalResponse::new( ...
code_fim
hard
{ "lang": "rust", "repo": "Valentine-Mario/Spacies", "path": "/server/src/controllers/event_controller.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Valentine-Mario/Spacies path: /server/src/controllers/event_controller.rs use crate::auth; use crate::diesel::RunQueryDsl; use crate::handlers::paginate::*; use crate::handlers::types::*; use crate::model::{Event, NewEvent, Space, SpaceUser, User}; use crate::schema::events::dsl::space_id as eve...
code_fim
hard
{ "lang": "rust", "repo": "Valentine-Mario/Spacies", "path": "/server/src/controllers/event_controller.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mosuka/meteora path: /meteora/src/main.rs use clap::{crate_authors, crate_name, crate_version, App, AppSettings, Arg, SubCommand}; use meteora::cli::delete::run_delete_cli; use meteora::cli::get::run_get_cli; use meteora::cli::leave::run_leave_cli; use meteora::cli::put::run_put_cli; use meteor...
code_fim
hard
{ "lang": "rust", "repo": "mosuka/meteora", "path": "/meteora/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> .takes_value(true), ) ) .subcommand( SubCommand::with_name("status") .name("status") .setting(AppSettings::DeriveDisplayOrder) .version(crate_version!()) .author(crate_authors!()) ...
code_fim
hard
{ "lang": "rust", "repo": "mosuka/meteora", "path": "/meteora/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/deno_lint path: /src/diagnostic.rs // Copyright 2020 the Deno authors. All rights reserved. MIT license. #[cfg(feature = "json")] use serde::Serialize; #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "json", derive(Serialize))] pub struct Position { pub line: usize, pub col:...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/deno_lint", "path": "/src/diagnostic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "json", derive(Serialize))] pub struct Range { pub start: Position, pub end: Position, } #[derive(Clone, Debug)] #[cfg_attr(feature = "json", derive(Serialize))] pub struct LintDiagnostic { pub range: Range, pub filename: String, pub messa...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/deno_lint", "path": "/src/diagnostic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linde12/advent-of-code-2020 path: /6/src/main.rs mod part1; mod part2; fn main() { <|fim_suffix|> // part 1 let result = part1::solve(input); println!("part 1 solution: {}", result); // part 2 let result = part2::solve(input); println!("part 2 solution: {}", result); }<|...
code_fim
easy
{ "lang": "rust", "repo": "linde12/advent-of-code-2020", "path": "/6/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // part 2 let result = part2::solve(input); println!("part 2 solution: {}", result); }<|fim_prefix|>// repo: linde12/advent-of-code-2020 path: /6/src/main.rs mod part1; mod part2; fn main() { <|fim_middle|> let input = include_str!("./input.txt").trim(); // part 1 let result = pa...
code_fim
medium
{ "lang": "rust", "repo": "linde12/advent-of-code-2020", "path": "/6/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johshoff/bart path: /libs/bart_derive/src/lib.rs #[macro_use] extern crate nom; #[macro_use] extern crate quick_error; #[macro_use] extern crate quote; extern crate proc_macro; extern crate syn; mod ast; mod parsbart; use proc_macro::TokenStream; use ast::Ast; use std::fs::File; use std::io:...
code_fim
hard
{ "lang": "rust", "repo": "johshoff/bart", "path": "/libs/bart_derive/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>n::is_none")] pub location: Option<String>, /// ID or name of Datacenter to create Server in #[serde(rename = "datacenter", skip_serializing_if = "Option::is_none")] pub datacenter: Option<String>, } impl CreateServerRequest { /// Request for POST https://api.hetzner.cloud/v1/servers ...
code_fim
hard
{ "lang": "rust", "repo": "simhaonline/hcloud-rust", "path": "/src/models/create_server_request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simhaonline/hcloud-rust path: /src/models/create_server_request.rs /* * Hetzner Cloud API * * Copied from the official API documentation for the Public Hetzner Cloud. * * The version of the OpenAPI document: 0.0.3 * * Generated by: https://openapi-generator.tech */ /// CreateServerRequ...
code_fim
hard
{ "lang": "rust", "repo": "simhaonline/hcloud-rust", "path": "/src/models/create_server_request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input = Fasta::parse_file("rosalind_lcsm.txt")?; println!("{}", find_motif(input.values().map(|s| s.trim()).collect())); Ok(()) } #[test] fn sample() { assert_eq!( "ATAG", find_motif(vec!["UUATAGC", "CCATAGU", "TTATAGTT", "ATAGGGGGGGGGG"]) ) }<|fim_prefix|>// repo: lazear/rosalind ...
code_fim
hard
{ "lang": "rust", "repo": "lazear/rosalind", "path": "/lcsm/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn sample() { assert_eq!( "ATAG", find_motif(vec!["UUATAGC", "CCATAGU", "TTATAGTT", "ATAGGGGGGGGGG"]) ) }<|fim_prefix|>// repo: lazear/rosalind path: /lcsm/src/main.rs use utils::Fasta; fn find_motif(input: Vec<&str>) -> &str { // find smallest dna string for reference let mut re...
code_fim
medium
{ "lang": "rust", "repo": "lazear/rosalind", "path": "/lcsm/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lazear/rosalind path: /lcsm/src/main.rs use utils::Fasta; fn find_motif(input: Vec<&str>) -> &str { // find smallest dna string for reference let mut ref_dna_index = 0; let mut ref_len = 1000; for (i, item) in input.iter().enumerate() { if item.len() < ref_len { ref_len = item...
code_fim
hard
{ "lang": "rust", "repo": "lazear/rosalind", "path": "/lcsm/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'s, 't, T: ?Sized> Deref for ViewMut<'s, 't, T> { type Target = T; #[inline] fn deref(&self) -> &T { self.value } } impl<'s, 't, T: ?Sized> DerefMut for ViewMut<'s, 't, T> { #[inline] fn deref_mut(&mut self) -> &mut T { self.value } }<|fim_prefix|>// repo: waonder-rs/engine path: /src/o...
code_fim
hard
{ "lang": "rust", "repo": "waonder-rs/engine", "path": "/src/old/scene/view.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: waonder-rs/engine path: /src/old/scene/view.rs use std::ops::{ Deref, DerefMut, CoerceUnsized, // DispatchFromDyn }; use std::marker::Unsize; use super::Scene; pub struct View<'s, 't, T: ?Sized> { pub(crate) scene: &'s Scene, pub(crate) value: &'t T } <|fim_suffix|>impl<'s, 't, T: ?Sized...
code_fim
hard
{ "lang": "rust", "repo": "waonder-rs/engine", "path": "/src/old/scene/view.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn deref(&self) -> &T { self.value } } pub struct ViewMut<'s, 't, T: ?Sized> { pub(crate) scene: &'s Scene, pub(crate) value: &'t mut T } impl<'s, 't, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<ViewMut<'s, 't, U>> for ViewMut<'s, 't, T> {} impl<'s, 't, T: ?Sized> Deref for ViewMut...
code_fim
hard
{ "lang": "rust", "repo": "waonder-rs/engine", "path": "/src/old/scene/view.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> team_drives.append(&mut body.team_drives); if !body.next_page_token.is_empty() && body.next_page_token != page { page = body.next_page_token.to_string(); } else { page = "".to_string(); } } // Return our resp...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/google/drive/src/teamdrives.rs", "mode": "spm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/third-party-api-clients path: /google/drive/src/teamdrives.rs use crate::Client; use crate::ClientResult; pub struct Teamdrives { pub client: Client, } impl Teamdrives { #[doc(hidden)] pub fn new(client: Client) -> Self { Teamdrives { client } } /** ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/third-party-api-clients", "path": "/google/drive/src/teamdrives.rs", "mode": "psm", "license": "CC-BY-3.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fredemus/lyak_verb path: /src/lib.rs /// Consider expanding the project to 4 dimensions for the hell of it lol // TODO: refactor feedback filters so they use fc directly. The current way sets them unnecessarily // Could fix/find problem by counting iterations of while loop #[macro_use] extern ...
code_fim
hard
{ "lang": "rust", "repo": "Fredemus/lyak_verb", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_parameter_object(&mut self) -> Arc<dyn PluginParameters> { Arc::clone(&self.params) as Arc<dyn PluginParameters> } } plugin_main!(LyakVerb); /// used to verify that delay lens are reasonable at different room sizes #[test] fn test_dly_lens() { let mut plugin = LyakVerb::default...
code_fim
hard
{ "lang": "rust", "repo": "Fredemus/lyak_verb", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Arc::clone(&self.params) as Arc<dyn PluginParameters> } } plugin_main!(LyakVerb); /// used to verify that delay lens are reasonable at different room sizes #[test] fn test_dly_lens() { let mut plugin = LyakVerb::default(); // plugin.params.length.set(9.); // plugin.params.width.se...
code_fim
hard
{ "lang": "rust", "repo": "Fredemus/lyak_verb", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Convenience const for accessing the Y coordinate of a 4-vector pub const Y: usize = 1; /// Convenience const for accessing the Z coordinate of a 4-vector pub const Z: usize = 2; /// Convenience const for accessing the E coordinate of a 4-vector pub const E: usize = 3;<|fim_prefix|>// repo: HadrienG2...
code_fim
hard
{ "lang": "rust", "repo": "HadrienG2/3photons-rust", "path": "/src/momentum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HadrienG2/3photons-rust path: /src/momentum.rs //! This module implements some domain-specific 4-momentum handling logic. use crate::numeric::Float; use nalgebra::SVector; /// 4-momentum dimension pub const MOMENTUM_DIM: usize = 4; /// Relativistic 4-momentum pub type Momentum = SVector<Float...
code_fim
medium
{ "lang": "rust", "repo": "HadrienG2/3photons-rust", "path": "/src/momentum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mark-i-m/zippynfs path: /protocol/src/build.rs use std::fs::metadata; use std::process::{Command, exit}; fn main() { // Only regenerate the rust if it is older than the thrift spec. // This way, cargo will not keep rebuilding zippyrpc, which is // really annoying let meta_rs = m...
code_fim
hard
{ "lang": "rust", "repo": "mark-i-m/zippynfs", "path": "/protocol/src/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !out.status.success() { println!("{}", String::from_utf8_lossy(&out.stderr)); exit(-1); } } else { //println!("cargo:warning=\"Thrift Up to Date :)\""); } //println!("cargo:rerun-if-changed=\"src/zippynfs.thrift\""); }<|fim_prefix|>// repo: m...
code_fim
hard
{ "lang": "rust", "repo": "mark-i-m/zippynfs", "path": "/protocol/src/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoowonYun/contract-examples path: /bonding/src/lib.rs #![no_std] #[macro_use] extern crate alloc; extern crate contract_ffi; use contract_ffi::contract_api::{account, runtime, storage, system, Error, TURef}; use contract_ffi::key::Key; use contract_ffi::unwrap_or_revert::UnwrapOrRevert; use c...
code_fim
medium
{ "lang": "rust", "repo": "JoowonYun/contract-examples", "path": "/bonding/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// Bonding contract. // // Accepts bonding amount (of type `u64`) as first argument. // Issues bonding request to the PoS contract. #[no_mangle] pub extern "C" fn call() { let pos_key = runtime::get_key(POS_CONTRACT_NAME).unwrap_or_revert_with(Error::GetKey); let pos_turef: TURef<Key> = pos_key ...
code_fim
medium
{ "lang": "rust", "repo": "JoowonYun/contract-examples", "path": "/bonding/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// A general error having to do with the IoTHub. #[allow(missing_docs)] #[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum Error { #[error("etag is not set")] EtagNotSet, #[error("From connection string error: {0}")] FromConnectionStringError(#[from] service::FromConnectionStr...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure-sdk-for-rust", "path": "/sdk/iot_hub/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MindFlavor/azure-sdk-for-rust path: /sdk/iot_hub/src/lib.rs //! Azure iot_hub crate for the unofficial Microsoft Azure SDK for Rust. This crate is part of a collection of crates: for more information please refer to [https://github.com/azure/azure-sdk-for-rust](https://github.com/azure/azure-sdk...
code_fim
medium
{ "lang": "rust", "repo": "MindFlavor/azure-sdk-for-rust", "path": "/sdk/iot_hub/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/xml-rs/src/reader/parser/inside_closing_tag_name.rs use namespace ; use reader : : lexer : : Token ; use super : : { Result PullParser State QualifiedNameTarget ClosingTagSubstate } ; impl PullParser { pub fn inside_closing_tag_name ( & mut sel...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/xml-rs/src/reader/parser/inside_closing_tag_name.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>lement name prefix " name . prefix ) ) _ = > { this . data . element_name = Some ( name . clone ( ) ) ; match token { Token : : Whitespace ( _ ) = > this . into_state_continue ( State : : InsideClosingTag ( ClosingTagSubstate : : CTAfterName ) ) Token : : TagEnd = > this . emit_end_element ( ) _ = > Some ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/xml-rs/src/reader/parser/inside_closing_tag_name.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: osohq/oso path: /polar-core/src/polar.rs use std::sync::{Arc, RwLock}; use super::data_filtering::{build_filter_plan, FilterPlan, PartialResults, Types}; use super::diagnostic::Diagnostic; use super::error::{PolarResult, RuntimeError, ValidationError}; use super::filter::Filter; use super::kb::...
code_fim
hard
{ "lang": "rust", "repo": "osohq/oso", "path": "/polar-core/src/polar.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let diagnostics = polar.diagnostic_load(vec![source]); assert_eq!(diagnostics.len(), 2); let mut diagnostics = diagnostics.into_iter(); let next = diagnostics.next().unwrap(); assert!(matches!(next, Diagnostic::Error(_))); assert!( next.to_string...
code_fim
hard
{ "lang": "rust", "repo": "osohq/oso", "path": "/polar-core/src/polar.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SveinungOverland/RustPractice path: /bintree/src/main.rs enum NodeComparison { MoveLeft, MoveRight, } struct Node { value: i32, left: Option<Box<Node>>, right: Option<Box<Node>>, } impl Node { fn new(value: i32) -> Node { Node { value: value, ...
code_fim
hard
{ "lang": "rust", "repo": "SveinungOverland/RustPractice", "path": "/bintree/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut temp: &'a mut Box<Node> = match self._direct_insert_or_child(value) { Some(child) => child, None => return, }; loop { temp = match temp._direct_insert_or_child(value) { Some(child) => child, None => return,...
code_fim
hard
{ "lang": "rust", "repo": "SveinungOverland/RustPractice", "path": "/bintree/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn build_node_tree() -> Box<Node> { return Box::new(Node { value: 10, left: Some(Box::new(Node { value: 9, left: Some(Box::new(Node { value: 8, left: Some(Box::new(Node { value: 7, left: Non...
code_fim
hard
{ "lang": "rust", "repo": "SveinungOverland/RustPractice", "path": "/bintree/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mackeee-orange/iota.rs path: /pow/src/lib.rs #![no_std] #![feature(alloc)] <|fim_suffix|>mod constants; mod pow; pub use constants::TRANSACTION_LENGTH; pub use pow::*;<|fim_middle|>extern crate alloc; extern crate iota_trytes as trytes; extern crate iota_curl as curl;
code_fim
medium
{ "lang": "rust", "repo": "mackeee-orange/iota.rs", "path": "/pow/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod constants; mod pow; pub use constants::TRANSACTION_LENGTH; pub use pow::*;<|fim_prefix|>// repo: mackeee-orange/iota.rs path: /pow/src/lib.rs #![no_std] #![feature(alloc)] extern crate alloc; <|fim_middle|>extern crate iota_trytes as trytes; extern crate iota_curl as curl;
code_fim
medium
{ "lang": "rust", "repo": "mackeee-orange/iota.rs", "path": "/pow/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CBenoit/nushell path: /crates/nu-command/src/database/mod.rs mod commands; mod expressions; mod values; use commands::add_commands_decls; use expressions::add_expressions_decls; <|fim_suffix|>pub fn add_database_decls(working_set: &mut StateWorkingSet) { add_commands_decls(working_set); ...
code_fim
medium
{ "lang": "rust", "repo": "CBenoit/nushell", "path": "/crates/nu-command/src/database/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use nu_protocol::engine::StateWorkingSet; pub fn add_database_decls(working_set: &mut StateWorkingSet) { add_commands_decls(working_set); add_expressions_decls(working_set); } #[cfg(test)] mod test_database;<|fim_prefix|>// repo: CBenoit/nushell path: /crates/nu-command/src/database/mod.rs mod ...
code_fim
medium
{ "lang": "rust", "repo": "CBenoit/nushell", "path": "/crates/nu-command/src/database/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn add_database_decls(working_set: &mut StateWorkingSet) { add_commands_decls(working_set); add_expressions_decls(working_set); } #[cfg(test)] mod test_database;<|fim_prefix|>// repo: CBenoit/nushell path: /crates/nu-command/src/database/mod.rs mod commands; mod expressions; mod values; use...
code_fim
easy
{ "lang": "rust", "repo": "CBenoit/nushell", "path": "/crates/nu-command/src/database/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for d in 1..num_days { let mut temp = vec![0;3]; for i in 0..3 { for j in 0..3 { if i != j { temp[i] = max(temp[i], dp[j] + activities[d][i]) } } } dp = temp; } return dp.iter().max().u...
code_fim
hard
{ "lang": "rust", "repo": "BigAngryDinosaur/rs_atcoder", "path": "/src/bin/vacation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BigAngryDinosaur/rs_atcoder path: /src/bin/vacation.rs use std::io; use std::io::prelude::*; use std::cmp::max; fn main() { let stdin = io::stdin(); let handle = stdin.lock(); let mut lines = handle.lines().map(|l| l.unwrap()); let num_days: usize = lines.next().unwrap().parse...
code_fim
hard
{ "lang": "rust", "repo": "BigAngryDinosaur/rs_atcoder", "path": "/src/bin/vacation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(4, change(5, vec![1, 2, 5])); assert_eq!(0, change(5, vec![3])); assert_eq!(59349132, change(777, vec![1, 2, 5, 10, 20, 50, 100])); }<|fim_prefix|>// repo: aptend/leetcode-rua path: /Rust/src/n0518_coin_change_2.rs pub fn change(amount: i32, coins: Vec<i32>) -> i32 { let mut dp...
code_fim
easy
{ "lang": "rust", "repo": "aptend/leetcode-rua", "path": "/Rust/src/n0518_coin_change_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aptend/leetcode-rua path: /Rust/src/n0518_coin_change_2.rs pub fn change(amount: i32, coins: Vec<i32>) -> i32 { let mut dp = vec![0; (amount + 1) as usize]; dp[0] = 1; for &coin in &coins { for x in coin..=amount { dp[x as usize] += dp[(x - coin) as usize]; ...
code_fim
easy
{ "lang": "rust", "repo": "aptend/leetcode-rua", "path": "/Rust/src/n0518_coin_change_2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wolvereness/fn-fixture-rs path: /fn-fixture-lib/src/traits.rs use std::fmt::{ Debug, Arguments, }; use proc_macro2::{ Span, TokenStream, }; pub(super) trait IntoCompileError<T: Sized>: Sized { #[inline(always)] fn compile_err(self, msg: &str) -> Result<T, TokenStream> {...
code_fim
hard
{ "lang": "rust", "repo": "Wolvereness/fn-fixture-rs", "path": "/fn-fixture-lib/src/traits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T> EitherResult<T> for Result<T, T> { #[inline(always)] fn either(self) -> T { match self { Ok(object) => object, Err(object) => object, } } }<|fim_prefix|>// repo: Wolvereness/fn-fixture-rs path: /fn-fixture-lib/src/traits.rs use std::fmt::{ ...
code_fim
hard
{ "lang": "rust", "repo": "Wolvereness/fn-fixture-rs", "path": "/fn-fixture-lib/src/traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kanshaohui/RustStudy path: /vectors/src/main.rs use vectors::SpreedsheetCell; fn main() { let mut v1: Vec<i32> = Vec::new(); let mut v2 = vec![1, 2, 3, 4]; let sheets = vec![ SpreedsheetCell::Int(5), SpreedsheetCell::Float(10.1), SpreedsheetCell::Text(String::...
code_fim
medium
{ "lang": "rust", "repo": "kanshaohui/RustStudy", "path": "/vectors/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match v1.get(4) { Some(four) => println!("This is v1_four {}", four), None => println!("No value"), } for i in &mut v2 { println!("v2 are {}", &i); *i = *i + 1; println!("v2 + 1 are {}", &i); } println!("Hello, world!"); }<|fim_prefix|>// repo: ...
code_fim
medium
{ "lang": "rust", "repo": "kanshaohui/RustStudy", "path": "/vectors/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_struct_length_count() { let input = b"\x02\x12\x34"; let res = S5::parse(input); assert_eq!( res, Ok(( &input[3..], S5 { b: vec![NewType(0x12), NewType(0x34)] } )) ); }<|fim_prefix|>// repo: rust-ba...
code_fim
hard
{ "lang": "rust", "repo": "rust-bakery/nom-derive", "path": "/tests/multiple.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-bakery/nom-derive path: /tests/multiple.rs #[allow(unused_imports)] #[macro_use] extern crate pretty_assertions; use nom::number::streaming::be_u8; use nom_derive::*; /// A structure with a length and a Vec #[derive(Debug, PartialEq, Nom)] struct S1 { pub a: u32, #[nom(Count = "a"...
code_fim
hard
{ "lang": "rust", "repo": "rust-bakery/nom-derive", "path": "/tests/multiple.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tweedegolf/stm32wlxx-hal path: /src/spi.rs //! Serial Peripheral Interface (SPI) bus use core::ptr; use crate::hal::spi::{FullDuplex, Mode, Phase, Polarity}; use crate::gpio::{Alternate, Floating, Input, PA4, PA5, PA6, PA7, AF13}; use crate::rcc::{Clocks, APB3}; use crate::time::Hertz; /// SP...
code_fim
hard
{ "lang": "rust", "repo": "tweedegolf/stm32wlxx-hal", "path": "/src/spi.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: incker2/logram path: /src/echo_id.rs use failure::Error; use futures::{Future, Stream}; use tgbot::{methods::SendMessage, Api as TelegramApi, UpdatesStream}; use tokio; <|fim_suffix|> let fut = updates .filter_map(|update| update.get_chat_id()) .map(|chat_id| { le...
code_fim
medium
{ "lang": "rust", "repo": "incker2/logram", "path": "/src/echo_id.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let fut = updates .filter_map(|update| update.get_chat_id()) .map(|chat_id| { let text = format!("Chat id: {}", chat_id); SendMessage::new(chat_id, text) }) .for_each(move |method| telegram.execute(&method).map(|_| ())) .map_err(|error| e...
code_fim
medium
{ "lang": "rust", "repo": "incker2/logram", "path": "/src/echo_id.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(optval != 0) } pub(crate) fn get_localaddr(socket: TcpSocket) -> io::Result<SocketAddr> { let mut addr: libc::sockaddr_storage = unsafe { std::mem::zeroed() }; let mut length = size_of::<libc::sockaddr_storage>() as libc::socklen_t; syscall!(getsockname( socket, &mut a...
code_fim
hard
{ "lang": "rust", "repo": "estebank/mio", "path": "/src/sys/unix/tcp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: estebank/mio path: /src/sys/unix/tcp.rs use std::io; use std::mem; use std::mem::{size_of, MaybeUninit}; use std::net::{self, SocketAddr}; use std::time::Duration; use std::os::unix::io::{AsRawFd, FromRawFd}; use crate::sys::unix::net::{new_socket, socket_addr, to_socket_addr}; pub type TcpSoc...
code_fim
hard
{ "lang": "rust", "repo": "estebank/mio", "path": "/src/sys/unix/tcp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(optval != 0) } #[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))] pub(crate) fn set_reuseport(socket: TcpSocket, reuseport: bool) -> io::Result<()> { let val: libc::c_int = if reuseport { 1 } else { 0 }; syscall!(setsockopt( socket, libc::SOL_SOCKET,...
code_fim
hard
{ "lang": "rust", "repo": "estebank/mio", "path": "/src/sys/unix/tcp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> StaticPage::Redirect { to: "/_".to_string(), } } fn default_page_not_found() -> StaticPage { StaticPage::Embedded { data: "404: not found.".as_bytes().to_vec(), content_type: "text/html".to_string(), } } } #[derive(Deseriali...
code_fim
hard
{ "lang": "rust", "repo": "hle0/shrtlnk", "path": "/shrtlnk/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hle0/shrtlnk path: /shrtlnk/src/config.rs use std::{borrow::Borrow, collections::BTreeMap, fs::File, io::Read}; use anyhow::anyhow; use serde::Deserialize; pub trait CheckConfig { fn check(&mut self) -> anyhow::Result<()>; } #[derive(Deserialize)] #[serde(tag = "type")] pub enum StaticPag...
code_fim
hard
{ "lang": "rust", "repo": "hle0/shrtlnk", "path": "/shrtlnk/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub mod warn; // pub use self::ir::{Ir, InvocationOfInnerLayer}; // pub use self::hir::{Hir, SymbolicName, SpannedSymbolicName}; // pub use self::action::{Action, ActionExpr}; // pub use self::fold::{Folder, FoldHir}; // pub use self::ty::{Ty, AutoTy}; // pub use self::rule::{Rule, FoldRule}; // pub use...
code_fim
medium
{ "lang": "rust", "repo": "pczarn/panini", "path": "/panini_logic/src/middle/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pczarn/panini path: /panini_logic/src/middle/mod.rs // pub mod action; // pub mod attr; pub mod embedded_string; pub mod error; // pub mod fold; // pub mod hir; pub mod ir; // pub mod rule; // #[macro_use] // pub<|fim_suffix|> pub mod warn; // pub use self::ir::{Ir, InvocationOfInnerLayer}; // ...
code_fim
medium
{ "lang": "rust", "repo": "pczarn/panini", "path": "/panini_logic/src/middle/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for fun in smod.funs.iter() { queue.push(FunQueueItem{fun : fun, pref : None}); } let mut loc_funs = vec![]; while let Some(item) = queue.pop() { let f = c_fun::compile(item.fun, &self.global_conf, &mod_name, &item.pref, &mut loc_funs); m...
code_fim
hard
{ "lang": "rust", "repo": "asvedr/oolang", "path": "/src/bytecode/compiler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: asvedr/oolang path: /src/bytecode/compiler.rs use bytecode::global_conf::*; use bytecode::compile_fun as c_fun; use bytecode::exc_keys::*; use syn::{Show, SynFn, SynMod}; use preludelib::*; /* name specifications: sampMod::fun : _sampleMod_F_fun in sampMod f...
code_fim
hard
{ "lang": "rust", "repo": "asvedr/oolang", "path": "/src/bytecode/compiler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> CMod { pub_fns : pub_f, priv_fns : priv_f } } } impl Show for CMod { fn show(&self, layer : usize) -> Vec<String> { let mut tab = String::new(); for _ in 0 .. layer { tab.push(' '); } let mut res = vec![]; ...
code_fim
hard
{ "lang": "rust", "repo": "asvedr/oolang", "path": "/src/bytecode/compiler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iggy-rs/iggy path: /server/src/components/message_saver.rs use crate::server_command::ServerCommand; use crate::server_config::MessageSaverConfig; use flume::Sender; use std::time::Duration; use tokio::{task, time}; use tracing::info; <|fim_suffix|> let duration = Duration::from_secs(config....
code_fim
hard
{ "lang": "rust", "repo": "iggy-rs/iggy", "path": "/server/src/components/message_saver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if config.interval == 0 { panic!("Message saver interval must be greater than 0.") } let duration = Duration::from_secs(config.interval); task::spawn(async move { let mut interval = time::interval(duration); info!( "Message saver is enabled, buffered me...
code_fim
medium
{ "lang": "rust", "repo": "iggy-rs/iggy", "path": "/server/src/components/message_saver.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let cc = bc - ac; let dc = bd - ad; let cdc = bcd - acd; println!("{}", b - a + 1 - cc - dc + cdc); }<|fim_prefix|>// repo: YutaGoto/daily_atcoder path: /2020-09/abc131_c.rs use whiteread::parse_line; use num_integer::gcd; fn main() { let (a, b, c, d): (usize, usize, usize, usize) =...
code_fim
medium
{ "lang": "rust", "repo": "YutaGoto/daily_atcoder", "path": "/2020-09/abc131_c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YutaGoto/daily_atcoder path: /2020-09/abc131_c.rs use whiteread::parse_line; use num_integer::gcd; fn main() { <|fim_suffix|> let cc = bc - ac; let dc = bd - ad; let cdc = bcd - acd; println!("{}", b - a + 1 - cc - dc + cdc); }<|fim_middle|> let (a, b, c, d): (usize, usize, u...
code_fim
hard
{ "lang": "rust", "repo": "YutaGoto/daily_atcoder", "path": "/2020-09/abc131_c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> buf.put_u16_be(string.len() as u16); buf.put(string); Ok(buf.to_owned().to_vec()) }<|fim_prefix|>// repo: andreycizov/yci path: /src/net/parser.rs use nom::{named, map_opt, error_position, map, do_parse, take, call, le_u16}; use crate::net::tcp::*; use bytes::buf::BufMut; named!( pub pa...
code_fim
hard
{ "lang": "rust", "repo": "andreycizov/yci", "path": "/src/net/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parse_packet(buff: Vec<u8>) -> Option<ClientBkRq> { let x: &[u8] = buff.as_ref(); serde_json::from_slice::<ClientBkRq>(&x).ok() } pub fn unparse_packet_bytes(x: &ClientBkRp) -> Result<Vec<u8>, serde_json::Error> { let string = serde_json::to_string(x)?; let string = string.into_by...
code_fim
hard
{ "lang": "rust", "repo": "andreycizov/yci", "path": "/src/net/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andreycizov/yci path: /src/net/parser.rs use nom::{named, map_opt, error_position, map, do_parse, take, call, le_u16}; use crate::net::tcp::*; use bytes::buf::BufMut; <|fim_suffix|>pub fn parse_packet(buff: Vec<u8>) -> Option<ClientBkRq> { let x: &[u8] = buff.as_ref(); serde_json::from...
code_fim
hard
{ "lang": "rust", "repo": "andreycizov/yci", "path": "/src/net/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/brawllib_rs path: /src/wiird_runner/wiird.rs #[derive(Serialize, Clone, Debug)] pub enum JumpFlag { WhenTrue, WhenFalse, Always, } #[derive(Serialize, Clone, Debug)] pub enum AddAddress { BaseAddress, PointerAddress, None, } <|fim_suffix|>impl GeckoOperation { ...
code_fim
hard
{ "lang": "rust", "repo": "rukai/brawllib_rs", "path": "/src/wiird_runner/wiird.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl GeckoOperation { pub(crate) fn new(value: u8) -> Self { match value { 00 => GeckoOperation::Add, 01 => GeckoOperation::Mul, 02 => GeckoOperation::Or, 03 => GeckoOperation::And, 04 => GeckoOperation::Xor, 05 => GeckoOp...
code_fim
hard
{ "lang": "rust", "repo": "rukai/brawllib_rs", "path": "/src/wiird_runner/wiird.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn batch_execute(&mut self, sql: String) -> Result<(), Error> { self.conn.as_mut().unwrap().batch_execute(&sql) } }<|fim_prefix|>// repo: Garfield96/fastShell path: /src/db_backend.rs use postgres::Error; use std::fmt; // pub(crate) trait DB { // fn execute(&mut self, sql: Strin...
code_fim
hard
{ "lang": "rust", "repo": "Garfield96/fastShell", "path": "/src/db_backend.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Garfield96/fastShell path: /src/db_backend.rs use postgres::Error; use std::fmt; // pub(crate) trait DB { // fn execute(&mut self, sql: String); // fn prepare<S>(&mut self, sql: String) -> &S; // } <|fim_suffix|> pub fn batch_execute(&mut self, sql: String) -> Result<(), Error> { ...
code_fim
hard
{ "lang": "rust", "repo": "Garfield96/fastShell", "path": "/src/db_backend.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn transaction(&mut self) -> Result<postgres::Transaction<'_>, Error> { self.conn.as_mut().unwrap().transaction() } pub fn batch_execute(&mut self, sql: String) -> Result<(), Error> { self.conn.as_mut().unwrap().batch_execute(&sql) } }<|fim_prefix|>// repo: Garfield96/...
code_fim
hard
{ "lang": "rust", "repo": "Garfield96/fastShell", "path": "/src/db_backend.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn precedence(a: i64, b: i64, c: i64) -> i64 { return a + (b - c) + (b + c) * a; } pub fn multi_compare(a: i64, b: i64, c: i64) -> bool { return (a < b) && (b < c) || (a >= b) && (b > c) || (a != b) && (b == c); } pub fn boolean_precedence(a: bool, b: bool, c: bool) -> bool { return a &&...
code_fim
hard
{ "lang": "rust", "repo": "MarcusRainbow/pypyrust", "path": "/src/add_mult.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarcusRainbow/pypyrust path: /src/add_mult.rs pub fn add_mult(a: i64, b: i64, c: i64) -> i64 { return a + b * c; } pub fn sub_div(a: i64, b: i64, c: i64) -> i64 { return a - b / c; } pub fn floor_div(a: i64, b: i64, c: i64) -> i64 { return a / (b % c); } <|fim_suffix|>pub fn compa...
code_fim
hard
{ "lang": "rust", "repo": "MarcusRainbow/pypyrust", "path": "/src/add_mult.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn compare(a: i64, b: i64, c: i64) -> bool { return a == b || b != c || a > b || c < a || a <= b || c >= b; } pub fn precedence(a: i64, b: i64, c: i64) -> i64 { return a + (b - c) + (b + c) * a; } pub fn multi_compare(a: i64, b: i64, c: i64) -> bool { return (a < b) && (b < c) || (a >= b...
code_fim
medium
{ "lang": "rust", "repo": "MarcusRainbow/pypyrust", "path": "/src/add_mult.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>(' { cnt += 1; } else { cnt -= 1; } cur += 1; if (cnt == 0) { ret = max(ret, cur); } if (cnt < 0) { cur = 0; cnt = 0; } } ret ...
code_fim
hard
{ "lang": "rust", "repo": "Karshilov/leet-code-tutorial", "path": "/P32.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Karshilov/leet-code-tutorial path: /P32.rs use std::cmp::max; impl Solution { pub fn longest_valid_parentheses(s: String) -> i32 { let mut cnt = 0; let mut ret = 0; let mut cur = 0; let v = &s[..]; let mut cur_char: Vec<char> = v.chars().collect(); ...
code_fim
hard
{ "lang": "rust", "repo": "Karshilov/leet-code-tutorial", "path": "/P32.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(CheckerPublishChallengeWitness { pattern, chain_id, checker_id, challenge_count, sidechain_config_dep_index, }) } } impl Serialize for CheckerPublishChallengeWitness { type RawType = [u8; CHECKER_PUBLISH_CHALLENGE_WI...
code_fim
hard
{ "lang": "rust", "repo": "LycrusHamster/axon", "path": "/axon-ckb-contracts/common-raw/src/witness/checker_publish_challenge.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LycrusHamster/axon path: /axon-ckb-contracts/common-raw/src/witness/checker_publish_challenge.rs use crate::{pattern::Pattern, FromRaw, Serialize}; const CHECKER_PUBLISH_CHALLENGE_WITNESS_LEN: usize = 9; #[derive(Debug)] pub struct CheckerPublishChallengeWitness { pattern: Pattern, pub...
code_fim
hard
{ "lang": "rust", "repo": "LycrusHamster/axon", "path": "/axon-ckb-contracts/common-raw/src/witness/checker_publish_challenge.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl KeyLess { pub fn fold(&mut self, buf: &Buffer, evnt: Event) -> Result<Event> { match buf.to_mode() { "normal" => self.normal_fold(evnt), "insert" => unreachable!(), _ => err_at!(Fatal, msg: format!("unreachable")), } } pub fn to_event_p...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/ted", "path": "/src/keymap_less.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/ted path: /src/keymap_less.rs #[allow(unused_imports)] use log::trace; use crate::{buffer::Buffer, event::Event, Error, Result}; #[derive(Clone, Default)] pub struct KeyLess; <|fim_suffix|> pub fn to_event_prefix(&self) -> Event { Event::Noop } } impl KeyLess { fn ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/ted", "path": "/src/keymap_less.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0221_maximal_square/dynamic_programming.rs pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::mem; <|fim_suffix|> result * result } } // ---------...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0221_maximal_square/dynamic_programming.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let vel = pulley .contains(PulleyMode::HAS_VEL) .then(|| cursor.read()) .transpose()?; let original_and_home_pos = action .contains(PlayerAction::HAS_ORIG_AND_HOME_POS) .then(|| Ok((cursor.read()?, cursor.read()?))) ....
code_fim
hard
{ "lang": "rust", "repo": "Lonami/terry", "path": "/terraria-protocol/src/packets/update_player.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> cursor.write(&self.player_id)?; cursor.write(&self.keys)?; cursor.write(&fixup_flags!(PulleyMode where { self.vel.is_some() => HAS_VEL, } in self.pulley))?; cursor.write(&fixup_flags!(PlayerAction where { self.original_and_home_pos.is_some() ...
code_fim
hard
{ "lang": "rust", "repo": "Lonami/terry", "path": "/terraria-protocol/src/packets/update_player.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lonami/terry path: /terraria-protocol/src/packets/update_player.rs use crate::serde::{fixup_flags, serializable_bitflags, PacketBody, Result, SliceCursor}; use crate::structures::Vec2; serializable_bitflags! { pub struct KeyPress: u8 { const UP = 0x01; const DOWN = 0x02; ...
code_fim
hard
{ "lang": "rust", "repo": "Lonami/terry", "path": "/terraria-protocol/src/packets/update_player.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }