text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: cedric-h/stockRPG path: /src/dev_ui.rs inline] fn type_editor(ui: &Ui, world: &specs::World) { use specs::Join; // resources let mut compium = world.write_resource::<Compendium>(); let mut asmblgr = world.write_resource::<Assemblager>(); let ents = world.entities(); // s...
code_fim
hard
{ "lang": "rust", "repo": "cedric-h/stockRPG", "path": "/src/dev_ui.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { imgui, frame_size: imwinit::get_frame_size(window, hidpi_factor).unwrap(), } } pub fn other_input_processing(&mut self, window: &winit::Window) { imwinit::update_mouse_cursor(&self.imgui, window); self.frame_size = imwinit...
code_fim
hard
{ "lang": "rust", "repo": "cedric-h/stockRPG", "path": "/src/dev_ui.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> exec: &mut fasync::TestExecutor, reservation: &mut Reservation, done: bool, ) -> Option<Permit> { match exec.run_until_stalled(reservation) { Poll::Pending => { assert!(!done, "expected reservation to be done"); None ...
code_fim
hard
{ "lang": "rust", "repo": "yueyedeai/fuchsia", "path": "/src/connectivity/bluetooth/lib/bt-a2dp/src/permits.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yueyedeai/fuchsia path: /src/connectivity/bluetooth/lib/bt-a2dp/src/permits.rs // Copyright 2021 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. //! A construct to confirm that only a limited numbe...
code_fim
hard
{ "lang": "rust", "repo": "yueyedeai/fuchsia", "path": "/src/connectivity/bluetooth/lib/bt-a2dp/src/permits.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_part_two_example() { let input_file_path = "src/bin/tests/inputs/day_3/day_three_input_example.txt"; let input_slopes = vec![vec![1,1],vec![3,1],vec![5,1],vec![7,1],vec![1,2]]; let expected = 336; assert_eq!(execute_part_two(input_file_path, input_slopes), expected); } #[...
code_fim
medium
{ "lang": "rust", "repo": "ChuckBates/AdventOfCode2020", "path": "/src/bin/tests/day_3_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChuckBates/AdventOfCode2020 path: /src/bin/tests/day_3_tests.rs use super::*; #[test] fn test_part_one_example() { let input_file_path = "src/bin/tests/inputs/day_3/day_three_input_example.txt"; let input_slope = vec![3,1]; let expected = 7; <|fim_suffix|>#[test] fn test_parse_inpu...
code_fim
hard
{ "lang": "rust", "repo": "ChuckBates/AdventOfCode2020", "path": "/src/bin/tests/day_3_tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input_file_path = "src/bin/tests/inputs/day_3/day_three_input_example_simple.txt"; let expected = vec![vec![".","#"], vec!["#","."]]; assert_eq!(parse_input(input_file_path), expected); }<|fim_prefix|>// repo: ChuckBates/AdventOfCode2020 path: /src/bin/tests/day_3_tests.rs use super::*; ...
code_fim
hard
{ "lang": "rust", "repo": "ChuckBates/AdventOfCode2020", "path": "/src/bin/tests/day_3_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: serverlesstechnology/cqrs path: /src/test/framework.rs use crate::aggregate::Aggregate; use crate::test::AggregateTestExecutor; /// A framework for rigorously testing the aggregate logic, one of the *most important* /// parts of any DDD system. pub struct TestFramework<A: Aggregate> { servi...
code_fim
medium
{ "lang": "rust", "repo": "serverlesstechnology/cqrs", "path": "/src/test/framework.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<A> TestFramework<A> where A: Aggregate, { /// Initiates an aggregate test with no previous events. /// /// ``` /// # use cqrs_es::doc::{MyAggregate, MyService}; /// use cqrs_es::test::TestFramework; /// /// let executor = TestFramework::<MyAggregate>::with(MyService) ...
code_fim
medium
{ "lang": "rust", "repo": "serverlesstechnology/cqrs", "path": "/src/test/framework.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cberner/erasure-coding path: /benches/decode_benchmark.rs use rand::Rng; use std::time::Instant; use erasure_coding::{Encoder, Decoder, Block}; const TARGET_TOTAL_BYTES: usize = 128 * 1024 * 1024; const DATA_SHARD_COUNTS: [usize; 8] = [3, 7, 10, 30, 70, 100, 150, 200]; const REPAIR_SHARD_COUNTS...
code_fim
medium
{ "lang": "rust", "repo": "cberner/erasure-coding", "path": "/benches/decode_benchmark.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut black_box_value = 0; for (data_shards, repair_shards) in DATA_SHARD_COUNTS.iter().zip(REPAIR_SHARD_COUNTS.iter()) { let elements = data_shards * shard_size as usize; let mut data: Vec<u8> = vec![0; elements]; for i in 0..elements { data[i] = rand::thread...
code_fim
medium
{ "lang": "rust", "repo": "cberner/erasure-coding", "path": "/benches/decode_benchmark.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let iterations = TARGET_TOTAL_BYTES / elements; let encoder = Encoder::new(*data_shards as u8, *repair_shards as u8); let (data_blocks, repair) = encoder.encode(&data); let mut erased_datas = vec![]; for _ in 0..iterations { let mut erased: Vec<Option<Bl...
code_fim
hard
{ "lang": "rust", "repo": "cberner/erasure-coding", "path": "/benches/decode_benchmark.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn command_eager( engine_state: &EngineState, stack: &mut Stack, call: &Call, mut df: NuDataFrame, ) -> Result<PipelineData, ShellError> { let columns: Value = call.req(engine_state, stack, 0)?; let columns = extract_strings(columns)?; let new_names: Value = call.req(engine_st...
code_fim
hard
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nushell/nushell path: /crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, }; use crate::dataframe::...
code_fim
hard
{ "lang": "rust", "repo": "nushell/nushell", "path": "/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-cram/src/data_container/compression_header/encoding/codec/integer.rs use std::{ collections::HashMap, io::{self, Write}, }; use bytes::Buf; use crate::{ container::block, data_container::compression_header::encoding::{Decode, Encode}, huffman:...
code_fim
hard
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-cram/src/data_container/compression_header/encoding/codec/integer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } #[test] fn test_encode() -> io::Result<()> { fn t( encoding: &Encoding<Integer>, value: i32, expected_core_data: &[u8], expected_external_data: &[u8], ) -> io::Result<()> { let mut core_data_writer = ...
code_fim
hard
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-cram/src/data_container/compression_header/encoding/codec/integer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /lib/bobbin-mcu/src/clock.rs //! Traits used for modeling MCU clock networks. pub use hz::Hz; /// Marker trait indicating the item is a Clock Tree. pub trait ClockTree {} /// Trait indicating the item is a clock with output frequency `hz()`. pub trait Clock : Defaul...
code_fim
medium
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/lib/bobbin-mcu/src/clock.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Query and select the clock source for T. pub trait ClockSource<T> { fn clock_source(&self) -> T; fn set_clock_source(&self, clk: T) -> &Self; }<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /lib/bobbin-mcu/src/clock.rs //! Traits used for modeling MCU clock networks. pub use hz::Hz; /// ...
code_fim
hard
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/lib/bobbin-mcu/src/clock.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anyawal/youki path: /cgroups/src/v2/cpu.rs use anyhow::{bail, Context, Result}; use std::path::Path; use crate::{ common::{self, ControllerOpt}, stats::{CpuUsage, StatsProvider}, }; use oci_spec::runtime::LinuxCpu; use super::controller::Controller; const CGROUP_CPU_WEIGHT: &str = "c...
code_fim
hard
{ "lang": "rust", "repo": "anyawal/youki", "path": "/cgroups/src/v2/cpu.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // act Cpu::apply(&tmp, &cpu).expect("apply cpu"); // assert let content = fs::read_to_string(max) .unwrap_or_else(|_| panic!("read {} file content", CGROUP_CPU_MAX)); assert_eq!(content, format!("{} {}", QUOTA, PERIOD)); } #[test] fn test_...
code_fim
hard
{ "lang": "rust", "repo": "anyawal/youki", "path": "/cgroups/src/v2/cpu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // arrange let tmp = create_temp_dir("test_realtime_runtime_not_supported") .expect("create temp directory for test"); let cpu = LinuxCpuBuilder::default() .realtime_runtime(5) .build() .unwrap(); // act let result = ...
code_fim
hard
{ "lang": "rust", "repo": "anyawal/youki", "path": "/cgroups/src/v2/cpu.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> to_print += "\x1b[0m"; // reset colors } else { // Check for food for i in 0..2 { let fields = ( foods.get(&(2 * x + if i == 1 { 1 } else { 0 }, 2 * y)), foods.get(&(2 * x + if i...
code_fim
hard
{ "lang": "rust", "repo": "PonasKovas/multisnake", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // // OK, all the data is read and parsed - time to draw the frame draw( my_id, snakes, foods, snake_parts, my_position, world_size, head_positions, ); } Exit::Continue } /// Draws the new ...
code_fim
hard
{ "lang": "rust", "repo": "PonasKovas/multisnake", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PonasKovas/multisnake path: /src/client.rs return; } if c[0] == b'n' { break; } } } exit_input_handler.store(true, Ordering::Relaxed); j...
code_fim
hard
{ "lang": "rust", "repo": "PonasKovas/multisnake", "path": "/src/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/dnc/src/package_2021_03_15/mod.rs a request is typically finalized by invoking `.await` on"] #[doc = r" `RequestBuilder`. This implicitly invokes the [`IntoFuture::into_future()`](#method.into_future)"] #[doc = r" method, which conve...
code_fim
hard
{ "lang": "rust", "repo": "Azure/azure-sdk-for-rust", "path": "/services/mgmt/dnc/src/package_2021_03_15/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/dnc/src/package_2021_03_15/mod.rs .append_pair(azure_core::query_param::API_VERSION, "2021-03-15"); req.insert_header("content-type", "application/json"); let req_body = azure_core:...
code_fim
hard
{ "lang": "rust", "repo": "Azure/azure-sdk-for-rust", "path": "/services/mgmt/dnc/src/package_2021_03_15/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-generic-cla", "source": "the-stack-v2" }
<|fim_suffix|> let val = store.get_expr(e); let val = val.val.borrow(); match *val { ExprType::Inherit => write!(w, "{} [shape=\"box\", label=\"Inherit\"];", id), ExprType::Number { ref val } => write!(w, "{} [label=\"{}\"];", id, &val.0), ExprType::Ident { name } => { wr...
code_fim
hard
{ "lang": "rust", "repo": "mahkoh/elang", "path": "/src/util/graphviz.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mahkoh/elang path: /src/util/graphviz.rs #![allow(unused)] use crate::types::{ store::Store, tree::{ExprId, ExprType, FnParam, FnType}, }; use std::{collections::HashMap, io, io::Write}; pub fn print_tree<W: Write>(e: ExprId, store: &Store, w: &mut W) -> io::Result<()> { let mut ma...
code_fim
hard
{ "lang": "rust", "repo": "mahkoh/elang", "path": "/src/util/graphviz.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } // https://prizm.cemetech.net/index.php?title=Serial_PollTX 0x1BC0 => { debug.print("https://prizm.cemetech.net/index.php?title=Serial_PollTX"); } // https://prizm.cemetech.net/index.php?title=Serial_Read 0x1BBA => { debug.print("ht...
code_fim
hard
{ "lang": "rust", "repo": "Lol3rrr/rizm", "path": "/emulator/src/system/syscall/serial.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lol3rrr/rizm path: /emulator/src/system/syscall/serial.rs use crate::traits::Debugger; pub fn is_syscall(id: u32) -> bool { match id { 0x1BBC | 0x1BC1 | 0x1BC2 | 0x1BBD | 0x1BC0 | 0x1BBF | 0x1BBA | 0x1BB9 | 0x1BBB | 0x1BC1 | 0x1BC2 | 0x1BB8 | 0x1BC6 | 0x1BB7 | 0x1BBB | 0x1BB...
code_fim
hard
{ "lang": "rust", "repo": "Lol3rrr/rizm", "path": "/emulator/src/system/syscall/serial.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ization_response_token::VerifyAuthorizationToken; #[cfg(test)] mod tests;<|fim_prefix|>// repo: rust-chainblock/bfs path: /src/lib_blockstack/src/auth/src/v1/tokens/authorization_response_token/mod.rs mod authorization_claims; pub mod create_authorization_response_token; pub mod verify_authorization_res...
code_fim
medium
{ "lang": "rust", "repo": "rust-chainblock/bfs", "path": "/src/lib_blockstack/src/auth/src/v1/tokens/authorization_response_token/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-chainblock/bfs path: /src/lib_blockstack/src/auth/src/v1/tokens/authorization_response_token/mod.rs mod authorization_claims; pub mod create_authorization_response_token; pu<|fim_suffix|>tion_response_token::CreateAuthorizationToken; pub use self::verify_authorization_response_token::Verify...
code_fim
medium
{ "lang": "rust", "repo": "rust-chainblock/bfs", "path": "/src/lib_blockstack/src/auth/src/v1/tokens/authorization_response_token/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0x22fe/bevy_prototype_simple_net path: /src/sockets.rs use std::collections::HashMap; use super::{common::SocketId, socket::Socket}; <|fim_suffix|> pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Box<dyn Socket>> { self.sockets.values_mut() } }<|fim_middle|>#[derive(Defa...
code_fim
hard
{ "lang": "rust", "repo": "0x22fe/bevy_prototype_simple_net", "path": "/src/sockets.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get(&self, id: SocketId) -> Option<&Box<dyn Socket>> { self.sockets.get(&id) } pub fn get_mut(&mut self, id: SocketId) -> Option<&mut Box<dyn Socket>> { self.sockets.get_mut(&id) } pub fn iter(&self) -> impl Iterator<Item = &Box<dyn Socket>> { self.sock...
code_fim
hard
{ "lang": "rust", "repo": "0x22fe/bevy_prototype_simple_net", "path": "/src/sockets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_call_parent_module() { nested_module_2::child_2::function(); } }<|fim_prefix|>// repo: toyseed/rust-module-test path: /src/parent_module/nested_module_1/child_1.rs use super::super::nested_module_2; <|fim_middle|>pub fn func...
code_fim
easy
{ "lang": "rust", "repo": "toyseed/rust-module-test", "path": "/src/parent_module/nested_module_1/child_1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toyseed/rust-module-test path: /src/parent_module/nested_module_1/child_1.rs use super::super::nested_module_2; <|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_call_parent_module() { nested_module_2::child_2::function(); } }<|fim_middle|>pub fn func...
code_fim
easy
{ "lang": "rust", "repo": "toyseed/rust-module-test", "path": "/src/parent_module/nested_module_1/child_1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> nested_module_2::child_2::function(); } }<|fim_prefix|>// repo: toyseed/rust-module-test path: /src/parent_module/nested_module_1/child_1.rs use super::super::nested_module_2; pub fn function() { println!("hello child 1"); } <|fim_middle|>#[cfg(test)] mod tests { use super::*; ...
code_fim
medium
{ "lang": "rust", "repo": "toyseed/rust-module-test", "path": "/src/parent_module/nested_module_1/child_1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Playing { fn already_showing_hand(&self) -> bool { match &self.props.game { Game::Bidding(_) => false, Game::SelectingTrump(_) => false, Game::PassingCards(_) => true, Game::ReturningCards(_) => true, Game::Playing(_) => true, ...
code_fim
hard
{ "lang": "rust", "repo": "Sheyne/pinochle", "path": "/client/src/app/game_component/playing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let play_area = if let Game::Playing(game) = &self.props.game { html! { <div> <h2>{ "Play area:" }</h2> <div> { "We've taken " } { game.taken(self.props.player.team()).len() } { " cards. They've taken " } { ...
code_fim
hard
{ "lang": "rust", "repo": "Sheyne/pinochle", "path": "/client/src/app/game_component/playing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sheyne/pinochle path: /client/src/app/game_component/playing.rs use pinochle_lib::{ command::PlayingInput, game::{self, Game, Input}, Card, Player, Suit, }; use std::convert::TryInto; use std::string::ToString; use strum::IntoEnumIterator; use yew::callback::Callback; use yew::html::...
code_fim
hard
{ "lang": "rust", "repo": "Sheyne/pinochle", "path": "/client/src/app/game_component/playing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ishmamAli786/Batch435_Quarter2_Saturday path: /imran_Discovery/src/09-clocks-and-timers/src/main.rs #![no_main] #![no_std] use aux9::{entry, tim6}; #[inline(never)] fn delay(tim6: &tim6::RegisterBlock, ms: u16) { // TODO implement this // const K: u16 = 800; // this value needs to be t...
code_fim
medium
{ "lang": "rust", "repo": "ishmamAli786/Batch435_Quarter2_Saturday", "path": "/imran_Discovery/src/09-clocks-and-timers/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // TODO initialize TIM6 let ms = 50; loop { for curr in 0..8 { let next = (curr + 1) % 8; leds[next].on(); delay(tim6, ms); leds[curr].off(); delay(tim6, ms); } } }<|fim_prefix|>// repo: ishmamAli786/Batch435_Qua...
code_fim
medium
{ "lang": "rust", "repo": "ishmamAli786/Batch435_Quarter2_Saturday", "path": "/imran_Discovery/src/09-clocks-and-timers/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ludiazv/borosVpi path: /vpid/vpid/src/cmd.rs use vpi::cmd::{VpiCmd,VpiCmdOutput}; use crossbeam_channel::{Sender,Receiver}; use std::os::raw::c_int; use std::time::Duration; use crate::error::{Result,ResultExt,OptionExt,CommandParse,CommandSend,CommandRecv,JsonError}; use serde_json::Value; ///...
code_fim
hard
{ "lang": "rust", "repo": "ludiazv/borosVpi", "path": "/vpid/vpid/src/cmd.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn send_response(&self,response:String) { if let Some(bc) = &self.back_channel { let _=bc.send(response); } } pub fn send_output(&self,out:&VpiCmdOutput) { match out { VpiCmdOutput::Json(s) => self.send_response(s.to_string()), o...
code_fim
hard
{ "lang": "rust", "repo": "ludiazv/borosVpi", "path": "/vpid/vpid/src/cmd.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Implementation of VpiCommand impl VpiCommand { pub fn new(b: VpiCommandBody,bc: Option<Sender<String>> ) -> Self { Self { body: b, back_channel: bc, } } #[inline] pub fn new_nbc(b: VpiCommandBody) -> Self { Self::new(b,None) } /*...
code_fim
hard
{ "lang": "rust", "repo": "ludiazv/borosVpi", "path": "/vpid/vpid/src/cmd.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: barzilouik/flowbetween path: /animation/src/traits/motion/transform.rs use super::super::brush::*; use std::ops::Range; use std::time::Duration; <|fim_suffix|> /// /// Returns a transformed set of points at the specified time /// fn transform_points<'a, Points: 'a+Iterator<Ite...
code_fim
hard
{ "lang": "rust", "repo": "barzilouik/flowbetween", "path": "/animation/src/traits/motion/transform.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// /// Returns a transformed set of points at the specified time /// fn transform_points<'a, Points: 'a+Iterator<Item=&'a BrushPoint>>(&self, time: Duration, points: Points) -> Box<dyn 'a+Iterator<Item=BrushPoint>>; }<|fim_prefix|>// repo: barzilouik/flowbetween path: /animation/src/tra...
code_fim
hard
{ "lang": "rust", "repo": "barzilouik/flowbetween", "path": "/animation/src/traits/motion/transform.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>n 2..((k as f64).sqrt() as u32 + 1) { if k % r == 0 { return false; } } return true; }<|fim_prefix|>// repo: b4skyx/exercism_rust path: /nth-prime/src/lib.rs pub fn nth(n: u32) -> u32 { if n == 0 { return 2; } if n == 1 { return 3; } ...
code_fim
hard
{ "lang": "rust", "repo": "b4skyx/exercism_rust", "path": "/nth-prime/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: b4skyx/exercism_rust path: /nth-prime/src/lib.rs pub fn nth(n: u32) -> u32 { if n == 0 { return 2; } if n == 1 { return 3; } let mut count: u32 = 1; for r in 4..(u32::max_value()) { if is_prime(r) { count = count + 1; } <|fim...
code_fim
medium
{ "lang": "rust", "repo": "b4skyx/exercism_rust", "path": "/nth-prime/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexcarol/exercism-rust path: /hamming/src/lib.rs pub fn hamming_distance(a: &str, b: &str) -> Result<i64, i64> { if a.len() != b.len() { return Err(0) } if a == b { return Ok(0) } <|fim_suffix|> let mut distance = 0; for anth in chars_a { let bnth...
code_fim
medium
{ "lang": "rust", "repo": "alexcarol/exercism-rust", "path": "/hamming/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut distance = 0; for anth in chars_a { let bnth = chars_b.next().unwrap(); if anth != bnth { distance += 1; } } Ok(distance) }<|fim_prefix|>// repo: alexcarol/exercism-rust path: /hamming/src/lib.rs pub fn hamming_distance(a: &str, b: &str) -> Res...
code_fim
medium
{ "lang": "rust", "repo": "alexcarol/exercism-rust", "path": "/hamming/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[target_feature(enable = "avx2")] unsafe fn transpose_4x8_avx2( input: (I32X8, I32X8, I32X8, I32X8), ) -> (I32X8, I32X8, I32X8, I32X8, I32X8, I32X8, I32X8, I32X8) { let stage1 = ( // 0101 _mm256_unpacklo_epi32(input.0.vec(), input.1.vec()), _mm256_unpackhi_epi32(input.0.vec(), input.1.vec...
code_fim
hard
{ "lang": "rust", "repo": "edmond-zhu/rav1e", "path": "/src/asm/x86/transform/forward.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[target_feature(enable = "avx2")] unsafe fn transpose_4x4_avx2( input: (I32X8, I32X8, I32X8, I32X8), ) -> (I32X8, I32X8, I32X8, I32X8) { let stage1 = ( _mm256_unpacklo_epi32(input.0.vec(), input.1.vec()), _mm256_unpackhi_epi32(input.0.vec(), input.1.vec()), _mm256_unpacklo_epi32(input.2.v...
code_fim
hard
{ "lang": "rust", "repo": "edmond-zhu/rav1e", "path": "/src/asm/x86/transform/forward.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: edmond-zhu/rav1e path: /src/asm/x86/transform/forward.rs // Copyright (c) 2019, The rav1e contributors. All rights reserved // // This source code is subject to the terms of the BSD 2 Clause License and // the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License // was not dis...
code_fim
hard
{ "lang": "rust", "repo": "edmond-zhu/rav1e", "path": "/src/asm/x86/transform/forward.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn run_interruptable<T>( f: impl Future<Output = CouchbaseResult<T>>, interrupt: Arc<AtomicBool>, ) -> Result<T, ShellError> { let f_fused = f.fuse(); let ctrl_c_fut = CtrlcFuture::new(interrupt.clone()).fuse(); pin_mut!(f_fused, ctrl_c_fut); let res = select! { ...
code_fim
hard
{ "lang": "rust", "repo": "steveyen/couchbase-shell", "path": "/src/cli/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn json_list(input: &[Value]) -> Result<Vec<serde_json::Value>, ShellError> { let mut out = vec![]; for value in input { out.push(convert_nu_value_to_json_value(value)?); } Ok(out) } pub fn cluster_identifiers_from( state: &Arc<State>, args: &EvaluatedWholeStreamCommandA...
code_fim
hard
{ "lang": "rust", "repo": "steveyen/couchbase-shell", "path": "/src/cli/util.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steveyen/couchbase-shell path: /src/cli/util.rs use super::ctrlc_future::CtrlcFuture; use crate::state::{RemoteCluster, State}; use couchbase::{Collection, CouchbaseError, CouchbaseResult}; use futures::{future::FutureExt, pin_mut, select, Stream, StreamExt}; use nu_cli::{EvaluatedWholeStreamCom...
code_fim
hard
{ "lang": "rust", "repo": "steveyen/couchbase-shell", "path": "/src/cli/util.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match monster.action.action { MobAction::Idle => { if let Some((entity, _player_position)) = find_player_in_radius( (self.entities, &*players, &*world_positions).join(), *monster_position, 200.0, ...
code_fim
hard
{ "lang": "rust", "repo": "amethyst/grumpy_visitors", "path": "/libs/game/src/ecs/systems/monster/action_subsystem.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amethyst/grumpy_visitors path: /libs/game/src/ecs/systems/monster/action_subsystem.rs use amethyst::ecs::{Entities, Entity, Join, ReadExpect, ReadStorage, WriteStorage}; use gv_core::profile_scope; use gv_animation_prefabs::{AnimationId, MONSTER_BODY}; use gv_core::{ actions::{ mob:...
code_fim
hard
{ "lang": "rust", "repo": "amethyst/grumpy_visitors", "path": "/libs/game/src/ecs/systems/monster/action_subsystem.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn run_bsdiff_in<P: AsRef<Path>>(dir: P, s: &[u8], t: &[u8]) -> io::Result<Vec<u8>> { let spath = create_temp(s)?; let tpath = create_temp(t)?; let ppath = create_temp(b"")?; run_command_in( dir, "bsdiff", &[spath.as_os_str(), tpath.as_os_str(), ppath.as_os_str()], ...
code_fim
hard
{ "lang": "rust", "repo": "hucsmn/qbsdiff", "path": "/utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hucsmn/qbsdiff path: /utils/src/lib.rs sor::new(&mut p))?; Ok(p) } /// Perform qbspatch. pub fn qbspatch(&self, s: &[u8], p: &[u8]) -> io::Result<Vec<u8>> { let patcher = Bspatch::new(p)?; let mut t = Vec::with_capacity(patcher.hint_target_size() as usize); ...
code_fim
hard
{ "lang": "rust", "repo": "hucsmn/qbsdiff", "path": "/utils/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> vec![ RandomSample { name: "rand-512k", source: Random(512 * 1024), targets: vec![ Distort(0.05), Distort(0.50), Distort(0.95), ], }, RandomSample { name: "rand-4m", ...
code_fim
hard
{ "lang": "rust", "repo": "hucsmn/qbsdiff", "path": "/utils/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let target_fn = match target { "day01.1" => day01::version1, "day01.2" => day01::version2, "day02.1" => day02::version1, "day02.2" => day02::version2, "day03.1" => day03::version1, "day03.2" => day03::version2, "day04.1" => day04::version1, ...
code_fim
medium
{ "lang": "rust", "repo": "lindycoder/AdventOfCode", "path": "/y2022/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lindycoder/AdventOfCode path: /y2022/src/main.rs use std::env; mod day01; mod day02; mod day03; mod day04; mod day05; mod day06; mod day07; mod day08; fn main() { <|fim_suffix|> let target_fn = match target { "day01.1" => day01::version1, "day01.2" => day01::version2, ...
code_fim
hard
{ "lang": "rust", "repo": "lindycoder/AdventOfCode", "path": "/y2022/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let w = self.framebuffer.var_screen_info.xres as usize; let h = self.framebuffer.var_screen_info.yres as usize; let line_length = self.framebuffer.fix_screen_info.line_length as usize; let mut frame = Frame { width: w, height: h, line_len...
code_fim
hard
{ "lang": "rust", "repo": "nbrr/conifer", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> 'outer: loop { for ev in self.input_device.events_no_sync().unwrap() { let mut did_update = false; if ev._type == EV_KEY { if ev.code == BUTTON_LEFT { if ev.value == 1 { pointer.is_d...
code_fim
hard
{ "lang": "rust", "repo": "nbrr/conifer", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nbrr/conifer path: /src/lib.rs use evdev::Device; use framebuffer::{Framebuffer, KdMode}; use std::fs::OpenOptions; use std::io::Read; use std::path::Path; use std::time::Instant; const EV_KEY: u16 = 1; const EV_ABS: u16 = 3; const EV_MSC: u16 = 4; const ABS_X: u16 = 0; const ABS_Y: u16 = 1; c...
code_fim
hard
{ "lang": "rust", "repo": "nbrr/conifer", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if metadata("dist/composition.js").is_err() { assert!(Command::new("npm") .current_dir("../") .args(&["run", "compile:for-harmonizer-build-rs"]) .status() .unwrap() .success()); } }<|fim_prefix|>// repo: pampang/federation path: ...
code_fim
easy
{ "lang": "rust", "repo": "pampang/federation", "path": "/harmonizer/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pampang/federation path: /harmonizer/build.rs use std::fs::metadata; use std::process::Command; <|fim_suffix|> if metadata("dist/composition.js").is_err() { assert!(Command::new("npm") .current_dir("../") .args(&["run", "compile:for-harmonizer-build-rs"]) ...
code_fim
easy
{ "lang": "rust", "repo": "pampang/federation", "path": "/harmonizer/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ramirezmike/image_organizer path: /src/models/image_queue.rs use iced::{ Scrollable, scrollable, Length, Column, Row, Container, Element, Align, Text }; use std::{ cmp, collections::HashMap }; use crate::states::Message; use crate::util; use crate::style; #[derive(Debug)] pub stru...
code_fim
hard
{ "lang": "rust", "repo": "ramirezmike/image_organizer", "path": "/src/models/image_queue.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> r.push(Container::new(column) .width(Length::Shrink) .height(Length::Fill) .style(style)) }); let scrollable = Scrollable::new(scroll) .width...
code_fim
hard
{ "lang": "rust", "repo": "ramirezmike/image_organizer", "path": "/src/models/image_queue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joshlk/vtext path: /python/src/tokenize.rs // Copyright 2019 vtext developers // // Licensed under the Apache License, Version 2.0, // <http://apache.org/licenses/LICENSE-2.0>. This file may not be copied, // modified, or distributed except according to those terms. use pyo3::prelude::*; use py...
code_fim
hard
{ "lang": "rust", "repo": "joshlk/vtext", "path": "/python/src/tokenize.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let res: Vec<&str> = self.inner.tokenize(x).collect(); let list = PyList::new(py, res); Ok(list) } /// get_params(self, x) /// /// Get parameters for this estimator. /// /// Returns /// ------- /// params : mapping of string to any /// ...
code_fim
hard
{ "lang": "rust", "repo": "joshlk/vtext", "path": "/python/src/tokenize.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a human-readable file size (i.e. '110 MB') from an integer pub fn filesizeformat(value: Value, _: HashMap<String, Value>) -> TeraResult<Value> { let num = try_get_value!("filesizeformat", "value", i32, value); let formatted = try!( num.file_size(file_size_opts::CONVENTIONAL) ...
code_fim
hard
{ "lang": "rust", "repo": "SeiryuZ/tera", "path": "/src/filters/number.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SeiryuZ/tera path: /src/filters/number.rs /// Filters operating on numbers use std::collections::HashMap; use serde_json::value::{Value, to_value}; use humansize::{FileSize, file_size_opts}; use errors::{TeraResult, TeraError}; /// Returns a suffix if the value is greater or equal than 2. Su...
code_fim
hard
{ "lang": "rust", "repo": "SeiryuZ/tera", "path": "/src/filters/number.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: togglebyte/nightmaregl path: /examples/text.rs use nightmaregl::events::{Event, LoopAction, EventLoop}; use nightmaregl::text::{Text, WordWrap}; use nightmaregl::{Color, Context, Position, Renderer, Result, Viewport}; fn main() -> Result<()> { <|fim_suffix|> eventloop.run(move |event| { ...
code_fim
hard
{ "lang": "rust", "repo": "togglebyte/nightmaregl", "path": "/examples/text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> eventloop.run(move |event| { match event { Event::Draw(_dt) => { context.clear(Color::black()); let _ = renderer.render( &text.texture(), &text.vertex_data(), &viewport, ...
code_fim
hard
{ "lang": "rust", "repo": "togglebyte/nightmaregl", "path": "/examples/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kayazas123/OpenDP-Experimental path: /opendp/src/base/domain.rs use std::cmp::Ordering; use indexmap::map::IndexMap; use opendp_derive::{AutoFrom, AutoGet, apply_categorical, apply_numeric}; use crate::base::value::*; use crate::Error; use crate::base::functions as fun; // Ethan: Am I corre...
code_fim
hard
{ "lang": "rust", "repo": "kayazas123/OpenDP-Experimental", "path": "/opendp/src/base/domain.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// IMPLEMENTATIONS impl Interval { pub fn new(lower: Option<Scalar>, upper: Option<Scalar>) -> Result<Interval, Error> { if let (Some(l), Some(u)) = (&lower, &upper) { // TODO: check is numeric match apply_numeric!(fun::cmp, l: Scalar, u: Scalar)? { None...
code_fim
hard
{ "lang": "rust", "repo": "kayazas123/OpenDP-Experimental", "path": "/opendp/src/base/domain.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Hittable for Sphere { fn hit( &self, r: &Ray, t_min: f32, t_max: f32, rec: &mut HitRecord, ) -> bool { let oc = r.origin() - self.center; let a = Vec3::dot(&r.direction(), &r.direction()); let b = 2.0 * Vec3::dot(&oc, &r.directio...
code_fim
medium
{ "lang": "rust", "repo": "bdurrani/rust-code", "path": "/ray-tracer/src/sphere.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bdurrani/rust-code path: /ray-tracer/src/sphere.rs use crate::hittable::{HitRecord, Hittable}; use crate::ray::Ray; use crate::Vec3; pub struct Sphere { radius: f32, center: Vec3, } <|fim_suffix|>impl Hittable for Sphere { fn hit( &self, r: &Ray, t_min: f32,...
code_fim
medium
{ "lang": "rust", "repo": "bdurrani/rust-code", "path": "/ray-tracer/src/sphere.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>yerId(0); pub const OVERLAY_TOOL: OverlayLayerId = OverlayLayerId(1); pub const OVERLAY_ONIONSKINS: OverlayLayerId = OverlayLayerId(2);<|fim_prefix|>// repo: Logicalshift/flowbetween path: /flo/src/animation_canvas/overlay_layers.rs #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub struc...
code_fim
medium
{ "lang": "rust", "repo": "Logicalshift/flowbetween", "path": "/flo/src/animation_canvas/overlay_layers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Logicalshift/flowbetween path: /flo/src/animation_canvas/overlay_layers.rs #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub struct OverlayLayerId(pub u64); pub const OVERLAY_ELEMENTS: OverlayLayerId = OverlayLa<|fim_suffix|>d(1); pub const OVERLAY_ONIONSKINS: OverlayLayerId = Over...
code_fim
medium
{ "lang": "rust", "repo": "Logicalshift/flowbetween", "path": "/flo/src/animation_canvas/overlay_layers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alex6323/curl-troika-benchmark path: /src/troika_f/types.rs use std::fmt; use std::result; pub type Result<T> = result::Result<T, failure::Error>; pub(crate) type Trit = u8; #[derive(Clone, Copy)] pub(crate) struct T27 { pub p: u32, pub n: u32, } impl fmt::Debug for T27 { fn fmt(...
code_fim
hard
{ "lang": "rust", "repo": "Alex6323/curl-troika-benchmark", "path": "/src/troika_f/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl T27 { pub fn new(p: u32, n: u32) -> T27 { T27 { p: p, n: n } } //#[inline] pub fn clean(&self) -> T27 { T27::new(self.p & 0x07ffffffu32, self.n & 0x07ffffffu32) } //#[inline] pub fn add(&self, other: &T27) -> T27 { let self_zero: u32 = !self.p & !se...
code_fim
hard
{ "lang": "rust", "repo": "Alex6323/curl-troika-benchmark", "path": "/src/troika_f/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let is_wav_suffix = request_uri.ends_with(MimeType::WAV_SUFFIX); if is_wav_suffix { return MimeType::AUDIO_WAV.to_string(); } let is_m4a_suffix = request_uri.ends_with(MimeType::M4A_SUFFIX); if is_m4a_suffix { return MimeType::AUDIO_MP4.to_s...
code_fim
hard
{ "lang": "rust", "repo": "bohdaq/rust-web-server", "path": "/src/mime_type/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bohdaq/rust-web-server path: /src/mime_type/mod.rs s_with(MimeType::TXT_SUFFIX); if is_txt_suffix { return MimeType::TEXT_PLAIN.to_string(); } let is_css_suffix = request_uri.ends_with(MimeType::CSS_SUFFIX); if is_css_suffix { return MimeT...
code_fim
hard
{ "lang": "rust", "repo": "bohdaq/rust-web-server", "path": "/src/mime_type/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let is_bz_suffix = request_uri.ends_with(MimeType::BZ_SUFFIX); if is_bz_suffix { return MimeType::APPLICATION_X_BZIP.to_string(); } let is_bz2_suffix = request_uri.ends_with(MimeType::BZ2_SUFFIX); if is_bz2_suffix { return MimeType::APPLICAT...
code_fim
hard
{ "lang": "rust", "repo": "bohdaq/rust-web-server", "path": "/src/mime_type/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Issue::new(Severity::Error, IssueType::MissingName, o.id()).object_type(o.object_type()) } #[test] fn test_routes() { let gtfs = gtfs_structures::Gtfs::new("test_data/check_name").unwrap(); let issues = validate(&gtfs); let route_name_issues: Vec<_> = issues .iter() .filte...
code_fim
hard
{ "lang": "rust", "repo": "Tristramg/transport-validator", "path": "/src/validators/check_name.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tristramg/transport-validator path: /src/validators/check_name.rs use crate::validators::issues::{Issue, IssueType, Severity}; pub fn validate(gtfs: &gtfs_structures::Gtfs) -> Vec<Issue> { let route_issues = gtfs .routes .iter() .filter(|&(_, route)| !has_name(route)...
code_fim
hard
{ "lang": "rust", "repo": "Tristramg/transport-validator", "path": "/src/validators/check_name.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(1, route_name_issues.len()); assert_eq!("35", route_name_issues[0].object_id); assert_eq!(IssueType::MissingName, route_name_issues[0].issue_type); } #[test] fn test_stops() { let gtfs = gtfs_structures::Gtfs::new("test_data/check_name").unwrap(); let issues = validate(&gtf...
code_fim
hard
{ "lang": "rust", "repo": "Tristramg/transport-validator", "path": "/src/validators/check_name.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} /// Finds a field by its MCP name pub fn find_field(mcp_name: &str, class: ClassDef) -> Option<FieldDef> { let field_reg = Regex::new(FIELD_REGEX).unwrap(); let contents = SRG_FILE.to_string(); let iter: Vec<&str> = contents.split("\n").collect(); let name = format!("{}/{}", class.mcp...
code_fim
hard
{ "lang": "rust", "repo": "RoccoDev/mcp-converter", "path": "/src/parser/srg/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} /// Finds a class by its Notchian name pub fn find_class_notchian(notchian_name: &str) -> Option<ClassDef> { let class_reg = Regex::new(CLASS_REGEX).unwrap(); let contents = SRG_FILE.to_string(); let iter: Vec<&str> = contents.split("\n").collect(); for line in iter { if(!line...
code_fim
hard
{ "lang": "rust", "repo": "RoccoDev/mcp-converter", "path": "/src/parser/srg/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RoccoDev/mcp-converter path: /src/parser/srg/mod.rs use regex::Regex; use std::fs; static SRG_FILE: &'static str = include_str!("../../../resources/srg.srg"); const CLASS_REGEX: &'static str = r"CL: (.*) (.*)"; /* [Notchian name] [MCP name] */ const FIELD_REGEX: &'static str = r"FD: (.*) (.*)"...
code_fim
hard
{ "lang": "rust", "repo": "RoccoDev/mcp-converter", "path": "/src/parser/srg/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn fuels_examples() { assert_eq!(fuel_calculation(12), 2); assert_eq!(fuel_calculation(14), 2); assert_eq!(fuel_calculation(1969), 654); assert_eq!(fuel_calculation(100756), 33583); } #[test] fn fuels_part2_examples() { assert_eq!(fuel_c...
code_fim
hard
{ "lang": "rust", "repo": "bmuzika/AoC2019-rust", "path": "/day1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn fuel_calculation(mass: i32) -> i32 { let fuel = (mass/3) - 2; fuel } fn fuel_calculation_part2(mass: i32) -> i32 { let mut new_fuel: i32 = fuel_calculation(mass); let mut total: i32 = 0; while new_fuel > 0 { total += new_fuel; let old_fuel = new_fuel; new_f...
code_fim
hard
{ "lang": "rust", "repo": "bmuzika/AoC2019-rust", "path": "/day1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bmuzika/AoC2019-rust path: /day1/src/main.rs use std::fs::File; use std::io::{Read}; fn main() { let mut file = match File::open("input.txt") { Ok(file) => file, Err(_) => panic!("no file"), }; let mut file_contents = String::new(); file.read_to_string(&mut file...
code_fim
hard
{ "lang": "rust", "repo": "bmuzika/AoC2019-rust", "path": "/day1/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let exec = sandbox::executors::Function::new(Box::new(move |&:| -> i32 {0})); let mut sbox = sandbox::Sandbox::new(Box::new(exec)); sbox.spawn(); assert!(sbox.get_pid() != -1); sbox.release(ipc::signals::Signal::Cont); assert!(sbox.get_pid() == -1); }<|fim_prefix|>// repo: codius-d...
code_fim
hard
{ "lang": "rust", "repo": "codius-deprecated/codius-sandbox-core", "path": "/tests/executors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn exec_closure_with_return() { let exec = sandbox::executors::Function::new(Box::new(move |&:| -> i32 {42})); let mut sbox = sandbox::Sandbox::new(Box::new(exec)); sbox.spawn(); assert!(sbox.get_pid() != -1); loop { match sbox.tick().state { sandbox::events...
code_fim
hard
{ "lang": "rust", "repo": "codius-deprecated/codius-sandbox-core", "path": "/tests/executors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codius-deprecated/codius-sandbox-core path: /tests/executors.rs #![allow(unstable)] extern crate "codius-sandbox-core" as sandbox; extern crate "posix-ipc" as ipc; use ipc::signals; #[test] fn exec_bin_false() { let argv = ["/usr/bin/false"]; let exec = sandbox::executors::Execv::new(&a...
code_fim
hard
{ "lang": "rust", "repo": "codius-deprecated/codius-sandbox-core", "path": "/tests/executors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }