text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: carlberger/rust-ftp path: /src/status.rs // 1xx: Positive Preliminary Reply pub const INITIATING: u32 = 100; pub const RESTART_MARKER: u32 = 110; pub const READY_MINUTE: u32 = 120; pub const ALREADY_OPEN: u32 = 125; pub const ABOUT_TO_SEND: u32 = 150; // 2xx: Positive Completion Reply pub const...
code_fim
hard
{ "lang": "rust", "repo": "carlberger/rust-ftp", "path": "/src/status.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: syxolk/indentex path: /src/transpile.rs use std::path::Path; use std::vec::Vec; use error::IndentexError; const LINESEP: &'static str = "\n"; const LATEX_TO_INDENTEX_FACTOR: f64 = 1.5; const DO_NOT_EDIT_NOTICE: &'static str = "\ % ===========================================================...
code_fim
hard
{ "lang": "rust", "repo": "syxolk/indentex", "path": "/src/transpile.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Transpilation fn transpile<T: AsRef<str>>(lines: &[T], options: &TranspileOptions) -> String { use parsers::Environment; use parsers::Hashline::{PlainLine, OpenEnv}; use parsers::process_line; // The number of environments is not known beforehand let mut env_stack: Vec<Environment>...
code_fim
hard
{ "lang": "rust", "repo": "syxolk/indentex", "path": "/src/transpile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: billnote/rust-exercism path: /diffie-hellman/src/lib.rs extern crate rand; use rand::{thread_rng, Rng}; pub fn private_key(p: u64) -> u64 { let mut rng = thread_rng(); rng.gen_range::<u64>(2, p) } <|fim_suffix|>pub fn secret(p: u64, b_pub: u64, a: u64) -> u64 { b_pub.pow(a as u32) ...
code_fim
medium
{ "lang": "rust", "repo": "billnote/rust-exercism", "path": "/diffie-hellman/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn secret(p: u64, b_pub: u64, a: u64) -> u64 { b_pub.pow(a as u32) % p }<|fim_prefix|>// repo: billnote/rust-exercism path: /diffie-hellman/src/lib.rs extern crate rand; use rand::{thread_rng, Rng}; <|fim_middle|>pub fn private_key(p: u64) -> u64 { let mut rng = thread_rng(); rng.gen_ran...
code_fim
medium
{ "lang": "rust", "repo": "billnote/rust-exercism", "path": "/diffie-hellman/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drewchandler/rust-lisp path: /src/main.rs #[macro_use] extern crate nom; extern crate rustyline; use rustyline::Editor; use nom::IResult::Done; <|fim_suffix|> match parser::sexp(line.as_bytes()) { Done(_, s) => { match s.eval(&root) { ...
code_fim
hard
{ "lang": "rust", "repo": "drewchandler/rust-lisp", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match parser::sexp(line.as_bytes()) { Done(_, s) => { match s.eval(&root) { Ok(s) => println!("{}", s), Err(e) => println!("ERROR: {}", e), }; } ...
code_fim
hard
{ "lang": "rust", "repo": "drewchandler/rust-lisp", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kichristensen/k8s-openapi-codegen path: /k8s-openapi/src/api/core/v1/pod.rs // Generated from definition io.k8s.api.core.v1.Pod /// Pod is a collection of containers that can run on a host. This resource is created by clients and scheduled onto hosts. #[derive(Debug, Default, Deserialize, Seria...
code_fim
hard
{ "lang": "rust", "repo": "kichristensen/k8s-openapi-codegen", "path": "/k8s-openapi/src/api/core/v1/pod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Specification of the desired behavior of the pod. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status #[serde(skip_serializing_if = "Option::is_none")] pub spec: Option<::api::core::v1::PodSpec>, /// Most recently observed status of the pod. T...
code_fim
hard
{ "lang": "rust", "repo": "kichristensen/k8s-openapi-codegen", "path": "/k8s-openapi/src/api/core/v1/pod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kitlith/livesplit-core path: /src/rendering/component/current_comparison.rs use crate::{ component::current_comparison::State, layout::{LayoutDirection, LayoutState}, rendering::{Backend, RenderContext}, }; pub(in crate::rendering) fn render( <|fim_suffix|>tate.text_color), ...
code_fim
hard
{ "lang": "rust", "repo": "kitlith/livesplit-core", "path": "/src/rendering/component/current_comparison.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>tate.text_color), component.value_color.unwrap_or(layout_state.text_color), component.display_two_rows || layout_state.direction == LayoutDirection::Horizontal, ); }<|fim_prefix|>// repo: kitlith/livesplit-core path: /src/rendering/component/current_comparison.rs use crate::{ comp...
code_fim
medium
{ "lang": "rust", "repo": "kitlith/livesplit-core", "path": "/src/rendering/component/current_comparison.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: derrickbaldwin/euler-project path: /rust/problem_33/src/main.rs extern crate problem_33; use problem_33::gcd; fn main() { let mut ys = Vec::new(); let mut zs = Vec::new(); let base = 10; for<|fim_suffix|> ys.push(y); zs.push(z); ...
code_fim
medium
{ "lang": "rust", "repo": "derrickbaldwin/euler-project", "path": "/rust/problem_33/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>1, |acc, y| acc * y); let product_zs = zs.iter().fold(1, |acc, z| acc * z); println!("{}", product_ys / gcd( product_zs, product_ys)); }<|fim_prefix|>// repo: derrickbaldwin/euler-project path: /rust/problem_33/src/main.rs extern crate problem_33; use problem_33::gcd; fn main() { let mut y...
code_fim
medium
{ "lang": "rust", "repo": "derrickbaldwin/euler-project", "path": "/rust/problem_33/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kamioftea/advent-of-code-2020 path: /src/day_13.rs //! This is my solution for [Advent of Code - Day 13](https://adventofcode.com/2020/day/13) Shuttle //! Search //! //! The first part was relatively simple, and seemed to be more a setup to give a push in the right //! direction for solving part...
code_fim
hard
{ "lang": "rust", "repo": "kamioftea/advent-of-code-2020", "path": "/src/day_13.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if timestamp == 0 { return 0; } ((timestamp - 1) / bus_id + 1) * bus_id - timestamp } /// The solution to part 1 - which is the next bus to depart after your arrival time? /// If you can arrive at the bus stop at earliest time, what is the next bus you can take, and how /// long wil...
code_fim
hard
{ "lang": "rust", "repo": "kamioftea/advent-of-code-2020", "path": "/src/day_13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn can_parse() { let input = "939 7,13,x,x,59,x,31,19"; assert_eq!( (939usize, vec!((0, 7), (1, 13), (4, 59), (6, 31), (7, 19))), parse_input(input) ) } #[test] fn can_find_next_departure() { assert_eq!(0, next_departure...
code_fim
hard
{ "lang": "rust", "repo": "kamioftea/advent-of-code-2020", "path": "/src/day_13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kalyankondapally/crosvm path: /cros_async/src/complete.rs // Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Need non-snake case so the macro can re-use type names for variabl...
code_fim
hard
{ "lang": "rust", "repo": "kalyankondapally/crosvm", "path": "/cros_async/src/complete.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>generate! { /// _Future for the [`complete2`] function. (Complete2, <_Fut1, _Fut2>), /// _Future for the [`complete3`] function. (Complete3, <_Fut1, _Fut2, _Fut3>), /// _Future for the [`complete4`] function. (Complete4, <_Fut1, _Fut2, _Fut3, _Fut4>), /// _Future for the [`c...
code_fim
hard
{ "lang": "rust", "repo": "kalyankondapally/crosvm", "path": "/cros_async/src/complete.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lwp001/rust-practice path: /reference_counted_smart_pointer/src/main.rs // We use Rc<T> when we want to allocate some data on the heap to be // accessed by multiple parts of our program, but we can't determine // at compile time which part of the program will use the data last. // Rc<T> is only ...
code_fim
medium
{ "lang": "rust", "repo": "lwp001/rust-practice", "path": "/reference_counted_smart_pointer/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil))))); println!("count after creating a = {}", Rc::strong_count(&a)); // Both b and c reference the same data: a let _b = Cons(3, Rc::clone(&a)); println!("count after creating b = {}", Rc::strong_count(&a)); { le...
code_fim
medium
{ "lang": "rust", "repo": "lwp001/rust-practice", "path": "/reference_counted_smart_pointer/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // New way { let c3 = dbus::blocking::Connection::new_session().unwrap(); let p = c3.with_proxy(cname, "/test", std::time::Duration::from_millis(1000)); use policykit_blocking::OrgFreedesktopDBusIntrospectable; assert_eq!(p.introspect().unwra...
code_fim
hard
{ "lang": "rust", "repo": "Sherlock-Holo/dbus-rs", "path": "/dbus-codegen-tests/tests/test1.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sherlock-Holo/dbus-rs path: /dbus-codegen-tests/tests/test1.rs #[allow(dead_code)] mod policykit; #[allow(dead_code)] #[deny(trivial_casts)] mod policykit_client; #[allow(dead_code)] #[deny(trivial_casts)] mod policykit_blocking; #[allow(dead_code)] #[deny(trivial_casts)] mod policykit_nonblo...
code_fim
medium
{ "lang": "rust", "repo": "Sherlock-Holo/dbus-rs", "path": "/dbus-codegen-tests/tests/test1.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert (test(true, x) == 2); assert (test(true, x) == 2); assert (test(true, x) == 2); assert (test(false, x) == 5); }<|fim_prefix|>// repo: sayrer/rust path: /src/test/run-pass/move-1.rs fn test(bool x, @tup(int, int, int) foo) -> int { auto bar = foo; let @tup(int,int,int) y; ...
code_fim
easy
{ "lang": "rust", "repo": "sayrer/rust", "path": "/src/test/run-pass/move-1.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sayrer/rust path: /src/test/run-pass/move-1.rs fn test(bool x, @tup(int, int, int) foo) -> int { auto bar = foo; let @tup(int,int,int) y; if (x) { y <- bar; } else { y = @tup(4,5,6); } ret y._1; } <|fim_suffix|> auto x = @tup(1,2,3); assert (test(t...
code_fim
easy
{ "lang": "rust", "repo": "sayrer/rust", "path": "/src/test/run-pass/move-1.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { auto x = @tup(1,2,3); assert (test(true, x) == 2); assert (test(true, x) == 2); assert (test(true, x) == 2); assert (test(false, x) == 5); }<|fim_prefix|>// repo: sayrer/rust path: /src/test/run-pass/move-1.rs fn test(bool x, @tup(int, int, int) foo) -> int { auto bar ...
code_fim
medium
{ "lang": "rust", "repo": "sayrer/rust", "path": "/src/test/run-pass/move-1.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> self.0.source() } } impl fmt::Display for BoxStdError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(f) } }<|fim_prefix|>// repo: lnicola/axum path: /src/body.rs //! HTTP body utilities. use bytes::Bytes; use http_body::Body as _; use std::{error::Error ...
code_fim
hard
{ "lang": "rust", "repo": "lnicola/axum", "path": "/src/body.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lnicola/axum path: /src/body.rs //! HTTP body utilities. use bytes::Bytes; use http_body::Body as _; use std::{error::Error as StdError, fmt}; use tower::BoxError; pub use hyper::body::Body; /// A boxed [`Body`] trait object. /// /// This is used in axum as the response body type for applicat...
code_fim
hard
{ "lang": "rust", "repo": "lnicola/axum", "path": "/src/body.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/lowpan/drivers/lowpan-ot-driver/src/config.rs // Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::prelude::*; use anyhow::Error; us...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/lowpan/drivers/lowpan-ot-driver/src/config.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn default_backbone_name() -> Option<String> { None } fn default_ot_radio_path() -> Option<String> { None } pub fn try_new() -> Result<Config, Error> { use std::path::Path; let args: DriverArgs = argh::from_env(); let config_path = args.confi...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/lowpan/drivers/lowpan-ot-driver/src/config.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(tmp) = args.max_auto_restarts { fx_log_info!( "cmdline overriding max_auto_restarts from {} to {}", self.max_auto_restarts, tmp ); self.max_auto_restarts = tmp; } if let Some(tmp) = arg...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/lowpan/drivers/lowpan-ot-driver/src/config.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, f: impl Fn(&mut Self) -> Result<Option<R>, Box<dyn Error>>, timeout: Duration, ) -> Result<R, Box<dyn Error>> { let start = Instant::now(); loop { self.ratelimiter.wait(); if let Some(tick) = f(self)? { return...
code_fim
hard
{ "lang": "rust", "repo": "RLBot/rlbot-rust", "path": "/src/physicist.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Polls for a new physics tick. /// /// If there is a tick that is newer than the previous tick, it is /// returned. Otherwise, `None` is returned. #[allow(clippy::redundant_closure)] pub fn try_next_flat(&mut self) -> Option<game::RigidBodyTick> { if let Some(tick) = sel...
code_fim
hard
{ "lang": "rust", "repo": "RLBot/rlbot-rust", "path": "/src/physicist.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RLBot/rlbot-rust path: /src/physicist.rs use crate::{ffi, game, rlbot::RLBot}; use std::{ error::Error, mem, time::{Duration, Instant}, }; /// An iterator-like object that yields physics ticks from the game as they /// occur. pub struct Physicist<'a> { rlbot: &'a RLBot, rate...
code_fim
hard
{ "lang": "rust", "repo": "RLBot/rlbot-rust", "path": "/src/physicist.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs // Copyright 2021 Shift Crypto AG // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_hashed_encoding() { // Compute expected hash by encoding to CBOR and then hashing. let expected_hash: [u8; 32] = { let mut cbor_encoded: Vec<u8> = Vec::new(); let mut encoder = Encoder::new(&mut cbor_encoded); encode_something(&mu...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /bt/nsIContentSecurityManager.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIContentSecurityManager.idl // {static D: &'static [Interface] = &[ <|fim_suffix|> /* boolean isOriginPotentiallyTrustworthy (in nsIPrincipal ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsIContentSecurityManager.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* boolean isOriginPotentiallyTrustworthy (in nsIPrincipal aPrincipal); */ Method { name: "isOriginPotentiallyTrustworthy", abi: "C", params: &[Param { name: "aPrincipal", ty: "*const nsIPrincip...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/bt/nsIContentSecurityManager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_invalid_precision_spec() { let spec = "1x:60y"; let retention_opt = RetentionPolicy::spec_to_retention_policy(spec); let expected = format!("Error: Invalid schema: Policy '{}' is in an invalid format\n", spec); assert_eq!(format!("{}", retention_opt....
code_fim
hard
{ "lang": "rust", "repo": "tureus/whisper", "path": "/src/whisper/schema/retention_policy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tureus/whisper path: /src/whisper/schema/retention_policy.rs use whisper::point::POINT_SIZE; use whisper::file::archive::ARCHIVE_INFO_SIZE; use whisper::errors::{SchemaError, Result}; use byteorder::{ BigEndian, WriteBytesExt }; use regex; use std::io::{ BufWriter, Write }; use std::fs::File; ...
code_fim
hard
{ "lang": "rust", "repo": "tureus/whisper", "path": "/src/whisper/schema/retention_policy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if ::gc::finalizer_safe() { ::gc::Finalize::finalize(self); } } } }; // Generate the final value as a TokenStream and return it result.to_string().parse().unwrap() } #[proc_macro_derive(Finalize)] pub fn derive_finalize(...
code_fim
hard
{ "lang": "rust", "repo": "kevincox/rust-gc", "path": "/gc_derive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Generate the final value as a TokenStream and return it result.to_string().parse().unwrap() } #[proc_macro_derive(Finalize)] pub fn derive_finalize(input: TokenStream) -> TokenStream { let source = input.to_string(); let ast = syn::parse_macro_input(&source).unwrap(); let name = &...
code_fim
hard
{ "lang": "rust", "repo": "kevincox/rust-gc", "path": "/gc_derive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kevincox/rust-gc path: /gc_derive/src/lib.rs extern crate proc_macro; extern crate syn; extern crate synstructure; #[macro_use] extern crate quote; use proc_macro::TokenStream; use synstructure::BindStyle; #[proc_macro_derive(Trace, attributes(unsafe_ignore_trace))] pub fn derive_trace(input: ...
code_fim
hard
{ "lang": "rust", "repo": "kevincox/rust-gc", "path": "/gc_derive/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Serbis/seal_rs path: /src/testkit/actors/mod.rs //! Test framework for actors //! //! # Table of Contents //! 1. [Introduction](#introduction) //! 2. [TestActorSystem](#testactorsystem) //! 3. [TestActorRef](#testactorref) //! 4. [TestProbe](#testprobe) //! 5. [Examples](#examples) //! //! # Int...
code_fim
hard
{ "lang": "rust", "repo": "Serbis/seal_rs", "path": "/src/testkit/actors/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(m) = v.downcast_ref::<logger::Log>() { //! if m.text.len() > 100 { //! match m.target { //! logger::LogTarget::StdOut => true, //! _ => false //! } //! } else { //! false //! } //! } else { //! ...
code_fim
hard
{ "lang": "rust", "repo": "Serbis/seal_rs", "path": "/src/testkit/actors/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>chains with //! target actor. You send message to the target actor, receive response from it and if it is //! matched, reply to them with new message, and again wait a message and so on. //! //! ``` //! probe.send(target.clone(), Box::new(some_actor::DoFirstAction { })); //! probe.expect_msg(type_matcher!...
code_fim
hard
{ "lang": "rust", "repo": "Serbis/seal_rs", "path": "/src/testkit/actors/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn problem_029_1_test() { assert_eq!(problem_029(2, 5), 15); } #[test] fn problem_029_2_test() { assert_eq!(problem_029(2, 100), 9183); } }<|fim_prefix|>// repo: treetips/project-euler path: /rust/src/p029.rs use bigdecimal::BigDecimal; use crate::util::pow; use std::collect...
code_fim
hard
{ "lang": "rust", "repo": "treetips/project-euler", "path": "/rust/src/p029.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(problem_029(2, 5), 15); } #[test] fn problem_029_2_test() { assert_eq!(problem_029(2, 100), 9183); } }<|fim_prefix|>// repo: treetips/project-euler path: /rust/src/p029.rs use bigdecimal::BigDecimal; use crate::util::pow; use std::collections::HashSet; /// # [Problem 29 「個別の...
code_fim
medium
{ "lang": "rust", "repo": "treetips/project-euler", "path": "/rust/src/p029.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: treetips/project-euler path: /rust/src/p029.rs use bigdecimal::BigDecimal; use crate::util::pow; use std::collections::HashSet; /// # [Problem 29 「個別のべき乗」](https://odz.sakura.ne.jp/projecteuler/?Problem+29) /// ## Description /// ```txt /// 2 ≤ a ≤ 5 と 2 ≤ b ≤ 5について, a^b を全て考えてみよう: /// /// 2^2...
code_fim
medium
{ "lang": "rust", "repo": "treetips/project-euler", "path": "/rust/src/p029.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Noah2610/deathframe path: /deathframe_animation/src/lib.rs extern crate climer; extern crate core; #<|fim_suffix|>[macro_use] extern crate serde; pub mod components; pub mod data; pub mod systems;<|fim_middle|>[macro_use] extern crate derive_builder; #
code_fim
easy
{ "lang": "rust", "repo": "Noah2610/deathframe", "path": "/deathframe_animation/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>components; pub mod data; pub mod systems;<|fim_prefix|>// repo: Noah2610/deathframe path: /deathframe_animation/src/lib.rs extern crate climer; extern crate core; #[macro_use] extern crate derive_builder; #<|fim_middle|>[macro_use] extern crate serde; pub mod
code_fim
easy
{ "lang": "rust", "repo": "Noah2610/deathframe", "path": "/deathframe_animation/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[structopt(short, long)] /// Cell count cc: Option<f32>, #[structopt(short, long)] /// Date format (default: "%d/%m/%Y") f: Option<String>, } fn parse_date(date: String, format: String) -> Result<NaiveDateTime, ParseError> { let t = NaiveTime::from_hms(0, 0, 0); let date...
code_fim
hard
{ "lang": "rust", "repo": "drodil/rustybeer", "path": "/rustybeer-cli/src/commands/yeast_viability.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drodil/rustybeer path: /rustybeer-cli/src/commands/yeast_viability.rs use chrono::format::ParseError; use chrono::{Duration, Local, NaiveDate, NaiveDateTime, NaiveTime}; use rustybeer::calculators::yeast_viability::{calculate_cc, calculate_yv}; use structopt::StructOpt; #[derive(Debug, StructOp...
code_fim
hard
{ "lang": "rust", "repo": "drodil/rustybeer", "path": "/rustybeer-cli/src/commands/yeast_viability.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let t = NaiveTime::from_hms(0, 0, 0); let date_only = NaiveDate::parse_from_str(&date, &format)?.and_time(t); Ok(date_only) } pub fn calculate_and_print(yv_options: YeastViabilityOptions) { let mut format = String::from("%d/%m/%Y"); if let Some(f) = yv_options.f { format = f; ...
code_fim
hard
{ "lang": "rust", "repo": "drodil/rustybeer", "path": "/rustybeer-cli/src/commands/yeast_viability.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n4o847/procon-rust path: /accepted/sumitb2019_d.rs use proconio::{fastout, input}; use proconio::marker::Chars; #[fastout] fn main() { input! { n: usize, s: Chars, } let mut ans = 0; for a in 0..=9 { let mut i = 0; while i <|fim_suffix|>= Some(b)...
code_fim
hard
{ "lang": "rust", "repo": "n4o847/procon-rust", "path": "/accepted/sumitb2019_d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>(10) != Some(c) { k += 1; } if k == n { continue; } ans += 1; } } } println!("{}", ans); }<|fim_prefix|>// repo: n4o847/procon-rust path: /accepted/sumitb2019_d.rs use proco...
code_fim
hard
{ "lang": "rust", "repo": "n4o847/procon-rust", "path": "/accepted/sumitb2019_d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>= Some(b) { j += 1; } if j == n { continue; } for c in 0..=9 { let mut k = j + 1; while k < n && s[k].to_digit(10) != Some(c) { k += 1; } if k...
code_fim
hard
{ "lang": "rust", "repo": "n4o847/procon-rust", "path": "/accepted/sumitb2019_d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_miner<S: AsRef<str>>(&self, miner_name: S) -> anyhow::Result<&MinerProcess> { Ok(self .miners .get(miner_name.as_ref()) .ok_or_else(|| TariWorldError::MinerProcessNotFound(miner_name.as_ref().to_string()))?) } pub fn get_merge_miner<S: As...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/integration_tests/src/world.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tari-project/tari path: /integration_tests/src/world.rs // Copyright 2023. The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of source code must...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/integration_tests/src/world.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn get_base_node_or_wallet_client<S: core::fmt::Debug + AsRef<str>>( &self, name: S, ) -> anyhow::Result<NodeClient> { match self.get_node_client(&name).await { Ok(client) => Ok(NodeClient::BaseNode(client)), Err(_) => match self.get_wallet...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/integration_tests/src/world.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /jormungandr/src/metrics/mod.rs use crate::blockchain::Ref; use chain_impl_mockchain::block::Block; use jormungandr_lib::time::SecondsSinceUnixEpoch; use std::sync::Arc; pub mod backends; pub trait MetricsBackend { fn add_tx_recv_cnt(&self, count: usize); ...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/jormungandr", "path": "/jormungandr/src/metrics/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl MetricsBackend for Metrics { metrics_count_method!(add_tx_recv_cnt); metrics_count_method!(add_tx_rejected_cnt); metrics_method!(set_mempool_usage_ratio, f64); metrics_count_method!(set_mempool_total_size); metrics_count_method!(add_block_recv_cnt); metrics_count_method!(add_p...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/jormungandr", "path": "/jormungandr/src/metrics/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn process_folder_recursively<'a, F>( &'a self, parent_id: String, callback: &'a impl Fn(File) -> F, ) -> LocalBoxFuture<'a, Result<()>> where F: Future<Output = Result<()>>, { async move { let files = self .get...
code_fim
hard
{ "lang": "rust", "repo": "corvinux/gdrivefs-rust", "path": "/src/drive_client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: corvinux/gdrivefs-rust path: /src/drive_client.rs use anyhow::{Context, Result}; use chrono::{DateTime, Utc}; use futures::future::{FutureExt, LocalBoxFuture}; use hyper::client::HttpConnector; use hyper_rustls::HttpsConnector; use reqwest::{header, Client, RequestBuilder}; use std::cell::Cell; ...
code_fim
hard
{ "lang": "rust", "repo": "corvinux/gdrivefs-rust", "path": "/src/drive_client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_file_content( &self, file_id: &str, byte_from: u64, byte_to: u64, ) -> Result<bytes::Bytes> { let request_url = format!("/files/{}", file_id); dbg!(&request_url); let mut request = self.get_authenticated_blocking(request_url.as_str...
code_fim
hard
{ "lang": "rust", "repo": "corvinux/gdrivefs-rust", "path": "/src/drive_client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suclogger/leetcode-rust path: /chapter_11/segment_tree/range-sum-query-mutable/src/main.rs fn main() { let na = NumArray::new(vec![9,-8]); assert_eq!(na.sum_range(1, 1), -8); } pub struct SegTree { pub info: i32, pub start: i32, pub end: i32, pub left: Option<Box<SegTree...
code_fim
hard
{ "lang": "rust", "repo": "suclogger/leetcode-rust", "path": "/chapter_11/segment_tree/range-sum-query-mutable/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct NumArray { pub seg_tree: SegTree, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl NumArray { fn new(nums: Vec<i32>) -> Self { let mut na = NumArray { seg_tree : SegTree::new(...
code_fim
hard
{ "lang": "rust", "repo": "suclogger/leetcode-rust", "path": "/chapter_11/segment_tree/range-sum-query-mutable/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn query_range(&self, a: i32, b: i32) -> i32 { if a > self.end || b < self.start { return 0; } if a <= self.start && b >= self.end { return self.info; } return self.left.as_ref().unwrap().query_range(a, b) + self.right.as_ref().unwrap()...
code_fim
hard
{ "lang": "rust", "repo": "suclogger/leetcode-rust", "path": "/chapter_11/segment_tree/range-sum-query-mutable/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (p, _) in &self.cubes { new_cubes.insert(p.clone(), self.new_state(&p, use_4d)); for n in p.neighbours(use_4d) { if !new_cubes.contains_key(&n) { new_cubes.insert(n.clone(), self.new_state(&n, use_4d)); } ...
code_fim
hard
{ "lang": "rust", "repo": "myddrin/advent_code_2020", "path": "/rust/day_17/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: myddrin/advent_code_2020 path: /rust/day_17/main.rs use std::{io, env}; use std::fs::File; use std::io::{BufReader, BufRead}; use std::collections::HashMap; use std::time::Instant; #[derive(Clone,Debug,Hash, PartialEq, Eq)] struct Position { x: i32, y: i32, z: i32, w: i32, } im...
code_fim
hard
{ "lang": "rust", "repo": "myddrin/advent_code_2020", "path": "/rust/day_17/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: horup/frameworky-rust path: /src/context.rs use std::{rc::Rc, any::Any}; use legion::world::{Duplicate, World}; use crate::components::{Body, Transform}; pub struct Time { pub t:f64, pub dt:f64, pub current:f64, pub accumulator:f64, pub alpha:f64 } <|fim_suffix|>impl Defau...
code_fim
hard
{ "lang": "rust", "repo": "horup/frameworky-rust", "path": "/src/context.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for Context { fn default() -> Self { Context { once:false, world:World::default(), events:Vec::new(), time:Time::default(), fixed_update_count:0, fixed_update_called:false } } } impl Context { pub fn clone_world(&self) -> World { let mut cloned:World = Wo...
code_fim
medium
{ "lang": "rust", "repo": "horup/frameworky-rust", "path": "/src/context.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mark-i-m/os1 path: /kernel/memory/regionmap.rs //! Module for detecting available physical memory //! //! Get memory map at boot time and use it construct `RegionMap`s. The BIOS calls needed have to //! run before we switch to protected mode. In particular, this module assumes that we are using...
code_fim
hard
{ "lang": "rust", "repo": "mark-i-m/os1", "path": "/kernel/memory/regionmap.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> RegionMap { list: rlist, index: 0, } } /// Print out the memory map for debugging purposes #[allow(dead_code)] pub fn dump(&self) { for i in 0..self.list.len() { self.list[i].dump(); } } } /// Make `RegionMap` iterab...
code_fim
hard
{ "lang": "rust", "repo": "mark-i-m/os1", "path": "/kernel/memory/regionmap.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Find the beginning address of the next region of memory based on the E820 BIOS call fn find_next(addr: usize) -> usize { unsafe { &memory_map } .iter() .take(unsafe { memory_map_count } as usize) .filter_map(|entry| { let start = entry.base_l as usize; ...
code_fim
hard
{ "lang": "rust", "repo": "mark-i-m/os1", "path": "/kernel/memory/regionmap.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn wait_schedule_update(&self, max_interval: Duration) -> LeaderCookie { use scheduler::State::*; use scheduler::LeaderState::*; let mut guard = self.lock(); let mut wait_time = max_interval; loop { guard = self.2.run_scheduler ...
code_fim
hard
{ "lang": "rust", "repo": "oleksandr-kuzmenko/verwalter", "path": "/src/daemon/shared.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oleksandr-kuzmenko/verwalter path: /src/daemon/shared.rs ice()).map(Id) } pub fn to_hex(&self) -> String { return self.0[..].to_hex(); } } impl Encodable for Id { fn encode<S: RustcEncoder>(&self, s: &mut S) -> Result<(), S::Error> { self.to_hex().encode(s) }...
code_fim
hard
{ "lang": "rust", "repo": "oleksandr-kuzmenko/verwalter", "path": "/src/daemon/shared.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oleksandr-kuzmenko/verwalter path: /src/daemon/shared.rs Option<Cantal>, debug_force_leader: bool, /// Fetch update notifier external_schedule_update: Option<Notifier>, errors: Arc<HashMap<&'static str, String>>, failed_roles: Arc<HashSet<String>>, } struct Notifiers { f...
code_fim
hard
{ "lang": "rust", "repo": "oleksandr-kuzmenko/verwalter", "path": "/src/daemon/shared.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magiclen/base64-url path: /src/lib.rs /*! # Base64 URL Base64 encode, decode, escape and unescape for URL applications. ## Examples Encode data to a Base64-URL string. ```rust assert_eq!("SGVsbG8sIHdvcmxkIQ", base64_url::encode("Hello, world!")); ``` Decode a Base64-URL string to data. <|f...
code_fim
hard
{ "lang": "rust", "repo": "magiclen/base64-url", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>Disable the default features to compile this crate without std. ```toml [dependencies.base64-url] version = "*" default-features = false ``` */ #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; pub extern crate base64; mod decode; mod encode; mod escape; mod unescape; pub use decode::*;...
code_fim
hard
{ "lang": "rust", "repo": "magiclen/base64-url", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; pub extern crate base64; mod decode; mod encode; mod escape; mod unescape; pub use decode::*; pub use encode::*; pub use escape::*; pub use unescape::*;<|fim_prefix|>// repo: magiclen/base64-url path: /src/lib.rs /*! # Base64 URL Base64 ...
code_fim
hard
{ "lang": "rust", "repo": "magiclen/base64-url", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: actix/actix-extras path: /actix-cors/tests/tests.rs t cors = Cors::default() .allowed_origin("https://example.com") .allowed_origin("https://example.org") .allowed_methods(vec![Method::GET]) .new_transform(test::ok_service()) .await .unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-extras", "path": "/actix-cors/tests/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[actix_web::test] async fn test_no_origin_response() { let cors = Cors::permissive() .disable_preflight() .new_transform(test::ok_service()) .await .unwrap(); let req = TestRequest::default().method(Method::GET).to_srv_request(); let resp = test::call_service(...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-extras", "path": "/actix-cors/tests/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let req = TestRequest::default() .insert_header(("Origin", "https://www.example.com")) .to_srv_request(); let resp = test::call_service(&cors, req).await; assert_eq!(resp.status(), StatusCode::OK); } #[actix_web::test] async fn vary_header_on_all_handled_responses() { let...
code_fim
hard
{ "lang": "rust", "repo": "actix/actix-extras", "path": "/actix-cors/tests/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manpat/skelet-rs path: /src/gfx/texture_buffer.rs use std::marker::PhantomData; #[derive(Copy, Clone, Debug)] pub struct TextureBufferID<T: Copy>(pub(super) usize, pub(super) PhantomData<*const T>); <|fim_suffix|> unsafe { gl::GenTextures(1, &mut texture_id); gl::GenBuffers(1, &mut b...
code_fim
hard
{ "lang": "rust", "repo": "manpat/skelet-rs", "path": "/src/gfx/texture_buffer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // buffer_id doesn't need to be bound here for gl::TexBuffer to work, // but it needs to have been bound at least once as gl::TEXTURE_BUFFER // before it's properly set up as such gl::BindBuffer(gl::TEXTURE_BUFFER, buffer_id); gl::BindTexture(gl::TEXTURE_BUFFER, texture_id); gl::TexBuffe...
code_fim
hard
{ "lang": "rust", "repo": "manpat/skelet-rs", "path": "/src/gfx/texture_buffer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let codes = s .split(",") .filter_map(|s| { s.parse::<I>() .map_err(|_| println!("Unable to parse {}", s)) .ok() }) .collect::<Vec<_>>(); Ok(Self { name: "base".into(), original_codes: codes.clone(), codes, position: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "tylerhawkes/adventofcode2019", "path": "/src/bin/day25.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tylerhawkes/adventofcode2019 path: /src/bin/day25.rs use std::io::Read; use std::str::FromStr; fn main() { let input = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/inputs/day25.txt")).replace("\n", ""); let mut io = input.parse::<Program<Ship>>().unwrap(); io.run(); } //gmail: ...
code_fim
hard
{ "lang": "rust", "repo": "tylerhawkes/adventofcode2019", "path": "/src/bin/day25.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<&[I]> for OpCode { fn from(codes: &[I]) -> Self { //println!("Making OpCode from {:?}", codes); let i = codes[0]; let code = i % 100; let param1 = i / 100 % 10; let param2 = i / 1000 % 10; let param3 = i / 10000 % 10; match code { 1 => Self::Add( (para...
code_fim
hard
{ "lang": "rust", "repo": "tylerhawkes/adventofcode2019", "path": "/src/bin/day25.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: provable-things/ptokens-core path: /src/erc20_on_evm/mod.rs //! # The `pERC20-on-EVM` pToken Core //! //! Here lies the functionality required for the cross-chain conversions between //! native ETH tokens and their ERC777 pToken equivalents on EVM compliant chains. //! This core consists of two ...
code_fim
hard
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/erc20_on_evm/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use crate::{ chains::{ eth::{ core_initialization::reset_eth_chain::debug_reset_eth_chain, eth_debug_functions::{debug_set_eth_account_nonce, debug_set_eth_any_sender_nonce}, eth_message_signer::{sign_ascii_msg_with_eth_key_with_no_prefix, sign_hex_msg_w...
code_fim
hard
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/erc20_on_evm/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xcode23/advent-of-code-2020 path: /src/day16.rs use crate::input; use std::collections::{BTreeSet, HashMap, HashSet}; use regex::{Captures, Regex}; static INPUT: &str = input::_INPUT; pub fn tickets_part1() -> i32 { let allowed_nums: HashSet<i32> = Regex::new(r"(\d+)\-(\d+)").unwrap() ...
code_fim
hard
{ "lang": "rust", "repo": "Xcode23/advent-of-code-2020", "path": "/src/day16.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let my_ticket: Vec<i32> = INPUT.split("\n\n").skip(1).next().unwrap() .lines().skip(1).next().unwrap() .split(',').map(|num| num.trim().parse().unwrap()).collect(); let data: HashSet<Vec<i32>> = INPUT.split("\n\n").skip(2).next().unwrap() .lines().skip(1).map(|line| { line.spl...
code_fim
hard
{ "lang": "rust", "repo": "Xcode23/advent-of-code-2020", "path": "/src/day16.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} {:?}",used_columns.len(), field_indexes); let mut prod: i64 = 1; for field in field_indexes.keys() { if field.starts_with("departure") { prod *= my_ticket[*(field_indexes.get(field).unwrap())] as i64; } } prod } fn get_full_range(capture: ...
code_fim
hard
{ "lang": "rust", "repo": "Xcode23/advent-of-code-2020", "path": "/src/day16.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn adjust(&self, x: f32, y: f32) -> Self { let mut pb = self.clone(); pb.adjust_x = pb.adjust_x + x; pb.adjust_y = pb.adjust_y + y; pb } }<|fim_prefix|>// repo: Foremark/Foremark path: /rust/svgbob/svgbob/src/point_block.rs use location::{Location,Direction}; u...
code_fim
hard
{ "lang": "rust", "repo": "Foremark/Foremark", "path": "/rust/svgbob/svgbob/src/point_block.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Foremark/Foremark path: /rust/svgbob/svgbob/src/point_block.rs use location::{Location,Direction}; use block::Block; use std::cmp::Ordering; /// An exact point in the grid /// relative to the focused char #[derive(Debug, Clone, PartialOrd, PartialEq)] pub struct PointBlock { pub location: O...
code_fim
hard
{ "lang": "rust", "repo": "Foremark/Foremark", "path": "/rust/svgbob/svgbob/src/point_block.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if set.is_empty() { println!("[empty set]"); } else { for elem in set.iter() { println!(" - {}", elem); } } } "insert" => { let value = args.get_str("<arg>"); i...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/minidb", "path": "/src/bin/minidb-cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carllerche/minidb path: /src/bin/minidb-cli.rs extern crate minidb; extern crate docopt; extern crate rand; extern crate env_logger; use minidb::config; use minidb::client::Client; use docopt::Docopt; use std::process; use std::net::SocketAddr; const USAGE: &'static str = " Usage: minidb-cli...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/minidb", "path": "/src/bin/minidb-cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> --causal=ID Fetch the current state from the given node ID and perform the remove based on that state. --help Display this message "; pub fn main() { let _ = env_logger::init(); // Create a opt parser from the top level usage let args = ...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/minidb", "path": "/src/bin/minidb-cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl FromStr for SrcAddr { type Err = AddrParseError; fn from_str(s: &str) -> Result<Self, AddrParseError> { if let Ok(addr) = SocketAddr::from_str(s) { Ok(SrcAddr::Socket(addr)) } else { let host = Interface::from_str(s)?; Ok(SrcAddr::Interface(...
code_fim
hard
{ "lang": "rust", "repo": "jean-airoldie/libzmq-rs", "path": "/libzmq/src/endpoint.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jean-airoldie/libzmq-rs path: /libzmq/src/endpoint.rs else { Err(AddrParseError::new("empty port")) } } } tryfrom_fromstr!(Port); impl fmt::Display for Port { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Port::Specified(num...
code_fim
hard
{ "lang": "rust", "repo": "jean-airoldie/libzmq-rs", "path": "/libzmq/src/endpoint.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }