text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: helloooooo/prac-algo path: /atcoder/src/abc112c.rs use std::cmp::max; use std::collections::HashSet; fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec...
code_fim
medium
{ "lang": "rust", "repo": "helloooooo/prac-algo", "path": "/atcoder/src/abc112c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (0..n).map(|_| read_vec()).collect() } fn main() { let n = read::<usize>(); let an = read_vec2::<i64>(n as u32); let (xt, yt, ht) = { let sub = an.iter().filter(|x| x[2] >= 1).nth(0).unwrap(); (sub[0], sub[1], sub[2]) }; let mut set = HashSet::new(); for cx in 0...
code_fim
hard
{ "lang": "rust", "repo": "helloooooo/prac-algo", "path": "/atcoder/src/abc112c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FANLIYANG-OPS/rust-kubernetes path: /src/server_def/src/lib.rs pub use core_def::*; use fmt::write; use myutil::{err::*, *}; use serde::{Deserialize, Serialize}; use std::fmt; pub const OPS_ID_LEN: usize = 4; pub const DEFAULT_REQ_ID: u64 = std::u64::MAX; pub type UUID = u64; pub type ServerAdd...
code_fim
hard
{ "lang": "rust", "repo": "FANLIYANG-OPS/rust-kubernetes", "path": "/src/server_def/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(missing_docs)] #[derive(Debug, Default, Deserialize, Serialize)] pub struct RequestUpdateEnvLife { pub env_id: EnvId, pub life_time: u64, pub is_fucker: bool, } #[allow(missing_docs)] #[derive(Debug, Default, Deserialize, Serialize)] pub struct RequestUpdateEnvResource { pub env_i...
code_fim
hard
{ "lang": "rust", "repo": "FANLIYANG-OPS/rust-kubernetes", "path": "/src/server_def/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lythesia/leet path: /rs/src/quests/convert_bst_to_greater_tree.rs /** * [538] Convert BST to Greater Tree * * Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than...
code_fim
hard
{ "lang": "rust", "repo": "lythesia/leet", "path": "/rs/src/quests/convert_bst_to_greater_tree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/highway-rs path: /src/builder.rs use crate::key::Key; use crate::portable::PortableHash; use crate::traits::HighwayHash; use core::default::Default; #[cfg(target_arch = "x86_64")] use crate::avx::AvxHash; #[cfg(target_arch = "x86_64")] use crate::sse::SseHash; #[derive(Debug, Clone)] e...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/highway-rs", "path": "/src/builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(h) = SseHash::new(key) { return HighwayBuilder(HighwayChoices::Sse(h)); } } HighwayBuilder(HighwayChoices::Portable(PortableHash::new(key))) } } impl Default for HighwayBuilder { fn default() -> Self { HighwayBuilder::ne...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/highway-rs", "path": "/src/builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Translate the pattern type for MLIR let pattern = match kind { MatchKind::Value => { let expected = assert_single_argument!(self.builder, args, "value pattern"); MatchPattern::Value(expected) } MatchKind::Type(ty) => { ...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/compiler/codegen/src/mlir/builder/ops/builders/patterns.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaneutt/lumen path: /compiler/codegen/src/mlir/builder/ops/builders/patterns.rs use libeir_ir::BasicType; use super::*; pub struct IsTypeBuilder; impl IsTypeBuilder { pub fn build<'f, 'o>( builder: &mut ScopedFunctionBuilder<'f, 'o>, ir_value: Option<ir::Value>, o...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/compiler/codegen/src/mlir/builder/ops/builders/patterns.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Get match inputs let selector = self.builder.value_ref(op.selector); debug_in!(self.builder, "selector is {:?}", op.selector); let reads = op.reads.as_slice(); debug_in!(self.builder, "reads are {:?}", reads); let mut branches = Vec::with_capacity(op.bran...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/compiler/codegen/src/mlir/builder/ops/builders/patterns.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut input = String::new(); for i in 0..loop_count { std::io::stdin().read_line(&mut input); } input.split_whitespace() .map(|x| x.parse::<i32>().unwrap()) .collect() }<|fim_prefix|>// repo: Hota822/atcoder path: /lib/io/input.rs use std::io::stdin; // 中身の型を変え...
code_fim
hard
{ "lang": "rust", "repo": "Hota822/atcoder", "path": "/lib/io/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hota822/atcoder path: /lib/io/input.rs use std::io::stdin; // 中身の型を変えたいときはcheck pointを変更 fn main {} // range of using i32 // about 2 * 10^9 ~ -2 * 10^9 // ( -2,147,483,648 ~ 2,147,483,647 ) <|fim_suffix|> let mut input = String::new(); std::io::stdin().read_line(&mut input); ...
code_fim
hard
{ "lang": "rust", "repo": "Hota822/atcoder", "path": "/lib/io/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut input = String::new(); std::io::stdin().read_line(&mut input); let mut stack: [i32; 2] = [0; 2]; // check point for (i, j ) in input.split_whitespace().enumerate() { stack[i] = j.parse().unwrap(); } stack } fn get_input_by_vec() -> Vec<i32> { //checkpoint let ...
code_fim
hard
{ "lang": "rust", "repo": "Hota822/atcoder", "path": "/lib/io/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>//impl<S: Simd> A<S> { // #[dispatch(S)] // fn test(self) -> S::Vf32 { // self.0.sin() // } //} fn main() {}<|fim_prefix|>// repo: isgasho/thermite path: /examples/dispatch.rs use thermite::*; /// Test doc #[inline(always)] #[dispatch(S)] pub fn test<'a, S: Simd>(x: &'a S::Vf32) -> S::V...
code_fim
easy
{ "lang": "rust", "repo": "isgasho/thermite", "path": "/examples/dispatch.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/thermite path: /examples/dispatch.rs use thermite::*; /// Test doc #[inline(always)] #[dispatch(S)] pub fn test<'a, S: Simd>(x: &'a S::Vf32) -> S::Vf32 where S: Simd, { x.tgamma() } <|fim_suffix|>//impl<S: Simd> A<S> { // #[dispatch(S)] // fn test(self) -> S::Vf32 { // ...
code_fim
easy
{ "lang": "rust", "repo": "isgasho/thermite", "path": "/examples/dispatch.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(rocket_fuel_equation_with_inner_fuel(12), 2); assert_eq!(rocket_fuel_equation_with_inner_fuel(14), 2); assert_eq!(rocket_fuel_equation_with_inner_fuel(1969), 966); assert_eq!(rocket_fuel_equation_with_inner_fuel(100756), 50346); } }<|fim_prefix|>// repo: foo-...
code_fim
hard
{ "lang": "rust", "repo": "foo-dogsquared/advent-of-code-2019", "path": "/src/day1/part2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foo-dogsquared/advent-of-code-2019 path: /src/day1/part2.rs use std::fs; use crate::Result; pub fn main () -> Result<i64> { let mut input = fs::read_to_string("inputs/day1.txt")?; let mut total_fuel = 0; <|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn basic...
code_fim
hard
{ "lang": "rust", "repo": "foo-dogsquared/advent-of-code-2019", "path": "/src/day1/part2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn basic_example() { assert_eq!(rocket_fuel_equation_with_inner_fuel(12), 2); assert_eq!(rocket_fuel_equation_with_inner_fuel(14), 2); assert_eq!(rocket_fuel_equation_with_inner_fuel(1969), 966); assert_eq!(rocket_fuel_equation_with_inner_fuel(100756), 50346...
code_fim
hard
{ "lang": "rust", "repo": "foo-dogsquared/advent-of-code-2019", "path": "/src/day1/part2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magiclen/slash-formatter path: /src/slash.rs use alloc::{borrow::Cow, string::String}; /// Delete an ending slash in a string except for '/'. /// /// ``` /// assert_eq!("path", slash_formatter::delete_end_slash("path/")); /// ``` #[inline] pub fn delete_end_slash<S: ?Sized + AsRef<str>>(s: &S) ...
code_fim
hard
{ "lang": "rust", "repo": "magiclen/slash-formatter", "path": "/src/slash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> concat_with_slash_in_place(&mut s1, s2); s1 } /// Concatenate two strings with a slash. /// /// ``` /// let mut s = String::from("path"); /// /// slash_formatter::concat_with_slash_in_place(&mut s, "to/"); /// /// assert_eq!("path/to", s); /// ``` #[inline] pub fn concat_with_slash_in_place<S2: ...
code_fim
hard
{ "lang": "rust", "repo": "magiclen/slash-formatter", "path": "/src/slash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qianxunyuyun2019/TrojanRust path: /src/protocol/trojan/outbound.rs use std::task::{Context, Poll}; use std::io::{Result, Error, ErrorKind}; use std::pin::Pin; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf, BufWriter}; pub struct TrojanOutboundStream<IO> { stream: BufWriter<IO> } impl<IO>...
code_fim
medium
{ "lang": "rust", "repo": "qianxunyuyun2019/TrojanRust", "path": "/src/protocol/trojan/outbound.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return Pin::new(&mut self.stream).poll_flush(cx); } fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> { return Pin::new(&mut self.stream).poll_shutdown(cx); } }<|fim_prefix|>// repo: qianxunyuyun2019/TrojanRust path: /src/protocol/trojan/out...
code_fim
hard
{ "lang": "rust", "repo": "qianxunyuyun2019/TrojanRust", "path": "/src/protocol/trojan/outbound.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pace-noge/learn-from-rust-book path: /06_enums_and_pattern_matching/6_1_defining_an_enum/defining_enum.rs #[derive(Debug)] enum IpAddrKind { V4, V6, } #[derive(Debug)] struct IpAddr { kind: IpAddrKind, address: String, } fn main() { let four = IpAddrKind::V4; let six =...
code_fim
medium
{ "lang": "rust", "repo": "pace-noge/learn-from-rust-book", "path": "/06_enums_and_pattern_matching/6_1_defining_an_enum/defining_enum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Home address {:?}", home); let loopback = IpAddr { kind: six, address: String::from("::1"), }; println!("Loopback {:?}", loopback); } fn route(ip_kin: IpAddrKind) {}<|fim_prefix|>// repo: pace-noge/learn-from-rust-book path: /06_enums_and_pattern_matching/6_1_...
code_fim
medium
{ "lang": "rust", "repo": "pace-noge/learn-from-rust-book", "path": "/06_enums_and_pattern_matching/6_1_defining_an_enum/defining_enum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nlopes/actix-web-prom path: /src/lib.rs ace - `/metrics` will be auto exposed (GET requests only) with Content-Type header `content-type: text/plain; version=0.0.4; charset=utf-8` - `Some(labels)` is used to add fixed labels to the metrics; `None` can be passed instead if no additional label...
code_fim
hard
{ "lang": "rust", "repo": "nlopes/actix-web-prom", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[actix_web::test] async fn middleware_basic_failure() { let prometheus = PrometheusMetricsBuilder::new("actix_web_prom") .endpoint("/prometheus") .build() .unwrap(); let app = init_service( App::new() .wrap(prometheu...
code_fim
hard
{ "lang": "rust", "repo": "nlopes/actix-web-prom", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nlopes/actix-web-prom path: /src/lib.rs nt("/metrics") .build() .unwrap(); let counter_opts = opts!("counter", "some random counter").namespace("api"); let counter = IntCounterVec::new(counter_opts, &["endpoint", "method", "status"]).unwrap(); prometheus .reg...
code_fim
hard
{ "lang": "rust", "repo": "nlopes/actix-web-prom", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Color::RGB(252, 45, 45) } fn red() -> Color { Color::RGB(223, 0, 0) } fn light_green() -> Color { Color::RGB(45, 252, 45) } fn green() -> Color { Color::RGB(0, 223, 0) } fn light_yellow() -> Color { Color::RGB(255, 255, 170) } fn yellow() -> Color { Color::RGB(255, 255, 130) }...
code_fim
hard
{ "lang": "rust", "repo": "Davejkane/riv", "path": "/src/program/render.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn light_green() -> Color { Color::RGB(45, 252, 45) } fn green() -> Color { Color::RGB(0, 223, 0) } fn light_yellow() -> Color { Color::RGB(255, 255, 170) } fn yellow() -> Color { Color::RGB(255, 255, 130) } fn grey() -> Color { Color::RGB(52, 56, 56) } fn normal_help_text() -> Ve...
code_fim
hard
{ "lang": "rust", "repo": "Davejkane/riv", "path": "/src/program/render.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Davejkane/riv path: /src/program/render.rs const LINE_HEIGHT: i32 = 22; const LINE_PADDING: i32 = 5; struct Colors { primary: Color, secondary: Color, tertiary: Color, } impl<'a> Program<'a> { /// render_screen is the main render function that delegates rendering every thing t...
code_fim
hard
{ "lang": "rust", "repo": "Davejkane/riv", "path": "/src/program/render.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yatekii/rcache path: /firmware/src/main.rs #![no_std] #![no_main] mod bsp; pub use cortex_m; pub use cortex_m_rt; pub use embedded_hal; use nmea0183 as nmea; pub use nrf52840_hal as hal; use rtic::app; //use panic_halt as _; use nrf52840_hal::uarte::Uarte; use panic_rtt_target as _; use rtt_t...
code_fim
hard
{ "lang": "rust", "repo": "Yatekii/rcache", "path": "/firmware/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match cx.resources.UART.read(cx.resources.RX_BUFFER) { Ok(_) => { // for c in &cx.resources.RX_BUFFER[..] { // rprint!("{}", *c as char); // } for b in &cx.resources.RX_BUFFER[..] { ...
code_fim
hard
{ "lang": "rust", "repo": "Yatekii/rcache", "path": "/firmware/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let resources = init::LateResources { UART: bsp.gps_uart, RX_BUFFER: [0; 20], NMEA: nmea::Parser::new(), BUTTON: bsp.buttons.sw1, LOCK: bsp.lock, }; resources } #[idle(resources=[UART, RX_BUFFER, NMEA, BUTTON, LO...
code_fim
hard
{ "lang": "rust", "repo": "Yatekii/rcache", "path": "/firmware/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Disable adding the default bootnode to the specification. /// /// By default the `/ip4/127.0.0.1/tcp/30333/p2p/NODE_PEER_ID` bootnode is added to the /// specification when no bootnode exists. #[structopt(long = "disable-default-bootnode")] pub disable_default_bootnode: bool, #[allow(missing_d...
code_fim
hard
{ "lang": "rust", "repo": "IPSE-TEAM/ipse-core", "path": "/client/cli/src/commands/build_sync_spec_cmd.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let light_sync_state = build_light_sync_state(client)?; spec.set_light_sync_state(light_sync_state.to_serializable()); info!("Building chain spec"); let raw_output = self.raw; if spec.boot_nodes().is_empty() && !self.disable_default_bootnode { let keys = network_config.node_key.into_keypair...
code_fim
hard
{ "lang": "rust", "repo": "IPSE-TEAM/ipse-core", "path": "/client/cli/src/commands/build_sync_spec_cmd.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IPSE-TEAM/ipse-core path: /client/cli/src/commands/build_sync_spec_cmd.rs // This file is part of Substrate. // Copyright (C) 2018-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute...
code_fim
hard
{ "lang": "rust", "repo": "IPSE-TEAM/ipse-core", "path": "/client/cli/src/commands/build_sync_spec_cmd.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> *self } } impl B { #[inline] pub fn foo(&self) -> ::std::os::raw::c_uint { let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() }; unsafe { ::std::ptr::copy_nonoverlapping( &self._bitfield_1 as *const _ as *const u8, ...
code_fim
hard
{ "lang": "rust", "repo": "tsliang/rust-bindgen", "path": "/tests/expectations/tests/union_bitfield_1_0.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> { fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true } } impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {} #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct U4 { pub _bitfield_1: __BindgenU...
code_fim
hard
{ "lang": "rust", "repo": "tsliang/rust-bindgen", "path": "/tests/expectations/tests/union_bitfield_1_0.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tsliang/rust-bindgen path: /tests/expectations/tests/union_bitfield_1_0.rs /* automatically generated by rust-bindgen */ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>); impl<T> __B...
code_fim
hard
{ "lang": "rust", "repo": "tsliang/rust-bindgen", "path": "/tests/expectations/tests/union_bitfield_1_0.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eistaa/AdventOfCode2020 path: /src/day12.rs use std::convert::TryFrom; use std::fs; use std::path::Path; use std::str::FromStr; enum Action { North(i32), South(i32), West(i32), East(i32), // ----- Right(i32), Left(i32), // ----- Forward(i32), } impl TryFrom<...
code_fim
hard
{ "lang": "rust", "repo": "eistaa/AdventOfCode2020", "path": "/src/day12.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match action { Action::North(dist) => self.at.north += dist, Action::South(dist) => self.at.north -= dist, Action::West(dist) => self.at.east -= dist, Action::East(dist) => self.at.east += dist, // ----- Action::Right(deg) => ...
code_fim
hard
{ "lang": "rust", "repo": "eistaa/AdventOfCode2020", "path": "/src/day12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..i32::abs(rot / 90) { let tmp = waypoint.east; waypoint.east = -i32::signum(rot) * waypoint.north; waypoint.north = i32::signum(rot) * tmp; } waypoint } fn parse(filename: &Path) -> Result<Vec<Action>, String> { fs::read_to_string(filename) .map...
code_fim
hard
{ "lang": "rust", "repo": "eistaa/AdventOfCode2020", "path": "/src/day12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/networkfirewall/src/output.rs (input); self } pub fn set_rule_group( mut self, input: std::option::Option<crate::model::RuleGroup>, ) -> Self { self.rule_group = input; self ...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/networkfirewall/src/output.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/networkfirewall/src/output.rs cription = input; self } /// <p>An optional token that you can use for optimistic locking. Network Firewall returns a token to your requests that access the firewall. The token marks the state of the firewal...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/networkfirewall/src/output.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut formatter = f.debug_struct("DescribeFirewallPolicyOutput"); formatter.field("update_token", &self.update_token); formatter.field("firewall_policy_response", &self.firewall_policy_response); formatter.field("firewall_policy", &self.firewall_policy); formatter...
code_fim
hard
{ "lang": "rust", "repo": "mnts26/aws-sdk-rust", "path": "/sdk/networkfirewall/src/output.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let window_size = graphics::get_size(ctx); window_size.0 as f32 / 80f32 } fn get_max_velocity(ctx:&Context) ->f32{ let window_size = graphics::get_size(ctx); window_size.1 as f32 / -1.8 } } impl event::EventHandler for MainState { fn update(&mut self, ctx:...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/fallingball", "path": "/examples/ball.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/fallingball path: /examples/ball.rs extern crate ggez; extern crate fallingball; use ggez::conf; use ggez::event; use ggez::graphics; use ggez::{Context, GameResult}; use ggez::timer; use fallingball::ball::{self,Ball}; use fallingball::bar::HorizontalBar; #[derive(Debug)] struct Main...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/fallingball", "path": "/examples/ball.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MerHS/fate path: /client/src/minion.rs use glium::{VertexBuffer, Program, Frame, DrawError}; use glium::index::*; use glium::backend::Facade; use xmath::Matrix; use traits::*; use error::CreationError; pub struct Minion { vb: VertexBuffer<Vertex>, ib: NoIndices, program: Program, ...
code_fim
hard
{ "lang": "rust", "repo": "MerHS/fate", "path": "/client/src/minion.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let left_dist = (dx*dx + dy*dy).sqrt(); let speed = 50.0; let diff = speed*elapsed; if left_dist <= diff { // 도착 self.pos = dest; next = Some(State::Stopped { time: 0.0 }); ...
code_fim
hard
{ "lang": "rust", "repo": "MerHS/fate", "path": "/client/src/minion.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// 미니언을 조종하는 객체 pub struct MinionController { minions: Vec<Minion> } impl MinionController { pub fn new<F: Facade>(facade: &F) -> Result<Self, CreationError> { Ok(MinionController { minions: vec![ try!(Minion::new(facade, (17.0, 4.0))), try!(M...
code_fim
hard
{ "lang": "rust", "repo": "MerHS/fate", "path": "/client/src/minion.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dus-study/game_2048_model path: /src/lib.rs //! Game models for the game 2048 //! //! game_2048_model provide multiple game engine models for [the game 2048](https://en.wikipedia.org/wiki/2048_(video_game)) //! //! # Quick Start //! //! To get started, here is an example of how to setup a ...
code_fim
hard
{ "lang": "rust", "repo": "dus-study/game_2048_model", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> a new number //! game.slide(Directions::Up); //! game.random(&mut rng); //! ``` //! //! You can also load an existing game. //! //! ``` //! use rand::prelude::*; //! use game_2048_model::prelude::*; //! //! // Load an existing game //! let stored_game = [ //! [0, 0, 0, 0], //! [4, 0...
code_fim
hard
{ "lang": "rust", "repo": "dus-study/game_2048_model", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>, 0, 0, 2], //! [2, 8, 4, 0], //! [32, 8, 16, 4] //! ]; //! let mut game = Matrix::from(stored_game); //! //! // The player choose a direction and the game spawns a new number //! game.slide(Directions::Down); //! ``` pub mod models; mod base; pub use base::*; pub mod prelude;<|f...
code_fim
hard
{ "lang": "rust", "repo": "dus-study/game_2048_model", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: huonw/strided-rs path: /src/traits.rs use {Stride, MutStride}; use std::ops::{Deref, DerefMut}; /// Things that can be viewed as a series of equally spaced `T`s in /// memory. pub trait Strided { type Elem; fn as_stride(&self) -> Stride<Self::Elem>; fn stride(&self) -> usize { ...
code_fim
hard
{ "lang": "rust", "repo": "huonw/strided-rs", "path": "/src/traits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl<'a,T> MutStrided for MutStride<'a,T> { fn as_stride_mut(&mut self) -> MutStride<T> { self.reborrow() } } impl<'a,T, X: AsRef<[T]> + ?Sized> From<&'a X> for Stride<'a,T> { fn from(value: &X) -> Stride<T> { Stride::new(value.as_ref()) } } impl<'a,T, X: AsMut<[T]> + ?Sized> From<&'a mut X> fo...
code_fim
hard
{ "lang": "rust", "repo": "huonw/strided-rs", "path": "/src/traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frankmcsherry/timely-dataflow path: /timely/src/dataflow/operators/capture/capture.rs //! Traits and types for capturing timely dataflow streams. //! //! All timely dataflow streams can be captured, but there are many ways to capture //! these streams. A stream may be `capture_into`'d any type i...
code_fim
hard
{ "lang": "rust", "repo": "frankmcsherry/timely-dataflow", "path": "/timely/src/dataflow/operators/capture/capture.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut builder = OperatorBuilder::new("Capture".to_owned(), self.scope()); let mut input = PullCounter::new(builder.new_input(self, Pipeline)); let mut started = false; builder.build( move |progress| { if !started { // dis...
code_fim
hard
{ "lang": "rust", "repo": "frankmcsherry/timely-dataflow", "path": "/timely/src/dataflow/operators/capture/capture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Capture a stream of timestamped data for later replay. pub trait Capture<T: Timestamp, D: Data> { /// Captures a stream of timestamped data for later replay. /// /// # Examples /// /// The type `Rc<EventLink<T,D>>` implements a typed linked list, /// and can be captured into an...
code_fim
hard
{ "lang": "rust", "repo": "frankmcsherry/timely-dataflow", "path": "/timely/src/dataflow/operators/capture/capture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_print_message() { assert_eq!( get_message("hello world"), "Your message was: hello world. Welcome to rust.", ) } }<|fim_prefix|>// repo: MatthewJamesBoyle/hello-world-rust path: /src/main.rs fn main() { println!("{}", get_message("He...
code_fim
medium
{ "lang": "rust", "repo": "MatthewJamesBoyle/hello-world-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MatthewJamesBoyle/hello-world-rust path: /src/main.rs fn main() { println!("{}", get_message("Hello World")) } fn get_message(msg: &str) -> String { format!("Your message was: {}. Welcome to rust.", msg) } #[cfg(test)] mod tests { use super::*; <|fim_suffix|> assert_eq!( ...
code_fim
easy
{ "lang": "rust", "repo": "MatthewJamesBoyle/hello-world-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> format!("Your message was: {}. Welcome to rust.", msg) } #[cfg(test)] mod tests { use super::*; #[test] fn test_print_message() { assert_eq!( get_message("hello world"), "Your message was: hello world. Welcome to rust.", ) } }<|fim_prefix|>// r...
code_fim
easy
{ "lang": "rust", "repo": "MatthewJamesBoyle/hello-world-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcbrockschmidt/rust-vid-streamer path: /src/receiver/bin/main.rs extern crate ctrlc; extern crate gstreamer as gst; use gst::prelude::*; use std::{env, process}; fn usage(args: Vec<String>) { println!("Usage: {} port", args[0]); } fn create_pipeline(port: &String) -> gst::Pipeline { le...
code_fim
hard
{ "lang": "rust", "repo": "jcbrockschmidt/rust-vid-streamer", "path": "/src/receiver/bin/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn authenticate_user(req: &HttpRequest<AppState>) -> impl Future<Item = AuthUser, Error = Error> { let mem: MemExecutor = req.state().mem.clone(); let pepper = req.state().config.pepper_0.clone(); result(preprocess_authz_token(req)) .and_then(move |access_token| { access_t...
code_fim
hard
{ "lang": "rust", "repo": "colelawrence/knot", "path": "/auth/src/auth.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl FromRequest<AppState> for AuthLogin { type Config = (); type Result = Box<Future<Item = AuthLogin, Error = actix_web::Error>>; #[inline] fn from_request(req: &HttpRequest<AppState>, _cfg: &Self::Config) -> Self::Result { Box::new( authenticate_login(&req) ...
code_fim
hard
{ "lang": "rust", "repo": "colelawrence/knot", "path": "/auth/src/auth.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: colelawrence/knot path: /auth/src/auth.rs use actix_web::{FromRequest, HttpRequest}; use futures::future::{result, Future}; use std::convert::From; use super::app::AppState; use crate::mem::{models, sessions, MemExecutor}; use crate::prelude::*; use actix_web::http::header::AUTHORIZATION; cons...
code_fim
hard
{ "lang": "rust", "repo": "colelawrence/knot", "path": "/auth/src/auth.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: software-opal/thread-colors path: /src/generated/isafil_rayon_older.rs "1860", "Bisque", &[251, 216, 212], ), ThreadRef::new( BRAND, "1855", "Desert Bloom", &[253, 217, 213], ), ThreadRef::new( BRAND, "1840", ...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/thread-colors", "path": "/src/generated/isafil_rayon_older.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: software-opal/thread-colors path: /src/generated/isafil_rayon_older.rs 645", "Memphis Belle", &[242, 211, 234], ), ThreadRef::new( BRAND, "3045", "Purple", &[202, 166, 209], ), ThreadRef::new( BRAND, "2830", ...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/thread-colors", "path": "/src/generated/isafil_rayon_older.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>w( BRAND, "5766", "Dark Gray", &[59, 69, 41], ), ThreadRef::new( BRAND, "5776", "Mahogany", &[43, 52, 35], ), ThreadRef::new( BRAND, "0761", "Palest Yellow", &[222, 208, 172], ), ThreadR...
code_fim
hard
{ "lang": "rust", "repo": "software-opal/thread-colors", "path": "/src/generated/isafil_rayon_older.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makepad/makepad path: /draw/vector/src/geometry/transform.rs use crate::geometry::Transformation; /// A trait to transform geometric objects in 2-dimensional Euclidian space. pub trait Transform { fn transform<T>(self, t: &T) -> Self where T: Transformation; <|fim_suffix|> w...
code_fim
easy
{ "lang": "rust", "repo": "makepad/makepad", "path": "/draw/vector/src/geometry/transform.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn transform_mut<T>(&mut self, t: &T) where T: Transformation; }<|fim_prefix|>// repo: makepad/makepad path: /draw/vector/src/geometry/transform.rs use crate::geometry::Transformation; <|fim_middle|>/// A trait to transform geometric objects in 2-dimensional Euclidian space. pub trait Tr...
code_fim
medium
{ "lang": "rust", "repo": "makepad/makepad", "path": "/draw/vector/src/geometry/transform.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> SledIterWrapper(self.0.iter()) } } impl SledAdapter { pub fn open_temp() -> Result<Self, Error> { let tmpdir = tempfile::tempdir().unwrap(); let tmpdirpath = tmpdir.path(); Self::open(tmpdirpath) } #[allow(dead_code)] pub fn open(basedir: &std::path::...
code_fim
hard
{ "lang": "rust", "repo": "mindbeam/toboggan-kv", "path": "/src/adapter/sled.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mindbeam/toboggan-kv path: /src/adapter/sled.rs use crate::{Error, Toboggan, Tree}; #[derive(Clone)] pub struct SledAdapter { db: sled::Db, } pub struct SledStoreTree(sled::Tree); impl Toboggan for SledAdapter { type Tree = SledStoreTree; fn open_tree<V: AsRef<[u8]>>(&self, name: V)...
code_fim
hard
{ "lang": "rust", "repo": "mindbeam/toboggan-kv", "path": "/src/adapter/sled.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { self.0.next().map(|o| o.map_err(|e| e.into())) } } #[cfg(test)] mod test { use crate::{adapter::SledAdapter, tester::Tester}; #[test] fn sled() { let store = SledAdapter::open_temp().unwrap(); let tester = Tester(stor...
code_fim
hard
{ "lang": "rust", "repo": "mindbeam/toboggan-kv", "path": "/src/adapter/sled.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zoxc/rayon path: /rayon-core/src/fork/mod.rs use registry::{self, WorkerThread}; #[cfg(feature = "tlv")] use fiber::tlv; use fiber::SingleWaiterLatch; use job::{Job, JobRef}; use std::sync::atomic::{AtomicIsize, AtomicUsize, Ordering}; use std::iter; use latch::Latch; #[repr(align(64))] #[deriv...
code_fim
hard
{ "lang": "rust", "repo": "Zoxc/rayon", "path": "/rayon-core/src/fork/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn steal_half(&self) -> Option<Slice> { loop { let data = self.data.load(Ordering::SeqCst); let (start, len) = Slice::decode(data); let new_len = match len { 0 => return None, _ => 1, 1 => 1, ...
code_fim
hard
{ "lang": "rust", "repo": "Zoxc/rayon", "path": "/rayon-core/src/fork/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> why })? }, Some(Message::Text(mut payload)) => from_str(&mut payload).map(Some).map_err(|why| { warn!("Err deserializing text: {:?}; text: {}", why, payload,); why })?, Some(Message::Close(Some(frame))) => { r...
code_fim
hard
{ "lang": "rust", "repo": "serenity-rs/serenity", "path": "/src/internal/ws_impl.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: serenity-rs/serenity path: /src/internal/ws_impl.rs use std::io::Read; use async_trait::async_trait; use async_tungstenite::tungstenite::Message; use flate2::read::ZlibDecoder; use futures::{SinkExt, StreamExt}; use tokio::time::timeout; use tracing::{instrument, warn}; use url::Url; use crate...
code_fim
hard
{ "lang": "rust", "repo": "serenity-rs/serenity", "path": "/src/internal/ws_impl.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>#[instrument] pub(crate) async fn create_client(url: Url) -> Result<WsStream> { let config = async_tungstenite::tungstenite::protocol::WebSocketConfig { max_message_size: None, max_frame_size: None, max_send_queue: None, accept_unmasked_frames: false, }; let (st...
code_fim
hard
{ "lang": "rust", "repo": "serenity-rs/serenity", "path": "/src/internal/ws_impl.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn lower_case(){ assert_eq!(split_words("AbrACAdAbrA"), ["abracadabra"]); } #[test] fn split_standard_words(){ assert_eq!(split_words("one sentence. a second Sentence"), ["one", "sentence", "a", "second", "sentence"]); } #[test] fn spl...
code_fim
hard
{ "lang": "rust", "repo": "allpasscool/YishanLin.github", "path": "/Rust/hw1-Word Frequency/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // This macro helps making writing the testing more concise // https://stackoverflow.com/questions/38183551/concisely-initializing-a-vector-of-strings macro_rules! vec_of_strings { ($($x:expr),*) => (vec![$($x.to_string()),*]); } //#[test] //fn test_read_text(){ //...
code_fim
hard
{ "lang": "rust", "repo": "allpasscool/YishanLin.github", "path": "/Rust/hw1-Word Frequency/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: allpasscool/YishanLin.github path: /Rust/hw1-Word Frequency/src/main.rs /// # Word frequency calculator /// ### Some notes on this implementation: /// * Any words separated by non-alphanumerics other than hyphen(-) or apostrophe(') are split /// * This works more like a tokenizer– no dictionary ...
code_fim
hard
{ "lang": "rust", "repo": "allpasscool/YishanLin.github", "path": "/Rust/hw1-Word Frequency/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> impl_gpio!(D, GPIOD, gpioden, gpiodrst, AFRL: [PD0, 0; PD1, 1; PD2, 2; PD3, 3; PD4, 4; PD5, 5; PD6, 6; PD7, 7;], AFRH: [PD8, 8; PD9, 9; PD10, 10; PD11, 11; PD12, 12; PD13, 13; PD14, 14; PD15, 15; ] ); impl_gpio!(E, GPIOE, gpioeen, gpioerst, AFRL: [...
code_fim
medium
{ "lang": "rust", "repo": "brandonedens/stm32l4x6_hal", "path": "/src/gpio/stm32l476vg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brandonedens/stm32l4x6_hal path: /src/gpio/stm32l476vg.rs //! GPIO specific to STM32L476VG //! //! To use these definitions, enable the "STM32L476VG" feature, and include like so: //! //! ```rust //! use stm32l4x6_hal::gpio::stm32l476vg::gpio; //! ``` <|fim_suffix|>impl_parts!( GPIOD, gpioc...
code_fim
medium
{ "lang": "rust", "repo": "brandonedens/stm32l4x6_hal", "path": "/src/gpio/stm32l476vg.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: loop-revolution/task-block path: /display/description.rs use crate::blocks::{task_block::TaskBlock, text_block::TextBlock}; use block_tools::{display_api::component::misc::richtext::RichTextComponent, models::Block}; impl TaskBlock { pub fn description(description: &Option<Block>, editable: bo...
code_fim
medium
{ "lang": "rust", "repo": "loop-revolution/task-block", "path": "/display/description.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>.block_data { let content = TextBlock::data_to_display(data); if editable { return Some(TextBlock::editable_component( desc.id.to_string(), Some(content), )); } else if !content.is_empty() { return Some(RichTextComponent { content, ..Default::default() ...
code_fim
medium
{ "lang": "rust", "repo": "loop-revolution/task-block", "path": "/display/description.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tbu-/warn path: /src/lib.rs //! A simple library for warning callbacks. #![warn(missing_docs)] #[macro_use] extern crate log; use std::any::Any; use std::fmt; use std::marker::PhantomData; /// Trait for objects that can accept warnings. pub trait Warn<W> { /// This method is the receiver...
code_fim
hard
{ "lang": "rust", "repo": "tbu-/warn", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Helper struct for the `wrap` function. pub struct Wrap<WT, W: Warn<WT>> { warn: W, phantom: PhantomData<WT>, } /// Wraps a `Warn` struct so it can receive more warning types. pub fn wrap<WT, W: Warn<WT>>(warn: &mut W) -> &mut Wrap<WT, W> { unsafe { &mut *(warn as *mut _ as *mut _)...
code_fim
hard
{ "lang": "rust", "repo": "tbu-/warn", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leejw51crypto/rust-sgx-remote-attestation path: /sgx-crypto/src/tls_psk.rs use mbedtls::ssl::config::{Endpoint, Preset, Transport}; use mbedtls::ssl::{Config, Context, HandshakeContext}; use mbedtls::Result; use super::random::Rng; type Callback = Box<dyn FnMut(&mut HandshakeContext, &str) -> ...
code_fim
medium
{ "lang": "rust", "repo": "leejw51crypto/rust-sgx-remote-attestation", "path": "/sgx-crypto/src/tls_psk.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn config<'a: 'c, 'b: 'c, 'c>(rng: &'a mut Rng, callback: &'b mut Callback) -> Config<'c> { let mut config = Config::new(Endpoint::Server, Transport::Stream, Preset::Default); config.set_rng(Some(&mut rng.inner)); config.set_psk_callback(callback); config } ...
code_fim
hard
{ "lang": "rust", "repo": "leejw51crypto/rust-sgx-remote-attestation", "path": "/sgx-crypto/src/tls_psk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod client { use super::*; pub fn config<'a: 'c, 'b: 'c, 'c>(rng: &'a mut Rng, psk: &'b [u8]) -> Result<Config<'c>> { let mut config = Config::new(Endpoint::Client, Transport::Stream, Preset::Default); config.set_rng(Some(&mut rng.inner)); config.set_psk(psk, "Client_i...
code_fim
hard
{ "lang": "rust", "repo": "leejw51crypto/rust-sgx-remote-attestation", "path": "/sgx-crypto/src/tls_psk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LaineZ/adbexplorer path: /src/file_operations.rs use std::{env, fs}; use anyhow::Result; pub struct Local { working_directory: String, } pub trait FileOperations { fn get_files(&mut self) -> Result<Vec<String>>; fn change_directory_rel(&mut self, path: &str); fn level_up_files(...
code_fim
hard
{ "lang": "rust", "repo": "LaineZ/adbexplorer", "path": "/src/file_operations.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl FileOperations for Local { fn get_files(&mut self) -> Result<Vec<String>> { log::info!("Going to: {}", self.get_working_directory()); let paths = fs::read_dir(self.get_working_directory())?; let mut files = Vec::new(); for path in paths { let path_valu...
code_fim
medium
{ "lang": "rust", "repo": "LaineZ/adbexplorer", "path": "/src/file_operations.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn should_load_files_recursively() { let result = load_file_recursively(&root().join("resources/nested_file_includes/normal/start.txt")); let expectation = String::from_str(indoc! {r##" START LEVEL-1 LEVEL-2 ...
code_fim
hard
{ "lang": "rust", "repo": "Leopard2A5/fhttp", "path": "/fhttp-core/src/request_sources/file_includes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_ok!(result, expectation); } #[test] fn should_detect_cyclic_dependencies() { let one = root().join("resources/nested_file_includes/cyclic_dependency/level-1.txt"); let three = root().join("resources/nested_file_includes/cyclic_dependency/level-3.txt"); l...
code_fim
hard
{ "lang": "rust", "repo": "Leopard2A5/fhttp", "path": "/fhttp-core/src/request_sources/file_includes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Leopard2A5/fhttp path: /fhttp-core/src/request_sources/file_includes.rs use std::cell::RefCell; use std::collections::HashMap; use std::fs; use std::ops::Range; use std::path::Path; use anyhow::{anyhow, Context, Result}; use itertools::Itertools; use regex::{Captures, Match}; use crate::path_u...
code_fim
hard
{ "lang": "rust", "repo": "Leopard2A5/fhttp", "path": "/fhttp-core/src/request_sources/file_includes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cmal/rust-practise-questions path: /answer/chapter_06/drop_hero/src/main.rs struct Hero { name: String } <|fim_suffix|>fn main() { let _hero = Hero { name: "Tom".to_string() }; }<|fim_middle|>impl Drop for Hero { fn drop(&mut self) { println!( "O...
code_fim
medium
{ "lang": "rust", "repo": "cmal/rust-practise-questions", "path": "/answer/chapter_06/drop_hero/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let _hero = Hero { name: "Tom".to_string() }; }<|fim_prefix|>// repo: cmal/rust-practise-questions path: /answer/chapter_06/drop_hero/src/main.rs struct Hero { name: String } impl Drop for Hero { fn drop(&mut self) { <|fim_middle|> println!( "Oh no !!! Our...
code_fim
medium
{ "lang": "rust", "repo": "cmal/rust-practise-questions", "path": "/answer/chapter_06/drop_hero/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dsherret/swc path: /ecmascript/minifier/src/compress/pure/arrows.rs use super::Pure; use crate::mode::Mode; use swc_common::{util::take::Take, Spanned}; use swc_ecma_ast::*; use swc_ecma_utils::contains_this_expr; /// Methods related to the option `arrows`. impl<M> Pure<'_, M> where M: Mode...
code_fim
hard
{ "lang": "rust", "repo": "dsherret/swc", "path": "/ecmascript/minifier/src/compress/pure/arrows.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !self.options.unsafe_methods && !self.options.arrows { return; } match p { Prop::KeyValue(kv) => { // if contains_this_expr(&kv.value) { return; } match &mut *kv.value {...
code_fim
hard
{ "lang": "rust", "repo": "dsherret/swc", "path": "/ecmascript/minifier/src/compress/pure/arrows.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl RelocationType { /// Match an architecture and value to a Relocation type pub fn from(machine: Machine, type_num: u32) -> Result<RelocationType, ElfLoaderErr> { let typ = match machine { Machine::X86 => RelocationType::x86(x86::RelocationTypes::from(type_num)), ...
code_fim
hard
{ "lang": "rust", "repo": "gz/rust-elfloader", "path": "/src/arch/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }