text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> #[test] pub fn expect_no_send_keys_with_empty_panes_syscommands() { let s = "--- windows: - editor: panes: - "; let yaml = YamlLoader::load_from_str(s).unwrap(); let remains: Vec<Commands> = call( &yaml, "muxed", ...
code_fim
hard
{ "lang": "rust", "repo": "brianp/muxed", "path": "/load/src/project/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brianp/muxed path: /load/src/project/parser.rs g apart the panes. Splitting windows when needed /// and executing commands as needed. fn pane_matcher<'a, T>( window: &'a Yaml, target: &WindowTarget, common_commands: T, tmux_config: &Config, inherited_path: Option<Rc<PathBuf>>...
code_fim
hard
{ "lang": "rust", "repo": "brianp/muxed", "path": "/load/src/project/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn circ_cc() { use crate::mycroft_program::{Bar, Database, Foo, GetBazResult, GetFooResult}; let mut db = Database::new(); println!("Simple insert"); db.insert_foo(Foo { arg0: 0 }); db.run_rules(); assert_eq!(db.query_get_foo(), vec![GetFooResult { out: 3 }]); println!(...
code_fim
hard
{ "lang": "rust", "repo": "maurer/mycroft", "path": "/tests/call_cc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maurer/mycroft path: /tests/call_cc.rs use mycroft_macros::mycroft_program; fn u8_plus(xs: &[u8]) -> u8 { let mut out = 0; for x in xs { out += *x; } out } mycroft_program!( r#" Foo(u8^u8_plus) Bar(u8^u8_plus) Baz(u8^u8_plus) ?get_foo: Foo(out) ?get_baz: Baz(out) oh...
code_fim
hard
{ "lang": "rust", "repo": "maurer/mycroft", "path": "/tests/call_cc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let game_config = Config::new().unwrap_or_else(|err| { println!("Error innitialising the game: {}", err); process::exit(1); }); game_loop(game_config); }<|fim_prefix|>// repo: lpedrosa/guess_number path: /src/main.rs extern crate rand; use std::cmp::Ordering; use ...
code_fim
hard
{ "lang": "rust", "repo": "lpedrosa/guess_number", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lpedrosa/guess_number path: /src/main.rs extern crate rand; use std::cmp::Ordering; use std::io; use std::process; use rand::Rng; struct Config { secret_number: u32, top_range: u32, } impl Config { fn new() -> Result<Config, String> { println!("Choose top range"); ...
code_fim
hard
{ "lang": "rust", "repo": "lpedrosa/guess_number", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match parsed_guess.cmp(&game_config.secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break; } } } } fn main()...
code_fim
hard
{ "lang": "rust", "repo": "lpedrosa/guess_number", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn path_from_ident(ident: syn::Ident) -> syn::Expr { let mut segments: Punctuated<_, Token![::]> = Punctuated::new(); segments.push(syn::PathSegment { ident: ident, arguments: syn::PathArguments::None }); syn::Expr::Path(syn::ExprPath { attrs: Vec::new(), qself: None, path: syn::Path { leading...
code_fim
hard
{ "lang": "rust", "repo": "tylerreisinger/cache-macro", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cloned_args: &syn::ExprTuple, inner_fn_call: &syn::ExprCall) -> syn::Block { parse_quote! { { use std::cell::RefCell; use std::thread_local; thread_local!( static cache: RefCell<#full_cache_type> = Ref...
code_fim
hard
{ "lang": "rust", "repo": "tylerreisinger/cache-macro", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tylerreisinger/cache-macro path: /src/lib.rs 4 { //! println!("{:?}", x); //! if x <= 1 { //! 1 //! } else { //! fib(x - 1) + fib(x - 2) //! } //! } //! //! assert_eq!(fib(19), 6765); //! ``` //! //! The above example only calls `fib` twenty times, with the values...
code_fim
hard
{ "lang": "rust", "repo": "tylerreisinger/cache-macro", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set whether HTTP/1 connections will silently ignored malformed header lines. /// /// If this is enabled and and a header line does not start with a valid header /// name, or does not include a colon at all, the line will be silently ignored /// and no error will be reported. //...
code_fim
hard
{ "lang": "rust", "repo": "hyperium/hyper", "path": "/src/client/conn/http1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hyperium/hyper path: /src/client/conn/http1.rs h: dispatch::Sender<Request<B>, Response<IncomingBody>>, } /// Deconstructed parts of a `Connection`. /// /// This allows taking apart a `Connection` at a later time, in order to /// reclaim the IO object, and additional related pieces. #[derive(De...
code_fim
hard
{ "lang": "rust", "repo": "hyperium/hyper", "path": "/src/client/conn/http1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match ready!(Pin::new(self.inner.as_mut().unwrap()).poll(cx))? { proto::Dispatched::Shutdown => Poll::Ready(Ok(())), proto::Dispatched::Upgrade(pending) => match self.inner.take() { Some(h1) => { let (io, buf, _) = h1.into_inner(); ...
code_fim
hard
{ "lang": "rust", "repo": "hyperium/hyper", "path": "/src/client/conn/http1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>{ pub symbol: Symbol, pub input_rx_ch: broadcast::Receiver<Message>, pub output_tx_ch: broadcast::Sender<DepthData>, pub writer_tx_ch: mpsc::Sender<Message> } impl DeserializeSettings { pub fn new( symbol: Symbol, input_rx_ch: broadcast::Receiver<Message>, ...
code_fim
hard
{ "lang": "rust", "repo": "L3pereira/exchange_interface", "path": "/orderbook/gateway_in/src/settings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: L3pereira/exchange_interface path: /orderbook/gateway_in/src/settings.rs use common::{ DepthData, Symbol }; use tokio_tungstenite::{ tungstenite::protocol::Message, tungstenite::error::Error as WsError }; use tokio::sync::{mpsc, broadcast}; use futures_util::{ stream::{Spli...
code_fim
hard
{ "lang": "rust", "repo": "L3pereira/exchange_interface", "path": "/orderbook/gateway_in/src/settings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbradf/edivisive-rs path: /tests/test_detect_change_points.rs use rstest::rstest; use std::{fs, path::Path}; use edivisive::EDivisive; use serde::Deserialize; #[derive(Debug, Deserialize)] struct SampleSeries { series: Vec<f64>, expected: usize, } impl SampleSeries { fn from_file(s...
code_fim
medium
{ "lang": "rust", "repo": "dbradf/edivisive-rs", "path": "/tests/test_detect_change_points.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let destination = format!("./tests/data/{}.json", series_name); let path = Path::new(&destination); let contents = fs::read_to_string(path).expect("Count not read file"); serde_json::from_str(&contents).expect("Count not parse JSON") } } #[rstest(sample_series, c...
code_fim
medium
{ "lang": "rust", "repo": "dbradf/edivisive-rs", "path": "/tests/test_detect_change_points.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/stdweb/src/webapi/event.rs use webcore::value::Reference; use webcore::try_from::TryInto; use webcore::reference_type::ReferenceType; use webapi::event_target::EventTarget; use webapi::window::Window; /// The `IEvent` interface represents any event which t...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/stdweb/src/webapi/event.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match js!( return @{self.as_ref()}.eventPhase; ).try_into().unwrap() { 0 => EventPhase::None, 1 => EventPhase::Capturing, 2 => EventPhase::AtTarget, 3 => EventPhase::Bubbling, _ => unreachable!("Unexpected EventPhase t...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/stdweb/src/webapi/event.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eloraiby/alt-std path: /src/hashmap.rs // // Based on SkTHash.h from Skia // Copyright 2019 Wael El Oraiby // Copyright 2015 Google Inc. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // ...
code_fim
hard
{ "lang": "rust", "repo": "eloraiby/alt-std", "path": "/src/hashmap.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if hash == e.hash && k == e.key { e.value = v; return; } index = self.next(index); } panic!("uncheckedSet shouldn't reach this point"); } fn newWithCap(cap: usize) -> Self { Self { table : U...
code_fim
hard
{ "lang": "rust", "repo": "eloraiby/alt-std", "path": "/src/hashmap.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..100 { let ret = hm.get(i); assert!(ret.is_some()); match ret { Some(o) => { for j in 0..i*2 { assert!((*o)[j as usize] == j) } } None => a...
code_fim
hard
{ "lang": "rust", "repo": "eloraiby/alt-std", "path": "/src/hashmap.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if mem::size_of::<T>() > 0 { deallocate(self.buf as *mut u8, (self.cap_mask as usize + 1) * mem::size_of::<T>(), mem::align_of::<T>()); } } } } unsafe impl<'a, T: Sendable+'a> _Selectable<'a> for Pac...
code_fim
hard
{ "lang": "rust", "repo": "cambricorp/comm", "path": "/src/spsc/ring_buf/imp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cambricorp/comm path: /src/spsc/ring_buf/imp.rs use std::{ptr, mem}; use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering}; use std::sync::{Mutex, Condvar}; use alloc::heap::{allocate, deallocate}; use std::cell::{Cell}; use select::{_Selectable, WaitQueue, Payload}; use alloc::{oom}; use ...
code_fim
hard
{ "lang": "rust", "repo": "cambricorp/comm", "path": "/src/spsc/ring_buf/imp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} fn is_valid(pass : &str) -> bool{ let mut double = BTreeMap::new(); let mut parsed_double = false; let mut seq = false; let mut last2 = None; let mut last = None; for char in pass.chars() { match char { 'i' | 'o' | 'l' => { return false; ...
code_fim
hard
{ "lang": "rust", "repo": "tesuji/rust_inline_bug", "path": "/src/y2015/day_11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tesuji/rust_inline_bug path: /src/y2015/day_11.rs use std::collections::BTreeMap; pub fn solve(){ const INPUT : &str = include_str!("../../inputs/2015/11"); let next = next_pass(INPUT); println!("[PART 1] Next password will be {}", next); let next = next_pass(&next); println...
code_fim
hard
{ "lang": "rust", "repo": "tesuji/rust_inline_bug", "path": "/src/y2015/day_11.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let next = chars.iter().collect::<String>(); if is_valid(&next){ return next; } } } fn inc(chars : &mut Vec<char>, index : usize){ chars[index] = (chars[index] as u8 + 1) as char; if chars[index] > 'z' { chars[index] = 'a'; inc(chars, index ...
code_fim
medium
{ "lang": "rust", "repo": "tesuji/rust_inline_bug", "path": "/src/y2015/day_11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl WormholeConnector { /** * Connect to the other side client * * This will perform the PAKE key exchange and all other necessary things to fully connect. * It returns a [`Wormhole`] struct over which you can send and receive byte messages with the other side. */ pub asy...
code_fim
hard
{ "lang": "rust", "repo": "piegamesde/magic-wormhole.rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piegamesde/magic-wormhole.rs path: /src/lib.rs //! In reality, there is no "Magic Wormhole" protocol. What makes Wormhole work is a handful of different protocols //! and handshakes, layered on another and weaved together. This allows other applications to build upon the parts they want //! and ...
code_fim
hard
{ "lang": "rust", "repo": "piegamesde/magic-wormhole.rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let server = NotificationServer::create(); let client = redis::Client::open("redis://127.0.0.1/").unwrap(); let sub = client.get_connection().unwrap(); NotificationServer::start(&server, move |notify| { let notification = Notification { name: notify.appnam...
code_fim
medium
{ "lang": "rust", "repo": "j-selby/leaffront", "path": "/dbus/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let v: String = serde_json::to_string(&notification).expect("Failed to convert notification to JSON"); let k: &str = "leaffront.notify"; redis::cmd("PUBLISH").arg(k).arg(&v).execute(&sub); }); }<|fim_prefix|>// repo: j-selby/leaffront path: /dbus/src/main.rs exter...
code_fim
hard
{ "lang": "rust", "repo": "j-selby/leaffront", "path": "/dbus/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: j-selby/leaffront path: /dbus/src/main.rs extern crate notify_rust; extern crate redis; extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; use notify_rust::server::NotificationServer; #[derive(Serialize, Deserialize)] pub struct Notification { name: Stri...
code_fim
medium
{ "lang": "rust", "repo": "j-selby/leaffront", "path": "/dbus/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parse_enum("!Delta"), Delta(TestStruct { intkey: 123, strkey: "default_value".to_string(), })); } #[test] fn test_enum_opt_struct() { assert_eq!(parse_enum("!Epsilon\nintkey: 457\nstrkey: a"), Epsilon(Some(TestStruct {...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/rust-quire", "path": "/src/validate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tailhook/rust-quire path: /src/validate.rs }; /// The trait every validator implements pub trait Validator: Debug { fn validate(&self, ast: Ast, err: &ErrorCollector) -> Ast; fn default(&self, pos: Pos) -> Option<Ast>; } /// Scalar YAML value /// /// This may be different kind of valu...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/rust-quire", "path": "/src/validate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tailhook/rust-quire path: /src/validate.rs All of the validators are configures using builder/fluent pattern. //! //! Also note that while validator can do various different transforms to the //! AST, but it works on the AST level, so it must put something that decoder //! is able to decode in t...
code_fim
hard
{ "lang": "rust", "repo": "tailhook/rust-quire", "path": "/src/validate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ramsayleung/rspotify path: /rspotify-http/src/reqwest.rs //! The client implementation for the reqwest HTTP client, which is async by //! default. use super::{BaseHttpClient, Form, Headers, Query}; use std::convert::TryInto; use std::time::Duration; use maybe_async::async_impl; use reqwest::{...
code_fim
hard
{ "lang": "rust", "repo": "ramsayleung/rspotify", "path": "/rspotify-http/src/reqwest.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Setting the headers, if any if let Some(headers) = headers { // The headers need to be converted into a `reqwest::HeaderMap`, // which won't fail as long as its contents are ASCII. This is an // internal function, so the condition cannot be broken by ...
code_fim
hard
{ "lang": "rust", "repo": "ramsayleung/rspotify", "path": "/rspotify-http/src/reqwest.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matyo91/adventofcode path: /src/day3.rs #[aoc_generator(day3)] pub fn input_generator(input: &str) -> Vec<String> { input .lines() .map(|l| String::from(l)) .collect::<Vec<String>>() } <|fim_suffix|>#[aoc(day3, part1)] pub fn solve_day3_part1(input: &Vec<String>) -> ...
code_fim
hard
{ "lang": "rust", "repo": "matyo91/adventofcode", "path": "/src/day3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[aoc(day3, part1)] pub fn solve_day3_part1(input: &Vec<String>) -> usize { solve_generic(input, 3, 1) } #[aoc(day3, part2)] pub fn solve_day3_part2(input: &Vec<String>) -> usize { solve_generic(input, 1, 1) * solve_generic(input, 3, 1) * solve_generic(input, 5, 1) * solve...
code_fim
hard
{ "lang": "rust", "repo": "matyo91/adventofcode", "path": "/src/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// The nondimensional relative Helmholtz free energy as a function of the nondimensional end-to-end length per link, parameterized by the number of links and nondimensional link stiffness. pub fn nondimensional_relative_helmholtz_free_energy(number_of_links: &u8, nondimensional_link_stiffness: &f64, non...
code_fim
hard
{ "lang": "rust", "repo": "sandialabs/Polymers", "path": "/src/physics/single_chain/efjc/thermodynamics/isometric/asymptotic/alternative/legendre/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// The implemented functionality of the thermodynamics of the EFJC model in the isometric ensemble approximated using an alternative asymptotic approach and a Legendre transformation. impl EFJC { /// Initializes and returns an instance of the thermodynamics of the EFJC model in the isometric ensem...
code_fim
hard
{ "lang": "rust", "repo": "sandialabs/Polymers", "path": "/src/physics/single_chain/efjc/thermodynamics/isometric/asymptotic/alternative/legendre/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sandialabs/Polymers path: /src/physics/single_chain/efjc/thermodynamics/isometric/asymptotic/alternative/legendre/mod.rs #[cfg(feature = "extern")] pub mod ex; #[cfg(feature = "python")] pub mod py; mod test; use std::f64::consts::PI; use crate::math:: { inverse_langevin, ...
code_fim
hard
{ "lang": "rust", "repo": "sandialabs/Polymers", "path": "/src/physics/single_chain/efjc/thermodynamics/isometric/asymptotic/alternative/legendre/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wasmerio/wasmer path: /tests/compilers/issues.rs //! This file is mainly to assure specific issues are working well use anyhow::Result; use wasmer::FunctionEnv; use wasmer::*; /// Corruption of WasmerEnv when using call indirect. /// /// Note: this one is specific to Singlepass, but we want to ...
code_fim
hard
{ "lang": "rust", "repo": "wasmerio/wasmer", "path": "/tests/compilers/issues.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let wat = r#" (module (func $popcnt_i32 (export "popcnt_i32") (param i32) (result i32) local.get 0 i32.popcnt ) (func $popcnt_i64 (export "popcnt_i64") (param i64) (result i64) local.get 0 i64.popcnt ) )"#; le...
code_fim
hard
{ "lang": "rust", "repo": "wasmerio/wasmer", "path": "/tests/compilers/issues.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Steelbirdy/poise path: /examples/framework_usage/autocomplete.rs use crate::{Context, Error}; use poise::futures::{self, Stream, StreamExt}; // Poise supports autocomplete on slash command parameters. You need to provide an autocomplete // function, which will be called on demand when the user ...
code_fim
hard
{ "lang": "rust", "repo": "Steelbirdy/poise", "path": "/examples/framework_usage/autocomplete.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>async fn autocomplete_number( _ctx: Context<'_>, _partial: u32, ) -> impl Iterator<Item = poise::AutocompleteChoice<u32>> { // Dummy choices [1_u32, 2, 3, 4, 5] .iter() .map(|&n| poise::AutocompleteChoice { name: format!( "{} (why did discord eve...
code_fim
hard
{ "lang": "rust", "repo": "Steelbirdy/poise", "path": "/examples/framework_usage/autocomplete.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvertescher/psoc6-pac path: /src/prot/smpu/ms0_ctl.rs #[doc = "Reader of register MS0_CTL"] pub type R = crate::R<u32, super::MS0_CTL>; #[doc = "Writer for register MS0_CTL"] pub type W = crate::W<u32, super::MS0_CTL>; #[doc = "Register MS0_CTL `reset()`'s with value 0x0303"] impl crate::ResetVa...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/psoc6-pac", "path": "/src/prot/smpu/ms0_ctl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> 16 - Protection context mask for protection context '0'. This field is a constant '0': - PC_MASK_0 is '0': MPU MS_CTL.PC\\[3:0\\] can NOT be set to '0' and PC\\[3:0\\] is not changed. If the protection context of the write transfer is '0', protection is not applied and PC\\[3:0\\] can be changed."] #...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/psoc6-pac", "path": "/src/prot/smpu/ms0_ctl.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> position: 0, seek: seek_tx, shared: shared, } }); (file_rx, complete_rx) } } impl audio_file2::Handler for AudioFileInternal { fn on_header(mut self, header_id: u8, header_data: &[u8], _session: &Session) -> aud...
code_fim
hard
{ "lang": "rust", "repo": "ferm10n/dansible-rust", "path": "/src/audio_file.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ferm10n/dansible-rust path: /src/audio_file.rs use bit_set::BitSet; use byteorder::{ByteOrder, BigEndian}; use eventual; use std::cmp::min; use std::sync::{Arc, Condvar, Mutex}; use std::sync::mpsc::{self, TryRecvError}; use std::fs; use std::io::{self, Read, Write, Seek, SeekFrom}; use tempfile...
code_fim
hard
{ "lang": "rust", "repo": "ferm10n/dansible-rust", "path": "/src/audio_file.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let frag = Fragment::new(msg[0], addr, timestamp, mac); println!("Got fragment! Packet type: {}", frag.packet_type); }); recv(sender)?; t.join().unwrap(); Ok(()) }<|fim_prefix|>// repo: GodOfProgramming/ltt path: /rust/tools/udp_server/src/main.rs use std::net::UdpSocket; use std::syn...
code_fim
medium
{ "lang": "rust", "repo": "GodOfProgramming/ltt", "path": "/rust/tools/udp_server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GodOfProgramming/ltt path: /rust/tools/udp_server/src/main.rs use std::net::UdpSocket; use std::sync::mpsc; use std::thread; use byteorder::{BigEndian, ReadBytesExt}; struct Fragment { packet_type: u8, address: [u8; 19], timestamp: u64, mac: [u8; 32], } impl Fragment { fn new(packet_...
code_fim
hard
{ "lang": "rust", "repo": "GodOfProgramming/ltt", "path": "/rust/tools/udp_server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pietgeursen/flumedb_rs path: /src/offset_log.rs use tokio_io::codec::Decoder; use bytes::{BytesMut}; use std::{io }; use std::mem::size_of; use std::marker::PhantomData; use byteorder::{BigEndian, ReadBytesExt}; #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct OffsetCode...
code_fim
hard
{ "lang": "rust", "repo": "pietgeursen/flumedb_rs", "path": "/src/offset_log.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut codec = OffsetCodec::<u32>::new(); let frame_bytes: &[u8] = &[0,0,0]; let result = codec.decode(&mut BytesMut::from(frame_bytes)); match result { Ok(None) => assert!(true), _ => assert!(false) } } #[test] fn errors_with_b...
code_fim
hard
{ "lang": "rust", "repo": "pietgeursen/flumedb_rs", "path": "/src/offset_log.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32wb/src/stm32wb55/flash/c2acr.rs #[doc = "Register `C2ACR` reader"] pub type R = crate::R<C2ACR_SPEC>; #[doc = "Register `C2ACR` writer"] pub type W = crate::W<C2ACR_SPEC>; #[doc = "Field `PRFTEN` reader - CPU2 cortex M0 prefetch enable"] pub type PRFTEN_R ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32wb/src/stm32wb55/flash/c2acr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>\nYou can [`read`](crate::generic::Reg::read) this register and get [`c2acr::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`c2acr::W`](W). You can also [`modify`](crate::generic:...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32wb/src/stm32wb55/flash/c2acr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Too large message can cause regression and should be rejected. let mut invalid_put = SimpleWriteEncoder::with_capacity(9 * 1024 * 1024); invalid_put.put(CF_DEFAULT, b"key", &vec![0; 8 * 1024 * 1024]); let resp = router.simple_write(2, header.clone(), invalid_put).unwrap(); assert!( ...
code_fim
hard
{ "lang": "rust", "repo": "pingyu/tikv", "path": "/components/raftstore-v2/tests/integrations/test_basic_write.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pingyu/tikv path: /components/raftstore-v2/tests/integrations/test_basic_write.rs // Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0. use std::{assert_matches::assert_matches, time::Duration}; use engine_traits::{Peekable, CF_DEFAULT}; use futures::executor::block_on; use kvprot...
code_fim
hard
{ "lang": "rust", "repo": "pingyu/tikv", "path": "/components/raftstore-v2/tests/integrations/test_basic_write.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Messenger for Event { type Target = Model; fn update( &self, target: &mut Self::Target, sender: &MessageSender<Self::Target>, render_tx: &Sender<((), oneshot::Sender<()>)>, ) -> bool { match self { Event::Request => { le...
code_fim
hard
{ "lang": "rust", "repo": "extraymond/activity_tracker", "path": "/src/elements/notification/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: extraymond/activity_tracker path: /src/elements/notification/model.rs use afterglow::prelude::*; pub struct Model { pub status: web_sys::NotificationPermission, } impl LifeCycle for Model { fn new(render_tx: Sender<((), oneshot::Sender<()>)>) -> Self { <|fim_suffix|>impl Messenger for ...
code_fim
hard
{ "lang": "rust", "repo": "extraymond/activity_tracker", "path": "/src/elements/notification/model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub enum Event { Request, GetRequest, } impl Messenger for Event { type Target = Model; fn update( &self, target: &mut Self::Target, sender: &MessageSender<Self::Target>, render_tx: &Sender<((), oneshot::Sender<()>)>, ) -> bool { match self { ...
code_fim
hard
{ "lang": "rust", "repo": "extraymond/activity_tracker", "path": "/src/elements/notification/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: guihao-liang/numeric path: /src/tensor/dot.rs use tensor::Tensor; use blas; macro_rules! add_impl { ($t:ty, $gemv:ident, $gemm:ident, $dot:ident) => ( impl Tensor<$t> { /// Takes the product of two tensors. If the tensors are both matrices (2D), then a /// ma...
code_fim
hard
{ "lang": "rust", "repo": "guihao-liang/numeric", "path": "/src/tensor/dot.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>data = t3.slice_mut(); blas::$gemm(b'N', b'N', t2.shape[1], t1.shape[0], t2.shape[0], 1.0, &t2.data, t2.shape[1], &t1.data, t2.shape[0], 0.0, data, t2.shape[1]); } t3 ...
code_fim
hard
{ "lang": "rust", "repo": "guihao-liang/numeric", "path": "/src/tensor/dot.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scotow/advent-of-code path: /2019/src/bin/day_14.rs advent_of_code_2019::main!(); fn generator(input: &str) -> HashMap<&str, (u64, Vec<(u64, &str)>)> { input .lines() .map(|l| { let mut parts = l .split([',', '=', '>']) .map(str::t...
code_fim
hard
{ "lang": "rust", "repo": "scotow/advent-of-code", "path": "/2019/src/bin/day_14.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (mut min, mut max) = (1, 1_000_000_000_000); loop { let middle = (min + max).div_ceil(&2); if solve(&receipts, middle) > 1_000_000_000_000 { max = middle - 1; } else { min = middle; } if min == max { return max; ...
code_fim
hard
{ "lang": "rust", "repo": "scotow/advent-of-code", "path": "/2019/src/bin/day_14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> solve(&receipts, 1) } fn part_2(receipts: HashMap<&str, (u64, Vec<(u64, &str)>)>) -> u64 { let (mut min, mut max) = (1, 1_000_000_000_000); loop { let middle = (min + max).div_ceil(&2); if solve(&receipts, middle) > 1_000_000_000_000 { max = middle - 1; } e...
code_fim
hard
{ "lang": "rust", "repo": "scotow/advent-of-code", "path": "/2019/src/bin/day_14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.rs // ignore-tidy-linelength // Regression test for #107745. // Previously need_type_info::update_infer_source will consider expressions originating from // macro expressions as candiate "previo...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", []); //~^ ERROR type annotations needed }<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.rs // ignore-tidy-linelength // Regression test for #107745. // Previously need_type_info::update_infer_source wil...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/ui/inference/need_type_info/issue-107745-avoid-expr-from-macro-expansion.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>llowing example shows the basics on how to build a provider, start a trace //! and handle the Event in the callback //! //! ```rust //! fn callback(record: EventRecord, schema_locator: &mut SchemaLocator) { //! //! // Within the callback we first locate the proper Schema for the event //! match sc...
code_fim
hard
{ "lang": "rust", "repo": "udbg/ferrisetw", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udbg/ferrisetw path: /src/lib.rs //! # Event Windows Tracing FTW! //! **Basically a [KrabsETW] rip-off written in Rust**, hence the name `Ferris` 🦀 //! //! All **credits** go to the team at Microsoft who develop KrabsEtw, without it, this project //! probably wouldn't be a thing. //! //! # What...
code_fim
hard
{ "lang": "rust", "repo": "udbg/ferrisetw", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Err(err) => println!("Error {:?}", err), //! }; //! } //! //! fn main() { //! // First we build a Provider //! let process_provider = Provider::new() //! .by_guid("22fb2cd6-0e7b-422b-a0c7-2fad1fd0e716") // Microsoft-Windows-Kernel-Process //! .add_callback(process_call...
code_fim
hard
{ "lang": "rust", "repo": "udbg/ferrisetw", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> macro_rules! shuffle { ($stack:expr ; $($a:ident),* => $($b:expr),*) => {{ __generate_lets!($stack; $($a),*); if let ($(Some($a)),*,) = ($($a),*,) { $($stack.push($b));* } else { return Err(Error::S...
code_fim
hard
{ "lang": "rust", "repo": "shioyama18/exercism", "path": "/rust/forth/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shioyama18/exercism path: /rust/forth/src/lib.rs use std::collections::HashMap; use std::rc::Rc; pub type Value = i64; pub type ForthResult = Result<(), Error>; pub struct Forth { stack: Vec<Value>, defns: HashMap<String, Rc<Vec<Token>>>, mode: Mode, } #[derive(Debug, PartialEq, E...
code_fim
hard
{ "lang": "rust", "repo": "shioyama18/exercism", "path": "/rust/forth/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut name = &"".into(); let mut defn = Vec::new(); for word in code { match self.mode { Mode::Name => { match *word { Token::Word(ref new_name) => { name = new_name; ...
code_fim
hard
{ "lang": "rust", "repo": "shioyama18/exercism", "path": "/rust/forth/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Loggify::init().unwrap(); error!("My error message"); warn!("My warn message"); info!("My info message"); debug!("Will not be shown"); trace!("Will not be shown"); }<|fim_prefix|>// repo: lholznagel/loggify path: /examples/01_basic.rs //! # Basic usage for the logger use log::{er...
code_fim
medium
{ "lang": "rust", "repo": "lholznagel/loggify", "path": "/examples/01_basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lholznagel/loggify path: /examples/01_basic.rs //! # Basic usage for the logger use log::{error, warn, info, debug, trace}; use loggify::Loggify; <|fim_suffix|> Loggify::init().unwrap(); error!("My error message"); warn!("My warn message"); info!("My info message"); debug!("...
code_fim
medium
{ "lang": "rust", "repo": "lholznagel/loggify", "path": "/examples/01_basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rockmenjack/AdventOfCode2018Answers path: /day11.rs use regex::Regex; use std::cmp::max; use std::fmt; use std::fs::File; use std::io::*; use std::rc::Rc; struct LineReader { buf: String, reader: BufReader<File>, } impl LineReader { pub fn new() -> Self { let file = File::o...
code_fim
hard
{ "lang": "rust", "repo": "rockmenjack/AdventOfCode2018Answers", "path": "/day11.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn part1() { //let mut r = LineReader::new(); let mut grid: Vec<i32> = vec![0; LENGTH_X * LENGTH_Y]; grid.iter_mut().enumerate().for_each(|(i, cell)| { let (x, y) = point_at(i); let p = power_level(x, y, SERIAL_NUMBER); *cell = p; }); let mut max_x = 0; le...
code_fim
hard
{ "lang": "rust", "repo": "rockmenjack/AdventOfCode2018Answers", "path": "/day11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: c-cube/batsat path: /src/batsat/src/interface.rs /* Main Interface */ use crate::{ clause::{lbool, Lit, Var}, theory::{self, Theory}, }; /// Main interface for a solver: it makes it possible to add clauses, /// allocate variables, and check for satisfiability /// /// Some functions tak...
code_fim
hard
{ "lang": "rust", "repo": "c-cube/batsat", "path": "/src/batsat/src/interface.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut solver: Solver<callbacks::Basic> = Solver::new(Default::default(), Default::default()); let a = Lit::new(solver.new_var_default(), false); let b = Lit::new(solver.new_var_default(), false); assert!(solver.add_clause_reuse(&mut vec![a, b])); asser...
code_fim
hard
{ "lang": "rust", "repo": "c-cube/batsat", "path": "/src/batsat/src/interface.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mfeckie/alpha_sparkle path: /src/main.rs use std::env; static ALPHABET: [&'static str; 26] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; fn main() { let args: Vec<_> = env::args().collect(); // If...
code_fim
hard
{ "lang": "rust", "repo": "mfeckie/alpha_sparkle", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(letter_of_alphabet("B".to_owned()), 2); } #[test] fn z_is_twenty_six() { assert_eq!(letter_of_alphabet("Z".to_owned()), 26); } #[test] fn alphabetic_test() { assert!(!not_alphabetic(Some('a'))); } #[test] fn non_alphabetic_test() { assert!(not_alphabetic(Some('^'))); } #[tes...
code_fim
hard
{ "lang": "rust", "repo": "mfeckie/alpha_sparkle", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(!not_alphabetic(Some('a'))); } #[test] fn non_alphabetic_test() { assert!(not_alphabetic(Some('^'))); } #[test] fn padding_for_b_test() { assert_eq!(internal_padding(1), 1); } #[test] fn padding_for_z_test() { assert_eq!(internal_padding(26), 51); }<|fim_prefix|>// repo: mfeckie...
code_fim
hard
{ "lang": "rust", "repo": "mfeckie/alpha_sparkle", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: callas1900/rshuffler path: /src/main.rs use structopt::StructOpt; use rand::seq::SliceRandom; #[derive(Debug, StructOpt)] #[structopt(name = "options", about = "member shuffler")] struct Opt { #[structopt(help = "input member name, such as 'ryo bruce alex'")] v: Vec<String>, } fn main()...
code_fim
medium
{ "lang": "rust", "repo": "callas1900/rshuffler", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: callas1900/rshuffler path: /src/main.rs use structopt::StructOpt; use rand::seq::SliceRandom; <|fim_suffix|> let mut opt = Opt::from_args(); let v = &mut opt.v[..]; let mut rng = rand::thread_rng(); v.shuffle(&mut rng); for e in v.iter() { println!("{}",e); } }<|...
code_fim
hard
{ "lang": "rust", "repo": "callas1900/rshuffler", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut opt = Opt::from_args(); let v = &mut opt.v[..]; let mut rng = rand::thread_rng(); v.shuffle(&mut rng); for e in v.iter() { println!("{}",e); } }<|fim_prefix|>// repo: callas1900/rshuffler path: /src/main.rs use structopt::StructOpt; use rand::seq::SliceRandom; <|...
code_fim
hard
{ "lang": "rust", "repo": "callas1900/rshuffler", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut client = BlockchainUpdatesApiClient::connect(url).await?; let request = GetBlockUpdateRequest { height }; let response = client.get_block_update(request).await?; println!("{:?}", response); Ok(()) }<|fim_prefix|>// repo: dvshur/waves-node-grpc-testing path: /src/get_block_...
code_fim
hard
{ "lang": "rust", "repo": "dvshur/waves-node-grpc-testing", "path": "/src/get_block_update.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dvshur/waves-node-grpc-testing path: /src/get_block_update.rs use std::env::var; use waves_protobuf_schemas::waves::events::grpc::blockchain_updates_api_client::BlockchainUpdatesApiClient; use waves_protobuf_schemas::waves::events::grpc::GetBlockUpdateRequest; #[tokio::main] async fn main() -> ...
code_fim
medium
{ "lang": "rust", "repo": "dvshur/waves-node-grpc-testing", "path": "/src/get_block_update.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Execute a request with the coap url. pub fn request(url: &str) -> Result<Packet> { Self::request_with_timeout(url, Some(Duration::new(DEFAULT_RECEIVE_TIMEOUT, 0))) } /// Execute a request. pub fn send(&self, packet: &Packet) -> Result<()> { match packet.to_bytes() ...
code_fim
hard
{ "lang": "rust", "repo": "jamesmunns/coap-rs", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamesmunns/coap-rs path: /src/client.rs use std::io::{Result, Error, ErrorKind}; use std::net::{ToSocketAddrs, SocketAddr, UdpSocket}; use std::time::Duration; use url::{UrlParser, SchemeType}; use num; use rand::{thread_rng, random, Rng}; use packet::{Packet, PacketType, OptionType}; const DEF...
code_fim
hard
{ "lang": "rust", "repo": "jamesmunns/coap-rs", "path": "/src/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use super::*; use std::time::Duration; use std::io::ErrorKind; use packet::Packet; use server::CoAPServer; #[test] fn test_request_error_url() { assert!(CoAPClient::request("http://127.0.0.1").is_err()); assert!(CoAPClient::request("coap...
code_fim
hard
{ "lang": "rust", "repo": "jamesmunns/coap-rs", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chrislearn/bugle path: /src/mutable.rs use crate::Receiver; pub trait Mutable<'a, D> where D: Clone + 'static, { fn new(value: D) -> Self where D: Sized; fn get(&self) -> &D; fn set(&mut self, value: D); <|fim_suffix|> where R: Receiver<Changed...
code_fim
medium
{ "lang": "rust", "repo": "chrislearn/bugle", "path": "/src/mutable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn set(&mut self, value: D); fn on_change<R>(&mut self, receiver: R) where R: Receiver<Changed<D>> + Send + 'a; // fn change_map<F, T, R>(&mut self, func: F) -> R // where // F: Fn(&D) -> T + Send + 'static, // R: Mutable<T>; } #[derive(...
code_fim
medium
{ "lang": "rust", "repo": "chrislearn/bugle", "path": "/src/mutable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn on_change<R>(&mut self, receiver: R) where R: Receiver<Changed<D>> + Send + 'a; // fn change_map<F, T, R>(&mut self, func: F) -> R // where // F: Fn(&D) -> T + Send + 'static, // R: Mutable<T>; } #[derive(Debug, Clone, Copy)] pub struct C...
code_fim
medium
{ "lang": "rust", "repo": "chrislearn/bugle", "path": "/src/mutable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>4, t_max: f64) -> Option<HitRecord>; }<|fim_prefix|>// repo: benWindsorCode/rayTracerRust path: /ray_tracer/src/traits.rs use crate::ray::Ray; use crate::hittable::HitRecord; pub trait Hittable { <|fim_middle|> fn hit(&self, ray: &Ray, t_min: f6
code_fim
easy
{ "lang": "rust", "repo": "benWindsorCode/rayTracerRust", "path": "/ray_tracer/src/traits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benWindsorCode/rayTracerRust path: /ray_tracer/src/traits.rs use crate::ray::Ray; use crate::hitta<|fim_suffix|>4, t_max: f64) -> Option<HitRecord>; }<|fim_middle|>ble::HitRecord; pub trait Hittable { fn hit(&self, ray: &Ray, t_min: f6
code_fim
medium
{ "lang": "rust", "repo": "benWindsorCode/rayTracerRust", "path": "/ray_tracer/src/traits.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for n_id in &neigbours { if let Some(n) = vertices[*n_id] { let (_, max_dist) = deformation_limits(&checker.problem, v_id, *n_id); bbox.intersect(&BBox { min_x: n.x - max_dist, max_x: n.x + max_dist, min_y: n.y - max_dist,...
code_fim
hard
{ "lang": "rust", "repo": "Vlad-Shcherbina/icfpc2021-tbd", "path": "/src/mango.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vlad-Shcherbina/icfpc2021-tbd path: /src/mango.rs #![allow(unused_imports)] #![allow(dead_code)] use crate::shake::ShakeRequest; use crate::prelude::{Pt, Problem}; use crate::graph::neighbours; use std::cmp::max; use crate::geom::{segment_in_poly, bounding_box, BBox}; use rand::prelude::SliceRa...
code_fim
hard
{ "lang": "rust", "repo": "Vlad-Shcherbina/icfpc2021-tbd", "path": "/src/mango.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nbigaouette/advent_of_code_2018 path: /day12/src/initial.rs // use std::collections::VecDeque; use slice_deque::SliceDeque; use crate::{pot_slice_to_string, Input, Note, PotState, Result}; use crate::{AoC, Day12SolutionPart1, Day12SolutionPart2}; #[derive(Debug)] pub struct Day12Initial<'a> { ...
code_fim
hard
{ "lang": "rust", "repo": "nbigaouette/advent_of_code_2018", "path": "/day12/src/initial.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let to_check = solution_part1(input, 1).unwrap(); let expected = 91; assert_eq!(to_check, expected); let to_check = solution_part1(input, 20).unwrap(); let expected = 325; assert_eq!(to_check, expected); ...
code_fim
hard
{ "lang": "rust", "repo": "nbigaouette/advent_of_code_2018", "path": "/day12/src/initial.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }