text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/futures/src/impls.rs use std::mem; use {Future, empty, Poll, Task}; impl<T, E> Future for Box<Future<Item=T, Error=E>> where T: Send + 'static, E: Send + 'static, { type Item = T; type Error = E; fn poll(&mut s...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/futures/src/impls.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn schedule(&mut self, task: &mut Task) { (**self).schedule(task) } fn tailcall(&mut self) -> Option<Box<Future<Item=Self::Item, Error=Self::Error>>> { (**self).tailcall() } }<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/f...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/futures/src/impls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (**self).poll(task) } fn schedule(&mut self, task: &mut Task) { (**self).schedule(task) } fn tailcall(&mut self) -> Option<Box<Future<Item=Self::Item, Error=Self::Error>>> { (**self).tailcall() } }<|fim_prefix|>// repo: rust-lang/rustc-perf pa...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/futures/src/impls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xujihui1985/mario path: /provider/src/connector/docker.rs use hyper::{body::Buf, Client}; use hyperlocal::{UnixClientExt, UnixConnector, Uri}; use crate::connector::models::{Container, ContainerDetail}; use super::errors::DockerAPIError; const INFO_PATH: &'static str = "/info"; const LIST_CON...
code_fim
medium
{ "lang": "rust", "repo": "xujihui1985/mario", "path": "/provider/src/connector/docker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn info(&self) -> DockerAPIResult<bool> { let url = Uri::new(&self.sock_path, INFO_PATH).into(); let response = self.client.get(url).await?; let status = response.status(); Ok(status.is_success()) } pub async fn inspect( &self, id: imp...
code_fim
hard
{ "lang": "rust", "repo": "xujihui1985/mario", "path": "/provider/src/connector/docker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn list_containers(&self) -> DockerAPIResult<Vec<Container>> { let url = Uri::new(&self.sock_path, LIST_CONTAINERS_PATH).into(); let response = self.client.get(url).await?; let status = response.status(); if !status.is_success() { return Err(Docker...
code_fim
hard
{ "lang": "rust", "repo": "xujihui1985/mario", "path": "/provider/src/connector/docker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Update the session in the database let result = database .send(UpdateSession { old_token, new_token, }) .await .map_err(ErrorInternalServerError)?; Ok(HttpResponse::Ok().json(Login(result.map_err(ErrorInternalServerError)?))) }<|fim_pr...
code_fim
medium
{ "lang": "rust", "repo": "saschagrunert/webapp.rs", "path": "/backend/src/http/login_session.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Create a new token for the already given one debug!("Session token {} wants to be renewed", old_token); let new_token = Token::verify(&old_token)?; // Update the session in the database let result = database .send(UpdateSession { old_token, new_token...
code_fim
medium
{ "lang": "rust", "repo": "saschagrunert/webapp.rs", "path": "/backend/src/http/login_session.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saschagrunert/webapp.rs path: /backend/src/http/login_session.rs //! The session based login request use crate::{ database::{DatabaseExecutor, UpdateSession}, token::Token, }; use actix::prelude::*; use actix_web::{ error::ErrorInternalServerError, web::{Data, Json}, Error, ...
code_fim
medium
{ "lang": "rust", "repo": "saschagrunert/webapp.rs", "path": "/backend/src/http/login_session.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ret += ss_y; ret %= MOD; ret += MOD - (2 * s_y * w.1 % MOD); ret %= MOD; ret += n * w.1 % MOD * w.1 % MOD; ret %= MOD; } println!("Case #{tc}: {ret}"); } }<|fim_prefix|>// repo: wisest30/AlgoStudy path: /source...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/HackerCup/2022_Round_1/B/hyo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ret += MOD - (2 * s_y * w.1 % MOD); ret %= MOD; ret += n * w.1 % MOD * w.1 % MOD; ret %= MOD; } println!("Case #{tc}: {ret}"); } }<|fim_prefix|>// repo: wisest30/AlgoStudy path: /source/HackerCup/2022_Round_1/B/hyo.rs use std::io::Read...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/HackerCup/2022_Round_1/B/hyo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wisest30/AlgoStudy path: /source/HackerCup/2022_Round_1/B/hyo.rs use std::io::Read; const MOD: i64 = 1_000_000_007; fn main() { let mut stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_to_string(&mut buf).unwrap(); let mut input = buf.split_ascii_whitespace();...
code_fim
hard
{ "lang": "rust", "repo": "wisest30/AlgoStudy", "path": "/source/HackerCup/2022_Round_1/B/hyo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>gisterJump::new(self)), op_codes::JBUS | op_codes::JRED => Box::new(operations::IoJump::new(self)), op_codes::ENTA...op_codes::ENTX => match self.modification { 0 | 1 => Box::new(operations::Increase::new(self)), 2 | 3 => Box::new(operations::Enter::new(self)), _ => pan...
code_fim
hard
{ "lang": "rust", "repo": "jonnystoten/negroni", "path": "/src/mix/instruction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonnystoten/negroni path: /src/mix/instruction.rs use super::{Address, Word}; use crate::mix::op_codes; use crate::operations; #[derive(Debug)] pub struct Instruction { pub operation: u8, pub modification: u8, pub address: Address, pub index_specification: u8, } impl Instruction { p...
code_fim
hard
{ "lang": "rust", "repo": "jonnystoten/negroni", "path": "/src/mix/instruction.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn read_to_string(path: &Path) -> Option<(String, LineEndings)> { let mut text = fs::read_to_string(&path).map_err(|e| log::warn!("failed to read file {}", e)).ok()?; let line_endings = normalize_newlines(&mut text); Some((text, line_endings)) } /// Replaces `\r\n` with `\n` in-place ...
code_fim
hard
{ "lang": "rust", "repo": "mkurnikov/ra_vfs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.root2files[&root].iter().map(|&it| it).find(|&file| self.file(file).path == path) } fn file(&self, file: VfsFile) -> &VfsFileData { &self.files[file.0 as usize] } fn file_mut(&mut self, file: VfsFile) -> &mut VfsFileData { &mut self.files[file.0 as usize] ...
code_fim
hard
{ "lang": "rust", "repo": "mkurnikov/ra_vfs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mkurnikov/ra_vfs path: /src/lib.rs ODO: Some LSP clients support watching the disk, so this crate should to //! support custom watcher events (related to //! <https://github.com/rust-analyzer/rust-analyzer/issues/131>) //! //! VFS is based on a concept of roots: a set of directories on the file ...
code_fim
hard
{ "lang": "rust", "repo": "mkurnikov/ra_vfs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Wrapping of the three arguments given to the /// ``regex_replace` and regex_replace_all` macros pub(crate) struct RexValFunArgs { pub regex_str: LitStr, pub value: Expr, pub fun: ExprClosure, } impl Parse for RexValFunArgs { fn parse(input: ParseStream<'_>) -> Result<Self> { le...
code_fim
hard
{ "lang": "rust", "repo": "korallin/lazy-regex", "path": "/src/proc_macros/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: korallin/lazy-regex path: /src/proc_macros/args.rs use { syn::{ parse::{Parse, ParseStream, Result}, Expr, ExprClosure, LitStr, Token, }, }; /// Wrapping of the two arguments given to one of the /// `regex_is_match`, `regex_find`, or `regex_captures` /// macros pub(crate...
code_fim
hard
{ "lang": "rust", "repo": "korallin/lazy-regex", "path": "/src/proc_macros/args.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twetzel59/sandbox path: /src/timing.rs //! Provides tools to manage the game's clocks //! timers, and ticks. //! //! Currently, this module just provides a simple //! clock based on the system clock. use std::time::{Duration, Instant}; /// A timing primitive that keeps track of how much /// ti...
code_fim
hard
{ "lang": "rust", "repo": "twetzel59/sandbox", "path": "/src/timing.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> elapsed } /// Reset the clock's elapsed time to /// zero, returning the time that had /// elapsed before the reset in seconds. pub fn restart_seconds(&mut self) -> f64 { dur_sec(self.restart()) } } /// Return the number of fractional seconds /// represented by the...
code_fim
hard
{ "lang": "rust", "repo": "twetzel59/sandbox", "path": "/src/timing.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: droogmic/advent2020 path: /tests/proptest_day_16.rs use advent2020::day16::{Rule, RuleStr, parse_notes}; use proptest::prelude::*; prop_compose! { fn arbitrary_rule(max: usize) (start in 0usize..max, d1 in 0usize..max, d2 in 0usize..max, d3 in 0usize..max) -> Ru...
code_fim
hard
{ "lang": "rust", "repo": "droogmic/advent2020", "path": "/tests/proptest_day_16.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>proptest! { #[test] fn rule_parse(rule_range in arbitrary_rule_range(1000)) { let rule_str = format_rule_range(0, rule_range); println!("{}", rule_str); rule_str.parse::<RuleStr>().unwrap(); } } proptest! { #![proptest_config(ProptestConfig::with_cases(1))] #[t...
code_fim
hard
{ "lang": "rust", "repo": "droogmic/advent2020", "path": "/tests/proptest_day_16.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>prop_compose! { fn arbitrary_rule_range(max: usize) (start in 0usize..max, d1 in 0usize..max, d2 in 0usize..max, d3 in 0usize..max) -> ((usize, usize), (usize, usize)) { ((start, start + d1), (start + d1 + d2, start + d1 + d2 + d3)) } } fn format_rule_range(idx...
code_fim
hard
{ "lang": "rust", "repo": "droogmic/advent2020", "path": "/tests/proptest_day_16.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[error("Fragment `{fragment_name}` not found.{suggestions}", suggestions = did_you_mean(suggestions))] FragmentNotFound { fragment_name: StringKey, suggestions: Vec<StringKey>, }, #[error("The type `{type_name}` is not an existing GraphQL type.{suggestions}", suggestions ...
code_fim
hard
{ "lang": "rust", "repo": "facebook/relay", "path": "/compiler/crates/relay-docblock/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebook/relay path: /compiler/crates/relay-docblock/src/errors.rs /* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use common::DiagnosticDisplay; use com...
code_fim
hard
{ "lang": "rust", "repo": "facebook/relay", "path": "/compiler/crates/relay-docblock/src/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[error("Unexpected non-nullable type given in `@edgeTo`.")] UnexpectedNonNullableEdgeTo, #[error("Unexpected non-nullable item in list type given in `@edgeTo`.")] UnexpectedNonNullableItemInListEdgeTo, #[error( "The type specified in the fragment (`{fragment_type_condition}`...
code_fim
hard
{ "lang": "rust", "repo": "facebook/relay", "path": "/compiler/crates/relay-docblock/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { // Desctructure `mutable_tuple` to change the value of the last element let (_, ref mut last) = mutable_tuple; *last = 4u32; } println!("{:?}", mutable_tuple); }<|fim_prefix|>// repo: sabahtalateh/rust_by_example path: /scoping/src/bin/ref_pattern.rs #[derive(Clone, ...
code_fim
hard
{ "lang": "rust", "repo": "sabahtalateh/rust_by_example", "path": "/scoping/src/bin/ref_pattern.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let point = Point { x: 3, y: 4 }; // copy_of_x and copy_of_x2 is the same let copy_of_x = { let Point { x: ref ref_to_x, y: _, } = point; *ref_to_x }; let copy_of_x2 = { let Point { x: ref_to_x, y: _ } = point; ref_to_x ...
code_fim
medium
{ "lang": "rust", "repo": "sabahtalateh/rust_by_example", "path": "/scoping/src/bin/ref_pattern.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sabahtalateh/rust_by_example path: /scoping/src/bin/ref_pattern.rs #[derive(Clone, Copy)] struct Point { x: i32, y: i32, } fn main() { let c = 'Q'; // `ref` on the left side equal to `&` on the // right side let ref ref_c1 = c; let ref_c2 = &c; println!("ref_c...
code_fim
medium
{ "lang": "rust", "repo": "sabahtalateh/rust_by_example", "path": "/scoping/src/bin/ref_pattern.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/mackerel-agent-rs path: /src/metric/filesystem.rs use super::{HostMetric, HostMetricKind, MetricValue}; use crate::Agent; use os_stat::FileSystem; impl From<Vec<FileSystem>> for HostMetric { fn from(fss: Vec<FileSystem>) -> Self { <|fim_suffix|>impl Agent { pub fn get_filesystem...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/mackerel-agent-rs", "path": "/src/metric/filesystem.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let kind = HostMetricKind::FileSystem; let mut value = MetricValue::new(); for fs in fss { value.insert(format!("filesystem.{}.size", fs.name), fs.size as f64); value.insert(format!("filesystem.{}.used", fs.name), fs.used as f64); } Self { va...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/mackerel-agent-rs", "path": "/src/metric/filesystem.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Agent { pub fn get_filesystem_metrics() -> HostMetric { let stats = FileSystem::get().expect("failed to get filesystem metrics"); stats.into() } }<|fim_prefix|>// repo: isgasho/mackerel-agent-rs path: /src/metric/filesystem.rs use super::{HostMetric, HostMetricKind, MetricVal...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/mackerel-agent-rs", "path": "/src/metric/filesystem.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn new_window(&self, dpi_factor: f32) -> Box<dyn Window> { let window = <T as Theme<DS>>::new_window(self, dpi_factor); Box::new(window) } fn update_window(&self, window: &mut dyn Window, dpi_factor: f32) { let window = window.as_any_mut().downcast_mut().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "kas-gui/kas", "path": "/crates/kas-core/src/theme/theme_dst.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kas-gui/kas path: /crates/kas-core/src/theme/theme_dst.rs // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org...
code_fim
hard
{ "lang": "rust", "repo": "kas-gui/kas", "path": "/crates/kas-core/src/theme/theme_dst.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn draw<'b>( &'b self, draw: DrawIface<'b, DS>, ev: &'b mut EventState, window: &'b mut dyn Window, ) -> Box<dyn ThemeDraw + 'b> { let window = window.as_any_mut().downcast_mut().unwrap(); Box::new(<T as Theme<DS>>::draw(self, draw, ev, window)) ...
code_fim
hard
{ "lang": "rust", "repo": "kas-gui/kas", "path": "/crates/kas-core/src/theme/theme_dst.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vgene/BoundsCheckExplorer path: /benchmarks/parity-scale-codec-1.3.5/bin/test_bc.rs use std::{convert::{TryFrom, TryInto}}; use parity_scale_codec::*; use std::time::SystemTime; use std::time::Duration; use std::io; use std::io::Write as IoWrite; fn now() -> SystemTime { return SystemTime:...
code_fim
hard
{ "lang": "rust", "repo": "vgene/BoundsCheckExplorer", "path": "/benchmarks/parity-scale-codec-1.3.5/bin/test_bc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn encode_test<T: TryFrom<u8> + Codec>(vec: &Vec<T>, n_iterations: usize) where T::Error: std::fmt::Debug{ for _ in 0..n_iterations { vec.encode(); } } #[no_mangle] #[inline(never)] fn bench<T: TryFrom<u8> + Codec>() where T::Error: std::fmt::Debug { let vec_size = 1638400; let v...
code_fim
medium
{ "lang": "rust", "repo": "vgene/BoundsCheckExplorer", "path": "/benchmarks/parity-scale-codec-1.3.5/bin/test_bc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> encode_test(&vec, n_iterations); let (total, err) = elapsed(start); if err { timing_error = true; } if timing_error { let _r = writeln!(&mut io::stderr(), "{:}", "Timing error"); } else { writeln!(&mut io::stderr(), "{:} {:} {:}.{:09}", "Iterations...
code_fim
medium
{ "lang": "rust", "repo": "vgene/BoundsCheckExplorer", "path": "/benchmarks/parity-scale-codec-1.3.5/bin/test_bc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thvdburgt/advent-of-code-2018 path: /day-12-subterranean-sustainability/tests/tests.rs extern crate advent_of_code_2018_day_12; use advent_of_code_2018_day_12::*; const INPUT_SAMPLE: &str = "\ initial state: #..#.#..##......###...### ..... => . ...## => # ..#.. => # .#... => # .#.#. => # .#.#...
code_fim
easy
{ "lang": "rust", "repo": "thvdburgt/advent-of-code-2018", "path": "/day-12-subterranean-sustainability/tests/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(solve_puzzle_part_1(INPUT_SAMPLE), 325);; }<|fim_prefix|>// repo: thvdburgt/advent-of-code-2018 path: /day-12-subterranean-sustainability/tests/tests.rs extern crate advent_of_code_2018_day_12; use advent_of_code_2018_day_12::*; const INPUT_SAMPLE: &str = "\ initial state: #..#.#..##.......
code_fim
easy
{ "lang": "rust", "repo": "thvdburgt/advent-of-code-2018", "path": "/day-12-subterranean-sustainability/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anzbert/adventOfCode path: /src/rusty16_9.rs use regex::Regex; pub fn run() { let _input = &match std::fs::read_to_string("./data/2016-puzzle9.txt") { Ok(content) => content, Err(err) => panic!("{:?}", err), }; let _test_input = "AA(8x2)(3x3)ABCEXTRA"; check_in...
code_fim
medium
{ "lang": "rust", "repo": "anzbert/adventOfCode", "path": "/src/rusty16_9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let length = output.len(); println!("input: {}\noutput: {}\nlength: {}", input, output, length); (output, length) } #[test] fn test_string1() { assert_eq!( check_input("(8x2)(3x3)ABC"), ("(3x3)ABC(3x3)ABC".to_string(), 16) ); } #[test] fn test_string2() { assert_eq...
code_fim
hard
{ "lang": "rust", "repo": "anzbert/adventOfCode", "path": "/src/rusty16_9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut elems: Vec<_> = trie.iter_prefix("foobar").collect(); elems.sort(); assert_eq!(&[&"foobar", &"foobarbaz"], &*elems); let mut elems: Vec<_> = trie.iter_prefix("foobarb").collect(); elems.sort(); assert_eq!(&[&"foobarbaz"], &*elems); let mut elems: Vec<_> = trie.iter_prefix("foobarba").coll...
code_fim
hard
{ "lang": "rust", "repo": "solb/trie-rs", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: solb/trie-rs path: /tests/tests.rs use trie::TrieSet; fn set(set: &mut TrieSet<&'static str>) { assert!(set.is_empty()); assert!(! set.contains("")); assert!(! set.contains("foobar")); assert!(set.insert("foobar")); assert!(! set.is_empty()); assert!(set.len() == 1); assert!(set.contain...
code_fim
hard
{ "lang": "rust", "repo": "solb/trie-rs", "path": "/tests/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn set_iter_prefix() { let mut trie = TrieSet::new(); set(&mut trie); let mut elems: Vec<_> = trie.iter_prefix("").collect(); elems.sort(); assert_eq!(&[&"", &"bar", &"foo", &"foobar", &"foobarbaz"], &*elems); let mut elems: Vec<_> = trie.iter_prefix("f").collect(); elems.sort(); assert_...
code_fim
hard
{ "lang": "rust", "repo": "solb/trie-rs", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<S: Into<String>, V: Into<Vec<u8>>> Into<String> for MaybeUtf8<S, V> { fn into(self) -> String { match self { MaybeUtf8::Utf8(s) => s.into(), MaybeUtf8::NotUtf8(v) => { let bytes = v.into(); match String::from_utf8_lossy(&bytes) { ...
code_fim
hard
{ "lang": "rust", "repo": "evnix/Rframe", "path": "/src/context/maybe_utf8.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evnix/Rframe path: /src/context/maybe_utf8.rs use std::ops::Deref; use std::borrow::{Cow, Borrow}; use std::hash::{Hash, Hasher}; ///An owned string that may be UTF-8 encoded. pub type MaybeUtf8Owned = MaybeUtf8<String, Vec<u8>>; ///A slice of a string that may be UTF-8 encoded. pub type MaybeU...
code_fim
hard
{ "lang": "rust", "repo": "evnix/Rframe", "path": "/src/context/maybe_utf8.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustWorks/openshift-openapi-codegen path: /src/v4_2/api/build/v1/binary_build_source.rs // Generated from definition com.github.openshift.api.build.v1.BinaryBuildSource /// BinaryBuildSource describes a binary file to be used for the Docker and Source build strategies, where the file will be ex...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/openshift-openapi-codegen", "path": "/src/v4_2/api/build/v1/binary_build_source.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> deserializer.deserialize_struct( "BinaryBuildSource", &[ "asFile", ], Visitor, ) } } impl serde::Serialize for BinaryBuildSource { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Seria...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/openshift-openapi-codegen", "path": "/src/v4_2/api/build/v1/binary_build_source.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl serde::Serialize for BinaryBuildSource { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { let mut state = serializer.serialize_struct( "BinaryBuildSource", self.as_file.as_ref().map_or(0, |_| 1), )?; if l...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/openshift-openapi-codegen", "path": "/src/v4_2/api/build/v1/binary_build_source.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitter-badger/agda-mode-1 path: /src/base.rs use serde::Deserialize; use std::fmt::{Display, Error, Formatter}; /// Modifier for interactive commands, /// specifying the amount of normalization in the output. #[derive(Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub e...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/agda-mode-1", "path": "/src/base.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn extra_brackets() { assert_eq!(check_err("func())"), "1:7: extra closing bracket \")\""); assert_eq!(check_err("{} + x]"), "1:7: extra closing bracket \"]\""); assert_eq!(check_err("{'xxx(yyy'})"), "1:12: extra closing bracket \")\""); } #[test] fn missing_br...
code_fim
hard
{ "lang": "rust", "repo": "edgedb/edgedb", "path": "/edb/edgeql-parser/tests/expr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: edgedb/edgedb path: /edb/edgeql-parser/tests/expr.rs use edgeql_parser::expr::check; #[test] fn test_valid() { check("1").unwrap(); check(" 42 ").unwrap(); check("42 # )").unwrap(); check("33 ++ 44").unwrap(); check("33 ++ '44'").unwrap(); check("(1, 2) # tuple").unwr...
code_fim
hard
{ "lang": "rust", "repo": "edgedb/edgedb", "path": "/edb/edgeql-parser/tests/expr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> tokio::signal::ctrl_c().await.unwrap(); }<|fim_prefix|>// repo: ryanpresciense/libmdns path: /examples/register.rs use env_logger; use libmdns; #[tokio::main] pub async fn main() { env_logger::init(); let responder = libmdns::Responder::builder().use_v6(false).build().unwrap(); <|fim_middl...
code_fim
medium
{ "lang": "rust", "repo": "ryanpresciense/libmdns", "path": "/examples/register.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryanpresciense/libmdns path: /examples/register.rs use env_logger; use libmdns; #[tokio::main] pub async fn main() { env_logger::init(); let responder = libmdns::Responder::builder().use_v6(false).build().unwrap(); <|fim_suffix|> tokio::signal::ctrl_c().await.unwrap(); }<|fim_middl...
code_fim
medium
{ "lang": "rust", "repo": "ryanpresciense/libmdns", "path": "/examples/register.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let client = ApiClient::new(cred, region, service); let res = client.get("DescribeInstances"); let mut output = String::new(); res.unwrap().read_to_string(&mut output); info!("{:?}", output) }<|fim_prefix|>// repo: thommay/aws-rs path: /src/bin/aws.rs extern crate aws; #[macro_use] e...
code_fim
medium
{ "lang": "rust", "repo": "thommay/aws-rs", "path": "/src/bin/aws.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thommay/aws-rs path: /src/bin/aws.rs extern crate aws; #[macro_use] extern crate log; extern crate env_logger; use aws::request::ApiClient; use aws::credentials::Credentials; use std::io::Read; <|fim_suffix|> let client = ApiClient::new(cred, region, service); let res = client.get("Desc...
code_fim
medium
{ "lang": "rust", "repo": "thommay/aws-rs", "path": "/src/bin/aws.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zdeljkic/coreutils path: /src/bin/env.rs #![deny(warnings)] extern crate coreutils; use std::env; use std::io::{stdout, stderr, Write}; <|fim_suffix|> let stdout = stdout(); let mut stdout = stdout.lock(); let mut stderr = stderr(); for (key, value) in env::vars() { st...
code_fim
medium
{ "lang": "rust", "repo": "zdeljkic/coreutils", "path": "/src/bin/env.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let stdout = stdout(); let mut stdout = stdout.lock(); let mut stderr = stderr(); for (key, value) in env::vars() { stdout.write(key.as_bytes()).try(&mut stderr); stdout.write(b"=").try(&mut stderr); stdout.writeln(value.as_bytes()).try(&mut stderr); } }<|fim_p...
code_fim
easy
{ "lang": "rust", "repo": "zdeljkic/coreutils", "path": "/src/bin/env.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> text[0..text.len() - padding_begin_index].to_string() } pub fn root_from_str(string: &String) -> [u8; 64] { if string.len() != 64 { panic!("String was not 64 bytes long.") } let mut root = [0xff; 64]; for (place, el) in root.iter_mut().zip(string.as_bytes()) { *place = *el; } ...
code_fim
hard
{ "lang": "rust", "repo": "p-v-d-Veeken/IFLS", "path": "/src/util/misc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (place, el) in root.iter_mut().zip(string.as_bytes()) { *place = *el; } root } #[cfg(test)] mod tests { use util::misc::{pad, remove_padding}; #[test] pub fn test_pad() { let max_len = 18; let msgs = vec![ String::from(""), String:...
code_fim
hard
{ "lang": "rust", "repo": "p-v-d-Veeken/IFLS", "path": "/src/util/misc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: p-v-d-Veeken/IFLS path: /src/util/misc.rs const NUM_CHARS: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; pub fn pad(text: &String, max_len: usize) -> String { let mut counter = text.len(); let mut padded_text = format!("{}", text); loop { let counter_...
code_fim
hard
{ "lang": "rust", "repo": "p-v-d-Veeken/IFLS", "path": "/src/util/misc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ret = enc_timestamp_byref(memory, resolution_ptr, resolution) .map(|_| host::__WASI_ESUCCESS) .unwrap_or_else(identity); return_enc_errno(ret) } #[wasi_common_cbindgen] pub fn clock_time_get( memory: &mut [u8], clock_id: wasm32::__wasi_clockid_t, // ignored for no...
code_fim
hard
{ "lang": "rust", "repo": "marmistrz/wasi-common", "path": "/src/hostcalls/misc.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marmistrz/wasi-common path: /src/hostcalls/misc.rs #![allow(non_camel_case_types)] use super::return_enc_errno; use crate::ctx::WasiCtx; use crate::memory::*; use crate::sys::hostcalls_impl; use crate::{host, wasm32}; use log::trace; use std::convert::{identity, TryFrom}; use wasi_common_cbindg...
code_fim
hard
{ "lang": "rust", "repo": "marmistrz/wasi-common", "path": "/src/hostcalls/misc.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JakeWharton/gitout path: /src/github.rs use std::fs::File; use std::io::copy; use std::path::PathBuf; use std::time::Duration; use std::{fs, thread}; use graphql_client::{GraphQLQuery, Response}; use reqwest::blocking::Client; use reqwest::header::ACCEPT; use serde::Deserialize; use serde::Seri...
code_fim
hard
{ "lang": "rust", "repo": "JakeWharton/gitout", "path": "/src/github.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> thread::sleep(wait); if wait < Duration::from_secs(64) { wait *= 2 } let status_url = format!("https://api.github.com/user/migrations/{0}", migration_id); let status_response: MigrationResponse = client .get(&status_url) .bearer_auth(token) .header(ACCEPT, "application/vnd.github.wy...
code_fim
hard
{ "lang": "rust", "repo": "JakeWharton/gitout", "path": "/src/github.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> starred_after = Some(repository.cursor); starred_repos.push(repository.node.name_with_owner); } for repository in watched_response { let repository = repository.unwrap(); watched_after = Some(repository.cursor); watched_repos.push(repository.node.unwrap().name_with_owner); } for gi...
code_fim
hard
{ "lang": "rust", "repo": "JakeWharton/gitout", "path": "/src/github.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lawliet89/rocket_cors path: /src/fairing.rs //! Fairing implementation #[allow(unused_imports)] use ::log::{error, info}; use rocket::http::{self, uri::Origin, Status}; use rocket::{self, error_, info_, outcome::Outcome, Request}; use crate::{ actual_request_response, origin, preflight_res...
code_fim
hard
{ "lang": "rust", "repo": "lawliet89/rocket_cors", "path": "/src/fairing.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> const CORS_ROOT: &str = "/my_cors"; fn make_cors_options() -> Cors { let allowed_origins = AllowedOrigins::some_exact(&["https://www.acme.com"]); CorsOptions { allowed_origins, allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(), ...
code_fim
hard
{ "lang": "rust", "repo": "lawliet89/rocket_cors", "path": "/src/fairing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ..Default::default() } .to_cors() .expect("Not to fail") } fn rocket(fairing: Cors) -> Rocket<rocket::Build> { Rocket::build().attach(fairing) } #[test] #[allow(non_snake_case)] fn FairingErrorRoute_returns_passed_in_status() { ...
code_fim
hard
{ "lang": "rust", "repo": "lawliet89/rocket_cors", "path": "/src/fairing.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: claucece/openmls path: /benches/benchmark.rs #[macro_use] extern crate criterion; extern crate openmls; extern crate rand; use criterion::Criterion; use openmls::prelude::*; <|fim_suffix|> for ciphersuite in Config::supported_ciphersuites() { c.bench_function( &format!( ...
code_fim
hard
{ "lang": "rust", "repo": "claucece/openmls", "path": "/benches/benchmark.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn criterion_benchmark(c: &mut Criterion) { criterion_kp_bundle(c); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches);<|fim_prefix|>// repo: claucece/openmls path: /benches/benchmark.rs #[macro_use] extern crate criterion; extern crate openmls; extern crate rand; use criter...
code_fim
hard
{ "lang": "rust", "repo": "claucece/openmls", "path": "/benches/benchmark.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut message = [0u8; 32]; let lock_size = match set_chain_flag { true => SIGNATURE_SIZE + 1, false => SIGNATURE_SIZE, }; let start_index = match set_chain_flag { true => 1, ...
code_fim
hard
{ "lang": "rust", "repo": "xcshuan/sourly_cat", "path": "/tests/src/tests/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xcshuan/sourly_cat path: /tests/src/tests/mod.rs mod hash; mod nft_create; mod nft_fighting; mod nft_transfer; use ckb_crypto::secp::Privkey; use ckb_fixed_hash::H256; use ckb_testtool::context::Context; use ckb_tool::ckb_types::{ bytes::Bytes, core::TransactionView, packed::{self, ...
code_fim
hard
{ "lang": "rust", "repo": "xcshuan/sourly_cat", "path": "/tests/src/tests/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if winner { deck1.push_back(card1); deck1.push_back(card2); } else { deck2.push_back(card2); deck2.push_back(card1); } } if deck2.is_empty() { (true, score_deck(&deck1)) } else { (false, score_deck(&deck2)...
code_fim
hard
{ "lang": "rust", "repo": "Diggsey/aoc2020", "path": "/src/bin/day22b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Diggsey/aoc2020 path: /src/bin/day22b.rs use std::collections::{HashSet, VecDeque}; const INPUT: &str = include_str!("../../inputs/day22.txt"); type Deck = VecDeque<usize>; fn parse_deck(input: &'static str) -> Deck { input.lines().skip(1).map(|l| l.parse().unwrap()).collect() } fn score...
code_fim
medium
{ "lang": "rust", "repo": "Diggsey/aoc2020", "path": "/src/bin/day22b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qinsoon/zebu path: /tests/test_runtime/test_mem_layout.rs // Copyright 2017 The Australian National University // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // /...
code_fim
hard
{ "lang": "rust", "repo": "qinsoon/zebu", "path": "/tests/test_runtime/test_mem_layout.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let array1_backend_ty = vm.get_backend_type_info(array1.id()); assert_eq!(array1_backend_ty.size, 16 * 5); } #[test] fn test_struct_layout() { let vm = Arc::new(VM::new()); typedef! ((vm) int8 = mu_int(8)); typedef! ((vm) int16 = mu_int(16)); typedef! ((vm) int32 = mu_i...
code_fim
medium
{ "lang": "rust", "repo": "qinsoon/zebu", "path": "/tests/test_runtime/test_mem_layout.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /** * This function performs a `POST` to the `/admin.emoji.remove` endpoint. * * Remove an emoji across an Enterprise Grid organization * * FROM: <https://api.slack.com/methods/admin.emoji.remove> */ pub async fn remove(&self) -> Result<crate::types::DndEndSchema> { ...
code_fim
hard
{ "lang": "rust", "repo": "vaibhavantil2/third-party-api-clients", "path": "/slack/src/admin_emoji.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vaibhavantil2/third-party-api-clients path: /slack/src/admin_emoji.rs use anyhow::Result; use crate::Client; pub struct AdminEmoji { pub client: Client, } impl AdminEmoji { #[doc(hidden)] pub fn new(client: Client) -> Self { AdminEmoji { client } } /** * This...
code_fim
hard
{ "lang": "rust", "repo": "vaibhavantil2/third-party-api-clients", "path": "/slack/src/admin_emoji.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(non_snake_case)] let ($($C,)*) = self.color_attachments; RenderTargetDescriptor { color_attachments: ($($C,)* IntegerAttachment { image, load_op, store_op ...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/rendering/render_target.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/rendering/render_target.rs let $C = $C.encode_color_buffer(&mut context); width = cmp::min(width, $C.image.width); height = cmp::min(height, $C.image.height); let $C = { ...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/rendering/render_target.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> color_count += 1; )* render_target.color_count = color_count; let task = f(&Framebuffer { color: ($C0, $($C,)*), depth_stencil: (), pipeline_target: GraphicsPipelineTarget { ...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/rendering/render_target.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn no_explicit_any_valid() { assert_lint_ok! { NoExplicitAny, r#" class Foo { static _extensions: { // deno-lint-ignore no-explicit-any [key: string]: (module: Module, filename: string) => any; } = Object.create(null); }"#, ...
code_fim
hard
{ "lang": "rust", "repo": "denoland/deno_lint", "path": "/src/rules/no_explicit_any.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: denoland/deno_lint path: /src/rules/no_explicit_any.rs // Copyright 2020-2021 the Deno authors. All rights reserved. MIT license. use super::{Context, LintRule}; use crate::handler::{Handler, Traverse}; use crate::Program; use deno_ast::swc::ast::TsKeywordTypeKind::TsAnyKeyword; use deno_ast::vi...
code_fim
hard
{ "lang": "rust", "repo": "denoland/deno_lint", "path": "/src/rules/no_explicit_any.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn NotFound(error: &iron::Error) -> ::maud::Markup { html! { div.block { div.block-header { h2 "Not Found" } (Error(error)) } } } pub fn InternalServerError(error: &iron::Error) -> ::maud::Markup { html! { div.blo...
code_fim
hard
{ "lang": "rust", "repo": "Nemo157/grarr", "path": "/src/render/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nemo157/grarr path: /src/render/error.rs use iron; pub fn Error(error: &iron::Error) -> ::maud::Markup { html! { pre.block-details code (error) } } pub fn BadRequest(error: &iron::Error) -> ::maud::Markup { html! { div.block { div.block-header { ...
code_fim
hard
{ "lang": "rust", "repo": "Nemo157/grarr", "path": "/src/render/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let time = SystemTime::now() - StdDuration::from_secs(46); let humantime = HumanTime::from(time); println!("precise : '{:#}'", humantime); println!("rough : '{}'", humantime); if let Some(text) = humanize_systemtime(Some(time)) { println!("{:#}", text); } }<...
code_fim
medium
{ "lang": "rust", "repo": "imp/chrono-humanize-rs", "path": "/examples/humanize_systemtime.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imp/chrono-humanize-rs path: /examples/humanize_systemtime.rs use std::time::Duration as StdDuration; use std::time::SystemTime; // use chrono::Duration; use chrono_humanize::{HumanTime, Humanize}; <|fim_suffix|>fn main() { let time = SystemTime::now() - StdDuration::from_secs(46); le...
code_fim
medium
{ "lang": "rust", "repo": "imp/chrono-humanize-rs", "path": "/examples/humanize_systemtime.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn extend_to(&mut self, x: usize, y: usize) { while self.grid.len() <= y { self.grid.push(vec![]); } let row = self.grid.get_mut(y).unwrap(); if row.len() <= x { row.resize(x + 1, Sand); } } fn fill_with_water(&mut self) { ...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/aoc18", "path": "/src/aoc17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn count_water(&self) -> usize { let mut count = 0; for row in self.grid.iter().skip(self.y_min) { for column in row { if column == &Water || column == &DampSand { count += 1; } } } count } ...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/aoc18", "path": "/src/aoc17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joelarmstrong/aoc18 path: /src/aoc17.rs use std::collections::HashSet; use std::cmp::min; use std::io; use std::io::BufRead; use std::ops::RangeInclusive; use failure::{Error, ensure, format_err}; use regex::Regex; pub fn aoc17(part2: bool) -> Result<(), Error> { let mut reservoir = parse_v...
code_fim
hard
{ "lang": "rust", "repo": "joelarmstrong/aoc18", "path": "/src/aoc17.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn type_str(&self) -> &str { match *self.0.borrow() { Object::Function(_) => "function", Object::UserData => "userdata", Object::Thread => "thread", Object::Table(_) => "table", } } pub fn tostring(&self) -> String { ...
code_fim
hard
{ "lang": "rust", "repo": "lggruspe/silica", "path": "/src/object.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lggruspe/silica path: /src/object.rs use crate::function::Function; use crate::table::Table; use std::cell::RefCell; use std::hash::{Hash, Hasher}; use std::rc::Rc; <|fim_suffix|> pub fn tostring(&self) -> String { match *self.0.borrow() { Object::Function(_) => format!("...
code_fim
hard
{ "lang": "rust", "repo": "lggruspe/silica", "path": "/src/object.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if path.exists() { info!("file already exists, skipping"; "path" => path.to_str(), "message" => msg); Ok(()) } else { let mut f = File::create(path)?; f.write_all(contents.as_bytes())?; info!("wrote file"; "path" => path.to_str()); Ok(()) } } //...
code_fim
medium
{ "lang": "rust", "repo": "evanjs/lorri", "path": "/src/ops/init.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evanjs/lorri path: /src/ops/init.rs //! Bootstrap a new lorri project use crate::ops::error::{ok, ExitError, OpResult}; use slog_scope::info; use std::fs::File; use std::io; use std::io::Write; use std::path::Path; <|fim_suffix|> create_if_missing( Path::new("./.envrc"), def...
code_fim
hard
{ "lang": "rust", "repo": "evanjs/lorri", "path": "/src/ops/init.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> create_if_missing( Path::new("./.envrc"), default_envrc, "Please add 'eval \"$(lorri direnv)\"' to .envrc to set up lorri support.", ) .map_err(|e| ExitError::user_error(format!("{}", e)))?; info!("done"); ok() }<|fim_prefix|>// repo: evanjs/lorri path: /src/o...
code_fim
hard
{ "lang": "rust", "repo": "evanjs/lorri", "path": "/src/ops/init.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>criterion_group!(benches, bench_group); criterion_main!(benches);<|fim_prefix|>// repo: numtide/treefmt path: /benches/bench.rs use criterion::{criterion_group, criterion_main, Criterion}; use std::path::PathBuf; use treefmt::config; pub fn bench_group(c: &mut Criterion) { c.bench_function("parse co...
code_fim
easy
{ "lang": "rust", "repo": "numtide/treefmt", "path": "/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!(root.is_ok()); }) }); } criterion_group!(benches, bench_group); criterion_main!(benches);<|fim_prefix|>// repo: numtide/treefmt path: /benches/bench.rs use criterion::{criterion_group, criterion_main, Criterion}; use std::path::PathBuf; use treefmt::config; <|fim_middle|...
code_fim
hard
{ "lang": "rust", "repo": "numtide/treefmt", "path": "/benches/bench.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }