text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> #[test] fn test_get_line_number() { assert_eq!(get_line_number(&"foo\nbar".to_string(), 0), 1, "first line"); assert_eq!( get_line_number(&"foo\nbar".to_string(), 4), 2, "second line" ); assert_eq!( get_line_number(&"foo\nbar".to_string(), 3), 1, "li...
code_fim
hard
{ "lang": "rust", "repo": "mabruckner/ourCAD", "path": "/src/parser/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stevepryde/rustnaughts path: /src/engine/runners/genetic/processor.rs use log::debug; use std::sync::mpsc::channel; use threadpool::ThreadPool; use crate::engine::botfactory::BotFactory; use crate::engine::gamebase::run_batch; use crate::engine::gameconfig::BatchConfig; use crate::engine::gamef...
code_fim
hard
{ "lang": "rust", "repo": "stevepryde/rustnaughts", "path": "/src/engine/runners/genetic/processor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tx = tx.clone(); self.pool.execute(move || { let item = process_batch( &thread_batch_config, game_factory, &mut bot_factory_clone, sample, index, ...
code_fim
hard
{ "lang": "rust", "repo": "stevepryde/rustnaughts", "path": "/src/engine/runners/genetic/processor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, game_factory: GameFactory, bot_factory: &mut BotFactory, samples: Vec<serde_json::Value>, selected_recipes: &mut Vec<GeneticRecipe>, score_threshold: GameScore, ) { let mut samples = samples; let mut index = 0; while !sampl...
code_fim
hard
{ "lang": "rust", "repo": "stevepryde/rustnaughts", "path": "/src/engine/runners/genetic/processor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> url = format!("http://{}", address.to_string()); let mut client = detail::renderer_client::RendererClient::connect(url) .await .unwrap(); client.render(request).await } }<|fim_prefix|>// repo: dearshuto/RayTracer path: /sjrt/src/net/rendering_client.rs use sup...
code_fim
hard
{ "lang": "rust", "repo": "dearshuto/RayTracer", "path": "/sjrt/src/net/rendering_client.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dearshuto/RayTracer path: /sjrt/src/net/rendering_client.rs use super::detail::{self, ImageView}; pub struct RenderingClient { pub width: i32, pub height: i32, pub sampling_count: u16, pub thread_count_x: i32, pub thread_count_y: i32, } impl RenderingCl<|fim_suffix|>idth, ...
code_fim
hard
{ "lang": "rust", "repo": "dearshuto/RayTracer", "path": "/sjrt/src/net/rendering_client.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct TimelineSemaphore { handle: vk::Semaphore, device: ash::Device, } impl TimelineSemaphore { pub fn new(device: &ash::Device) -> Result<Self> { unsafe { let device = device.clone(); let handle = device.create_semaphore( &vk::S...
code_fim
hard
{ "lang": "rust", "repo": "evopen/silly-cat-engine", "path": "/tracer/src/engine/queue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evopen/silly-cat-engine path: /tracer/src/engine/queue.rs use std::{sync::Arc}; use anyhow::Result; use ash::{ version::{DeviceV1_0, DeviceV1_2}, vk, }; use super::{command_buffer::CommandBuffer, Vulkan}; pub struct Queue { handle: vk::Queue, vulkan: Arc<Vulkan>,...
code_fim
hard
{ "lang": "rust", "repo": "evopen/silly-cat-engine", "path": "/tracer/src/engine/queue.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn handle(&self) -> vk::Semaphore { self.handle } } impl Drop for BinarySemaphore { fn drop(&mut self) { unsafe { self.device.destroy_semaphore(self.handle, None); } } } impl Queue { pub fn new(vulkan: Arc<Vulkan>, queue_family_in...
code_fim
hard
{ "lang": "rust", "repo": "evopen/silly-cat-engine", "path": "/tracer/src/engine/queue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.symbol_table.contains_key(key) { Some(&self) } else if self.parent.is_some() { self.parent.unwrap().find(key) } else { None } } pub fn get(&'a self, key: &str) -> Option<MalType> { let menv = self.find(key)?; ...
code_fim
medium
{ "lang": "rust", "repo": "sransara/mal-practice", "path": "/src/menv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sransara/mal-practice path: /src/menv.rs use std::collections::HashMap; use crate::types::MalType; #[derive(Debug)] pub struct MalEnv<'a> { parent: Option<&'a MalEnv<'a>>, symbol_table: HashMap<String, MalType>, } <|fim_suffix|> pub fn set(&mut self, key: &str, value: MalType) { ...
code_fim
medium
{ "lang": "rust", "repo": "sransara/mal-practice", "path": "/src/menv.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn find(&'a self, key: &str) -> Option<&MalEnv> { if self.symbol_table.contains_key(key) { Some(&self) } else if self.parent.is_some() { self.parent.unwrap().find(key) } else { None } } pub fn get(&'a self, key: &str) -> Opti...
code_fim
medium
{ "lang": "rust", "repo": "sransara/mal-practice", "path": "/src/menv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: philip-peterson/yew path: /yew-router/src/matcher/util.rs use nom::{ bytes::complete::{tag, tag_no_case}, character::complete::anychar, combinator::{cond, map, peek, rest}, error::{ErrorKind, ParseError}, multi::many_till, sequence::pair, IResult, }; use std::{iter::P...
code_fim
hard
{ "lang": "rust", "repo": "philip-peterson/yew", "path": "/yew-router/src/matcher/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let parser = alternative( vec!["c", "d", "abc"] .into_iter() .map(String::from) .collect(), ); let parsed = parser("abcz").expect("Should parse"); assert_eq!(parsed, ("z", "abc")) } #[test] fn alternat...
code_fim
hard
{ "lang": "rust", "repo": "philip-peterson/yew", "path": "/yew-router/src/matcher/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Self { bank: buffer[offset + 0x00], map: buffer[offset + 0x01], // Padding grass_ptr: load_poke_ptr(buffer, offset + 0x04)?, water_ptr: load_poke_ptr(buffer, offset + 0x08)?, trees_ptr: load_poke_ptr(buffer, offset + 0x0C)?...
code_fim
medium
{ "lang": "rust", "repo": "5mattmatt1/generation_iii_rom_editor", "path": "/src/wild_data_header.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 5mattmatt1/generation_iii_rom_editor path: /src/wild_data_header.rs #[derive(Copy, Clone)] pub struct WildDataHeader { pub bank: u8, pub map: u8, pub grass_ptr: usize, pub water_ptr: usize, pub trees_ptr: usize, pub fishing_ptr: usize, } <|fim_suffix|> Ok(Self { ...
code_fim
medium
{ "lang": "rust", "repo": "5mattmatt1/generation_iii_rom_editor", "path": "/src/wild_data_header.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ProcedureNative5 { #[ cfg_attr ( feature = "vonuvoli_inline", inline ) ] pub fn symbol (&self) -> (BacktraceSymbol) { return BacktraceSymbol::new (unsafe { mem::transmute (self.0) }); } #[ cfg_attr ( feature = "vonuvoli_inline", inline ) ] pub fn handle (&self) -> (Handle) { return self....
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/vonuvoli-scheme", "path": "/sources/native_procedures.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ProcedureNativeInternals { #[ cfg_attr ( feature = "vonuvoli_inline", inline ) ] pub fn symbol (&self) -> (BacktraceSymbol) { match *self { ProcedureNativeInternals::Native0 (ref native) => return native.symbol (), ProcedureNativeInternals::Native1 (ref native) => return native.sy...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/vonuvoli-scheme", "path": "/sources/native_procedures.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Happy-Ferret/vonuvoli-scheme path: /sources/native_procedures.rs use super::errors::exports::*; use super::evaluator::exports::*; use super::runtime::exports::*; use super::values::exports::*; use super::prelude::*; pub mod exports { pub use super::ProcedureNative; pub use super::Proc...
code_fim
hard
{ "lang": "rust", "repo": "Happy-Ferret/vonuvoli-scheme", "path": "/sources/native_procedures.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wils0651/TheNebula path: /src/main.rs down_d: bool, left_d: bool, right_d: bool, score: i64, difficulty: i32, lives: i32 } pub struct Enemy { gl: GlGraphics, // OpenGL drawing backend. radius: f64, mass: f64, x_pos: f64, y_pos: f64, x_vel: f64, y_vel: f64...
code_fim
hard
{ "lang": "rust", "repo": "wils0651/TheNebula", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wils0651/TheNebula path: /src/main.rs .trans(-radius, -radius) .trans(x_pos, y_pos); ellipse(PURPLE, shape1, transform, gl); }); } } //implementation of the Lives struct impl Lives { fn render (...
code_fim
hard
{ "lang": "rust", "repo": "wils0651/TheNebula", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>//boundaries fn collision(the_player: &mut Player, the_enemy: &mut Enemy) -> bool { let mut retval: bool = false; the_player.score += (((the_player.x_vel.powi(2) + the_player.y_vel.powi(2)).sqrt()) as i64) * 100 ; let cent_dist: f64 = ((the_player.x_pos-the_enemy.x_pos).powi(2) + (the_player.y...
code_fim
hard
{ "lang": "rust", "repo": "wils0651/TheNebula", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // next_idx should return the idx of tiles that hit the query while let Some(n) = inner.next_idx() { res.push(n); } assert_eq!(res.len(), 6); assert!(res.iter().all(|&n| (2..=8).contains(&n))); } #[test] fn test_cache_stream_inner_vector() {...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/operators/src/pro/cache/cache_stream.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geo-engine/geoengine path: /operators/src/pro/cache/cache_stream.rs use super::error::CacheError; use super::shared_cache::{CacheBackendElementExt, CacheElement}; use crate::util::Result; use futures::stream::FusedStream; use futures::{Future, Stream}; use pin_project::pin_project; use std::{pin...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/operators/src/pro/cache/cache_stream.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_cache_stream_inner_raster() { let data = Arc::new(create_test_raster_data()); let query = RasterQueryRectangle { spatial_bounds: SpatialPartition2D::new_unchecked((2., -2.).into(), (8., -8.).into()), time_interval: TimeInterval::new_unchecked...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/operators/src/pro/cache/cache_stream.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> Self(r) } } pub(super) fn respond<T, E>(db: Result<T, E>) -> StdResult<impl warp::Reply, Infallible> where T: Send + Serialize, E: Send + std::fmt::Debug, { let r: WrappedResult<T, E> = db.into(); Ok(r) }<|fim_prefix|>// repo: jdnavarro/charlatan path: /src/db.rs use std::{co...
code_fim
hard
{ "lang": "rust", "repo": "jdnavarro/charlatan", "path": "/src/db.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jdnavarro/charlatan path: /src/db.rs use std::{convert::Infallible, result::Result as StdResult}; use serde::Serialize; use warp::{hyper::StatusCode, Reply}; pub(super) type Result<T, E> = std::result::Result<T, E>; <|fim_suffix|>impl<T, E> From<Result<T, E>> for WrappedResult<T, E> { fn ...
code_fim
hard
{ "lang": "rust", "repo": "jdnavarro/charlatan", "path": "/src/db.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xmonader/smoltcp path: /src/rand.rs #![allow(unsafe_code)] #![allow(unused)] #[derive(Debug)] pub(crate) struct Rand { state: u64, } impl Rand { pub(crate) const fn new(seed: u64) -> Self { Self { state: seed } } <|fim_suffix|> let s = self.state.wrapping_mul(M).wra...
code_fim
hard
{ "lang": "rust", "repo": "xmonader/smoltcp", "path": "/src/rand.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let s = self.state.wrapping_mul(M).wrapping_add(A); self.state = s; let shift = 29 - (s >> 61); (s >> shift) as u32 } }<|fim_prefix|>// repo: xmonader/smoltcp path: /src/rand.rs #![allow(unsafe_code)] #![allow(unused)] #[derive(Debug)] pub(crate) struct Rand { st...
code_fim
hard
{ "lang": "rust", "repo": "xmonader/smoltcp", "path": "/src/rand.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> "RP", "SL", "SN", "ST", "SH", "TH", ];<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/de/address/state_abbr.rs pub static STATE_ABBR: &'static [&'static str] = &[ "BW", "BY", "BE", "BB<|fim_middle|>", "HB", "HH", "HE", "MV", "NI", "NW",
code_fim
easy
{ "lang": "rust", "repo": "PSeitz/f4ker-rs", "path": "/src/locales/de/address/state_abbr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>", "HB", "HH", "HE", "MV", "NI", "NW", "RP", "SL", "SN", "ST", "SH", "TH", ];<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/de/address/state_abbr.rs pub static STATE_ABBR: &'static [&'sta<|fim_middle|>tic str] = &[ "BW", "BY", "BE", "BB
code_fim
easy
{ "lang": "rust", "repo": "PSeitz/f4ker-rs", "path": "/src/locales/de/address/state_abbr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/locales/de/address/state_abbr.rs pub static STATE_ABBR: &'static [&'sta<|fim_suffix|> "RP", "SL", "SN", "ST", "SH", "TH", ];<|fim_middle|>tic str] = &[ "BW", "BY", "BE", "BB", "HB", "HH", "HE", "MV", "NI", "NW",
code_fim
medium
{ "lang": "rust", "repo": "PSeitz/f4ker-rs", "path": "/src/locales/de/address/state_abbr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: divergentdave/rsass path: /tests/fuzz_cases.rs use rsass::{compile_scss, output}; <|fim_suffix|> let format = output::Format { style: output::Style::Compressed, precision: 5, }; assert!(compile_scss(b"\\d00000", format).is_err()); }<|fim_middle|>#[test] fn bad_escape(...
code_fim
easy
{ "lang": "rust", "repo": "divergentdave/rsass", "path": "/tests/fuzz_cases.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let format = output::Format { style: output::Style::Compressed, precision: 5, }; assert!(compile_scss(b"\\d00000", format).is_err()); }<|fim_prefix|>// repo: divergentdave/rsass path: /tests/fuzz_cases.rs use rsass::{compile_scss, output}; <|fim_middle|>#[test] fn bad_escape(...
code_fim
easy
{ "lang": "rust", "repo": "divergentdave/rsass", "path": "/tests/fuzz_cases.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imricardoramos/rust_wgpu_test path: /src/app.rs use winit::{ event_loop::ControlFlow, event::{Event, WindowEvent, KeyboardInput, ElementState, VirtualKeyCode}, }; use crate::window; use crate::scene; pub fn run(){ let (event_loop, window) = window::create_window(); let mut scen...
code_fim
hard
{ "lang": "rust", "repo": "imricardoramos/rust_wgpu_test", "path": "/src/app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match event { Event::WindowEvent { ref event, window_id, } if window_id == window.id() => { match event { WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent:...
code_fim
hard
{ "lang": "rust", "repo": "imricardoramos/rust_wgpu_test", "path": "/src/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andreasterrius/alers path: /crates/ale_resources/src/mesh.rs pub position_offset: Option<usize>, pub uv_offset: Option<usize>, pub normal_offset: Option<usize>, pub load_transform: AleTransform, } pub struct Tri { position: [Vector3<f32>; 3], normal: [Vector3<f32>; 3], tri_norma...
code_fim
hard
{ "lang": "rust", "repo": "andreasterrius/alers", "path": "/crates/ale_resources/src/mesh.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] pub fn test_tri_cube_get_no_ebo() { use approx::relative_eq; let mesh = Mesh::new_cube(); assert_eq!(mesh.tri_len(), 12); let mut res: Vec<f32> = vec![]; for i in 0..mesh.tri_len() { let tri = mesh.tri_get(i).unwrap(); res.extend_from_slice(&[tri.position[0][0], tri.position[...
code_fim
hard
{ "lang": "rust", "repo": "andreasterrius/alers", "path": "/crates/ale_resources/src/mesh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(mesh.tri_len(), 3); let tri = mesh.tri_get(0).unwrap(); assert_eq!(tri.position[0], Vector3::new(1.0, 1.0, 1.0)); assert_eq!(tri.position[1], Vector3::new(2.0, 2.0, 2.0)); assert_eq!(tri.position[2], Vector3::new(3.0, 3.0, 3.0)); assert_eq!(tri.uv[0], Vector2::new(10.0, 10.0)); ...
code_fim
hard
{ "lang": "rust", "repo": "andreasterrius/alers", "path": "/crates/ale_resources/src/mesh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ryman/criterion.rs path: /src/outliers.rs use serialize::json; use std::io::File; use test::stats::Stats; #[deriving(Encodable)] pub struct Outliers { high_mild: Vec<f64>, high_severe: Vec<f64>, low_mild: Vec<f64>, low_severe: Vec<f64>, normal: Vec<f64>, thresholds: (f64...
code_fim
hard
{ "lang": "rust", "repo": "Ryman/criterion.rs", "path": "/src/outliers.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn high_severe(&self) -> &[f64] { self.high_severe.as_slice() } pub fn low_mild(&self) -> &[f64] { self.low_mild.as_slice() } pub fn low_severe(&self) -> &[f64] { self.low_severe.as_slice() } pub fn normal(&self) -> &[f64] { self.normal.as_...
code_fim
hard
{ "lang": "rust", "repo": "Ryman/criterion.rs", "path": "/src/outliers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let sample_size = total + self.normal.len(); let percent = |n: uint| { 100.0 * n as f64 / sample_size as f64 }; println!("> Found {} outliers among {} measurements ({:.2}%)", total, sample_size, percent(total)); let prin...
code_fim
hard
{ "lang": "rust", "repo": "Ryman/criterion.rs", "path": "/src/outliers.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wg/pg-extend-rs path: /integration-tests/tests/nullable_tests.rs extern crate integration_tests; use integration_tests::*; #[test] fn test_rs_nullif() { test_in_db("nullable", |conn| { // 'a', 'b' => 'a' let result = conn.query("SELECT rs_nullif('a', 'b')", &[]).expect("que...
code_fim
hard
{ "lang": "rust", "repo": "wg/pg-extend-rs", "path": "/integration-tests/tests/nullable_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let row = result.get(0); let col: Option<String> = row.get(0); assert_eq!(col, Some("a".to_string())); // NULL, '-' => NULL let result = conn.query("SELECT rs_nullif(NULL, '-')", &[]).expect("query failed"); assert_eq!(result.len(), 1); let row = ...
code_fim
hard
{ "lang": "rust", "repo": "wg/pg-extend-rs", "path": "/integration-tests/tests/nullable_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goodbyekansas/wasmtime path: /crates/wasi-common/yanix/src/fcntl.rs use crate::{ file::{FdFlags, OFlags}, from_result, from_success_code, }; use std::io::Result; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(target_os = "wasi")] use std::os::wasi::prelude::*; <|fim_suffix|>pub unsaf...
code_fim
hard
{ "lang": "rust", "repo": "goodbyekansas/wasmtime", "path": "/crates/wasi-common/yanix/src/fcntl.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn get_status_flags(fd: RawFd) -> Result<OFlags> { from_result(libc::fcntl(fd, libc::F_GETFL)).map(OFlags::from_bits_truncate) } pub unsafe fn set_status_flags(fd: RawFd, flags: OFlags) -> Result<()> { from_success_code(libc::fcntl(fd, libc::F_SETFL, flags.bits())) }<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "goodbyekansas/wasmtime", "path": "/crates/wasi-common/yanix/src/fcntl.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>mod change; mod cluster; mod cmd; mod commit_table_reply; mod database_info; mod database_reply; mod errors; mod kv_reply; mod log_entry; mod match_seq; mod operation; mod raft_txid; mod raft_types; mod seq_num; mod seq_value; mod table_info; mod table_reply; #[cfg(test)] mod cluster_test; #[cfg(test)] m...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/common/meta/types/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use change::AddResult; pub use change::Change; pub use cluster::Node; pub use cluster::NodeInfo; pub use cluster::Slot; pub use cmd::Cmd; pub use commit_table_reply::UpsertTableOptionReply; pub use database_info::DatabaseInfo; pub use database_reply::CreateDatabaseReply; pub use errors::ConflictSeq; p...
code_fim
medium
{ "lang": "rust", "repo": "r-asou/databend", "path": "/common/meta/types/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: r-asou/databend path: /common/meta/types/src/lib.rs // Copyright 2020 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.or...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/common/meta/types/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for partition_index in 0..partitions_pre_node { node_partitions .push((new_partitions[node_partitions_offset + partition_index]).clone()); } if !node_partitions.is_empty() { nodes_partitions.in...
code_fim
hard
{ "lang": "rust", "repo": "xlight/datafuse", "path": "/fusequery/query/src/interpreters/plan_scheduler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xlight/datafuse path: /fusequery/query/src/interpreters/plan_scheduler.rs // Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. use std::collections::hash_map::Entry::Occupied; use std::collections::hash_map::Entry::Vacant; use std::collections::HashMap; use st...
code_fim
hard
{ "lang": "rust", "repo": "xlight/datafuse", "path": "/fusequery/query/src/interpreters/plan_scheduler.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xib1uvXi/rust_by_example path: /rust_drill/src/main.rs fn main() { // ! 这个是说明是一个宏 println!("Hello, world!"); println!("Hello world!"); <|fim_suffix|> // 用变量替换字符串有多种写法。 // 比如可以使用位置参数。 println!("{0}, this is {1}. {1}, this is {0}", "Alice", "Bob"); }<|fim_middle|> printl...
code_fim
easy
{ "lang": "rust", "repo": "Xib1uvXi/rust_by_example", "path": "/rust_drill/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 用变量替换字符串有多种写法。 // 比如可以使用位置参数。 println!("{0}, this is {1}. {1}, this is {0}", "Alice", "Bob"); }<|fim_prefix|>// repo: Xib1uvXi/rust_by_example path: /rust_drill/src/main.rs fn main() { // ! 这个是说明是一个宏 println!("Hello, world!"); println!("Hello world!"); <|fim_middle|> printl...
code_fim
easy
{ "lang": "rust", "repo": "Xib1uvXi/rust_by_example", "path": "/rust_drill/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(HtmlBlock { content, brace }) } } impl ToTokens for HtmlBlock { fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { let HtmlBlock { content, .. } = self; let new_tokens = match content { BlockContent::Iterable(html_iterable) => quote! {#html_iterabl...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/yew", "path": "/packages/yew-macro/src/html_tree/html_block.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/yew path: /packages/yew-macro/src/html_tree/html_block.rs use proc_macro2::Delimiter; use quote::{quote, quote_spanned, ToTokens}; use syn::buffer::Cursor; use syn::parse::{Parse, ParseStream}; use syn::{braced, token}; use super::{HtmlIterable, HtmlNode, ToNodeIterator}; use crate::P...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/yew", "path": "/packages/yew-macro/src/html_tree/html_block.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> cursor.group(Delimiter::Brace).map(|_| ()) } } impl Parse for HtmlBlock { fn parse(input: ParseStream) -> syn::Result<Self> { let content; let brace = braced!(content in input); let content = if HtmlIterable::peek(content.cursor()).is_some() { BlockCont...
code_fim
medium
{ "lang": "rust", "repo": "doytsujin/yew", "path": "/packages/yew-macro/src/html_tree/html_block.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if msg_len > 0 { let buf_end = self.buffer_pos.checked_add(msg_len).expect("overflow"); xor::in_place( &mut self.buffer.as_mut()[self.buffer_pos..buf_end], &msg[msg_pos..], ); self.buffer_pos = self.buffer_pos.checke...
code_fim
hard
{ "lang": "rust", "repo": "paragonie-scott/miscreant", "path": "/rust/src/internals/pmac.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paragonie-scott/miscreant path: /rust/src/internals/pmac.rs //! `internals/pmac.rs`: Parallel Message Authentication Code //! Defined in http://web.cs.ucdavis.edu/~rogaway/ocb/pmac.pdf use super::{BLOCK_SIZE, Block, Block8, BlockCipher, Mac, xor}; use super::block::R; use byteorder::{BigEndian,...
code_fim
hard
{ "lang": "rust", "repo": "paragonie-scott/miscreant", "path": "/rust/src/internals/pmac.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 2) create_wallet let json = r#"{ "passwordHint": "hint", "name": "urugang", "timestamp": 0, "source": "NEW_IDENTITY", "password": "mypass" }"#; let json = CString::new(json).expect("CString:new failed"); let id = unsafe { let result = ...
code_fim
hard
{ "lang": "rust", "repo": "lichang-lab/token-core", "path": "/tcx/examples/wallet.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let json = format!( r#"{{ "id": {}, "chainType": "BCH", "to": "{}", "amount": "1200", "fee": "13", "internalUsed": 1, "outputs": {:}, "password": "mypass" }}"#, id, "bitcoincash:qrj5mazh5vayn8jnqqsgqymnjtn7wshejyt3...
code_fim
hard
{ "lang": "rust", "repo": "lichang-lab/token-core", "path": "/tcx/examples/wallet.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lichang-lab/token-core path: /tcx/examples/wallet.rs extern crate serde_json; extern crate tcx; extern crate tcx_btc_fork; extern crate tcx_chain; use serde_json::Value; use std::ffi::{CStr, CString}; use std::fs::{create_dir, remove_dir}; use std::path::Path; use tcx::*; use tcx_btc_fork::tran...
code_fim
hard
{ "lang": "rust", "repo": "lichang-lab/token-core", "path": "/tcx/examples/wallet.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.id = None; log::warn!("Failed to load image: {}", self.path.display()); loop { log::warn!("Cause: {}", error); if let Some(source) = error.source() { error = source; } else { break; } } ...
code_fim
hard
{ "lang": "rust", "repo": "chenenjie/kas", "path": "/src/widget/sprite.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenenjie/kas path: /src/widget/sprite.rs // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org/licenses/LICENS...
code_fim
hard
{ "lang": "rust", "repo": "chenenjie/kas", "path": "/src/widget/sprite.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Set image path pub fn set_path<P: Into<PathBuf>>(&mut self, mgr: &mut Manager, path: P) { self.path = path.into(); self.do_load = false; let mut size = Size::ZERO; mgr.draw_shared(|ds| { if let Some(id) = self.id { ds.image_free(id); ...
code_fim
hard
{ "lang": "rust", "repo": "chenenjie/kas", "path": "/src/widget/sprite.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jbelke/amqp-rs path: /amqp0/client/src/session/mod.rs // Copyright 2016 Alexander Reece // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // opt...
code_fim
hard
{ "lang": "rust", "repo": "jbelke/amqp-rs", "path": "/amqp0/client/src/session/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let State::Started(ref mut buf, ref mut stream) = self.state { try!(buf.read_from(stream)); let frame = P::Frame::nom_bytes(&buf[..4], &mut NoParserPool); let (_, frame) = frame.unwrap(); println!("{:#?}", frame); return Ok(frame); ...
code_fim
hard
{ "lang": "rust", "repo": "jbelke/amqp-rs", "path": "/amqp0/client/src/session/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::auth::{Authenticator, PlainAuthenticator}; pub use self::config::{Config, ConfigBuilder}; #[derive(Debug)] enum State { Unconnected, Started(Buf, TcpStream), // Before sending StartOK Secured(Buf, TcpStream), // Before sending SecureOK Tuned(Buf, TcpStream), // Before send...
code_fim
hard
{ "lang": "rust", "repo": "jbelke/amqp-rs", "path": "/amqp0/client/src/session/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.color_value.clone() } }<|fim_prefix|>// repo: asg0451/rt path: /src/texture/solid_color.rs use crate::texture::Texture; use crate::vec3::{Color, Point3, Vec3}; pub struct SolidColor { color_value: Color, } <|fim_middle|>impl SolidColor { pub fn new(color_value: Color) -> Self {...
code_fim
medium
{ "lang": "rust", "repo": "asg0451/rt", "path": "/src/texture/solid_color.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: asg0451/rt path: /src/texture/solid_color.rs use crate::texture::Texture; use crate::vec3::{Color, Point3, Vec3}; <|fim_suffix|>impl SolidColor { pub fn new(color_value: Color) -> Self { Self { color_value } } } impl Texture for SolidColor { fn value(&self, _u: f64, _v: f64...
code_fim
easy
{ "lang": "rust", "repo": "asg0451/rt", "path": "/src/texture/solid_color.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samschlinkertcnn/slack-rs-api path: /codegen/src/adapt/users/mod.rs #![allow(unused_imports)] #![allow(clippy::single_match)] use crate::adapt::utils::*; use crate::rust::{Method, Module}; mod profile; pub fn correct(module: &mut Module) { for mut module in &mut module.submodules { ...
code_fim
medium
{ "lang": "rust", "repo": "samschlinkertcnn/slack-rs-api", "path": "/codegen/src/adapt/users/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn correct_delete_photo(_method: &mut Method) {} fn correct_get_presence(_method: &mut Method) {} fn correct_identity(_method: &mut Method) {} fn correct_info(_method: &mut Method) {} fn correct_list(_method: &mut Method) {} fn correct_lookup_by_email(_method: &mut Method) {} fn correct_set_active(...
code_fim
hard
{ "lang": "rust", "repo": "samschlinkertcnn/slack-rs-api", "path": "/codegen/src/adapt/users/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use core::panic::PanicInfo; #[panic_handler] pub fn panic(panic: &PanicInfo<'_>) -> ! { wait_vblank(); unsafe { write_volatile(POWCNT1, 0x3); write_volatile(DISPCNT, 0x20000); write_volatile(VRAMCNT_A, 0x80); } writeln!(Console, "{}", panic).unwrap(); wait_vbla...
code_fim
hard
{ "lang": "rust", "repo": "Rapdorian/nds-rs", "path": "/panic/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rapdorian/nds-rs path: /panic/src/lib.rs #![no_std] #![feature(panic_info_message, lang_items, asm)] use core::fmt::Write; use core::ptr::write_volatile; use font8x8::{UnicodeFonts, BASIC_FONTS}; use nds_registers::arm9::*; <|fim_suffix|>impl Write for Console { fn write_str(&mut self, s: ...
code_fim
hard
{ "lang": "rust", "repo": "Rapdorian/nds-rs", "path": "/panic/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let ast::ModuleItem::Stmt(ast::Stmt::Expr(expr)) = node { expr.span = expr.span.apply_mark(self.mark); } } } impl VisitMut for CleanSideEffects { fn visit_mut_module(&mut self, node: &mut ast::Module) { node.body.drain_filter(|item| { if item.spa...
code_fim
medium
{ "lang": "rust", "repo": "daveek/qwik", "path": "/packages/qwik/src/optimizer/core/src/clean_side_effects.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: daveek/qwik path: /packages/qwik/src/optimizer/core/src/clean_side_effects.rs use swc_common::{Mark, Spanned}; use swc_ecmascript::ast; use swc_ecmascript::visit::VisitMut; pub struct Treeshaker { pub marker: CleanMarker, pub cleaner: CleanSideEffects, } pub struct CleanSideEffects { ...
code_fim
hard
{ "lang": "rust", "repo": "daveek/qwik", "path": "/packages/qwik/src/optimizer/core/src/clean_side_effects.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> node.body.drain_filter(|item| { if item.span().has_mark(self.mark) { return false; } match item { ast::ModuleItem::Stmt(ast::Stmt::Expr(expr)) => match *expr.expr { ast::Expr::New(_) | ast::Expr::Call(_) => { ...
code_fim
hard
{ "lang": "rust", "repo": "daveek/qwik", "path": "/packages/qwik/src/optimizer/core/src/clean_side_effects.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: warrenhodg/rust_examples path: /factory_pattern/src/main.rs trait Pet { fn get_name(&self) -> String; } type PetFactory = fn (name: &str) -> Box<dyn Pet>; struct Dog { name: String, } impl Dog { fn new(name: &str) -> Box<dyn Pet> { Box::new(Self { name: name.to...
code_fim
hard
{ "lang": "rust", "repo": "warrenhodg/rust_examples", "path": "/factory_pattern/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Person {} dropping", self.name); } } fn run() { println!("in run"); let p = Person::new_with_pet("Warren", Dog::new, "Wilma"); println!("{} has {}", p.name, p.p.get_name()); println!("{} has {}", p.name, p.p.get_name()); println!("out of run"); } fn main() { ...
code_fim
hard
{ "lang": "rust", "repo": "warrenhodg/rust_examples", "path": "/factory_pattern/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { name: name.to_string(), p: f(pet_name), } } } impl Drop for Person { fn drop(&mut self) { println!("Person {} dropping", self.name); } } fn run() { println!("in run"); let p = Person::new_with_pet("Warren", Dog::new, "Wilma"); ...
code_fim
hard
{ "lang": "rust", "repo": "warrenhodg/rust_examples", "path": "/factory_pattern/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!(); } } #[stable(feature = "rust1", since = "1.0.0")] impl UpperExp for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { unimplemented!(); } } ) } floating! { f32 } floating! { f64 }...
code_fim
hard
{ "lang": "rust", "repo": "GitNiklas/libcore", "path": "/src/fmt/float_avr_hack.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GitNiklas/libcore path: /src/fmt/float_avr_hack.rs use fmt::{Formatter, Result, Display, Debug, UpperExp, LowerExp}; macro_rules! floating { ($ty:ident) => ( #[stable(feature = "rust1", since = "1.0.0")] impl Debug for $ty { fn fmt(&self, fmt: &mut Formatter) -> ...
code_fim
hard
{ "lang": "rust", "repo": "GitNiklas/libcore", "path": "/src/fmt/float_avr_hack.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DoumanAsh/pong path: /src/game/systems/paddle.rs use amethyst::core::Transform; use amethyst::ecs::{Join, Read, ReadStorage, System, WriteStorage}; use amethyst::input::InputHandler; use amethyst::core::timing::Time; use game::components::gameplay::{Side, Paddle, PADDLE_HEIGHT}; use game::ARENA...
code_fim
hard
{ "lang": "rust", "repo": "DoumanAsh/pong", "path": "/src/game/systems/paddle.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>Bit 24 - Default 0 active low during valid data transfer on each horizontal line."] #[inline] pub fn enable_pol(&self) -> ENABLE_POLR { let bits = { const MASK: bool = true; const OFFSET: u8 = 24; ((self.bits >> OFFSET) & MASK as u32) != 0 }; ...
code_fim
hard
{ "lang": "rust", "repo": "ferrous-systems/imxrt1052", "path": "/src/lcdif/vdctrl0_set/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }; VSYNC_PULSE_WIDTH_UNITR { bits } } #[doc = "Bit 21 - Default 0 for counting VSYNC_PERIOD in terms of DISPLAY CLOCK (pix_clk) cycles"] #[inline] pub fn vsync_period_unit(&self) -> VSYNC_PERIOD_UNITR { let bits = { const MASK: bool = true; co...
code_fim
hard
{ "lang": "rust", "repo": "ferrous-systems/imxrt1052", "path": "/src/lcdif/vdctrl0_set/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/lcdif/vdctrl0_set/mod.rs lue of the field"] pub struct VSYNC_PULSE_WIDTHR { bits: u32, } impl VSYNC_PULSE_WIDTHR { #[doc = r" Value of the field as raw bits"] #[inline] pub fn bits(&self) -> u32 { self.bits } } #[doc = r" Value of ...
code_fim
hard
{ "lang": "rust", "repo": "ferrous-systems/imxrt1052", "path": "/src/lcdif/vdctrl0_set/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rednithin/CSES path: /AppleDivision.rs use std::io; use std::str; // https://github.com/EbTech/rust-algorithms pub struct Scanner<R: io::BufRead> { reader: R, buffer: Vec<String>, } impl<R: io::BufRead> Scanner<R> { pub fn new(reader: R) -> Self { Scanner { read...
code_fim
medium
{ "lang": "rust", "repo": "rednithin/CSES", "path": "/AppleDivision.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut answer = total_sum; for i in 0..1i64<<n { let subset_sum: i64 = apples .iter() .enumerate() .filter_map(|(j, item)| { if 1 << j & i > 0 { Some(item) } else { None ...
code_fim
medium
{ "lang": "rust", "repo": "rednithin/CSES", "path": "/AppleDivision.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let tree = interpret(&states, tokens!["N", "-", "(", "N", "-", "N", ")"]).unwrap(); assert_eq!( &format!("{:?}", tree)[..], r#"[S: [E: [E: [T: "N"]], "-", [T: "(", [E: [E: [T: "N"]], "-", [T: "N"]], ")"]]]"# ); }<|fim_prefix|>// repo: lalrpop/lalrpop path: /lalrpop/src/lr1/bui...
code_fim
hard
{ "lang": "rust", "repo": "lalrpop/lalrpop", "path": "/lalrpop/src/lr1/build_lalr/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lalrpop/lalrpop path: /lalrpop/src/lr1/build_lalr/test.rs use super::super::interpret::interpret; use super::build_lalr_states; use crate::grammar::repr::*; use crate::lr1::tls::Lr1Tls; use crate::test_util::normalized_grammar; use crate::tls::Tls; use string_cache::DefaultAtom as Atom; fn nt(t...
code_fim
medium
{ "lang": "rust", "repo": "lalrpop/lalrpop", "path": "/lalrpop/src/lr1/build_lalr/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustviz/rustviz path: /src/examples/nll_lexical_scope_different/main.rs /* --- BEGIN Variable Definitions --- Owner mut x; MutRef y; MutRef z; MutRef s; Function String::from(); Function world(); Function push_str(); Function println!() --- END Variable Definitions --- */ fn main() { <|fim_suffi...
code_fim
hard
{ "lang": "rust", "repo": "rustviz/rustviz", "path": "/src/examples/nll_lexical_scope_different/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn world(s : &mut String) { // !{ InitRefParam(s) } s.push_str(", world"); // !{ PassByMutableReference(s->push_str()) } } // !{ GoOutOfScope(s) }<|fim_prefix|>// repo: rustviz/rustviz path: /src/examples/nll_lexical_scope_different/main.rs /* --- BEGIN Variable Definitions --- Owner mut x; MutRef y;...
code_fim
hard
{ "lang": "rust", "repo": "rustviz/rustviz", "path": "/src/examples/nll_lexical_scope_different/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { for _ in 0..xch { for ky in 0..kh { let y_start = ky * dh - ph; for kx in 0..kw { let x_start = kx * dw - pw; let mut y_offset = y_start; for _ in 0..yh { if...
code_fim
hard
{ "lang": "rust", "repo": "raskr/rust-autograd", "path": "/src/tensor_ops/conv_ops/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raskr/rust-autograd path: /src/tensor_ops/conv_ops/mod.rs use crate::ndarray_ext; use crate::ndarray_ext::{NdArray, NdArrayView}; use crate::op; use crate::same_type; use crate::tensor_ops::*; use crate::Float; use crate::Tensor; use ndarray; use rayon::prelude::*; use std::f32; use std::slice; ...
code_fim
hard
{ "lang": "rust", "repo": "raskr/rust-autograd", "path": "/src/tensor_ops/conv_ops/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_conn_manager() { let (sender1, receiver1) = ChannelSender::<Message>::new(1, 1); let (sender2, receiver2) = ChannelSender::<Message>::new(2, 2); let mut conn_manager = NetworkInbound::<ChannelSender<Message>, ChannelSender<Message>>::new(); // inse...
code_fim
hard
{ "lang": "rust", "repo": "hqt/dust", "path": "/raftstore/src/network_inbound.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hqt/dust path: /raftstore/src/network_inbound.rs use std::collections::HashMap; use crate::peer_sender::PeerSender; use std::sync::{Arc, Mutex}; use raft::{prelude::*}; use std::borrow::Borrow; // ConnManager manages network inbound: either to other Raft nodes or "clients" (configuration chang...
code_fim
hard
{ "lang": "rust", "repo": "hqt/dust", "path": "/raftstore/src/network_inbound.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // get connection let proposal_sender = conn_manager.get_proposal_sender(1); assert_eq!(proposal_sender.is_some(), true); assert_eq!(proposal_sender.unwrap().sender_id(), 1); let internal_sender = conn_manager.get_internal_sender(1); assert_eq!(internal_sen...
code_fim
hard
{ "lang": "rust", "repo": "hqt/dust", "path": "/raftstore/src/network_inbound.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> eprintln!( "[{}][{}] {}: {}", timestamp, record.module_path().unwrap_or("<unknown>"), text, record.args() ); } } fn flush(&self) {} }<|fim_prefix|>// repo: K4rakara/waylock path: /src/...
code_fim
hard
{ "lang": "rust", "repo": "K4rakara/waylock", "path": "/src/logger.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn log(&self, record: &log::Record) { // enabled is not necessarily called first, so we must check manually if self.enabled(record.metadata()) { let timestamp = format_rfc3339_seconds(SystemTime::now()); let text = match record.level() { log::Le...
code_fim
hard
{ "lang": "rust", "repo": "K4rakara/waylock", "path": "/src/logger.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: K4rakara/waylock path: /src/logger.rs use humantime::format_rfc3339_seconds; use std::boxed::Box; use std::time::SystemTime; pub struct Logger { level_filter: log::LevelFilter, } impl Logger { fn new(level_filter: log::LevelFilter) -> Self { Self { level_filter } } <|fim_...
code_fim
hard
{ "lang": "rust", "repo": "K4rakara/waylock", "path": "/src/logger.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let dim_factors = std::mem::replace(&mut self.dim_factors, VecSet::default()); let divisors = std::mem::replace(&mut self.divisors, VecSet::default()); let (new_dim_factors, new_divisors) = dim_factors.relative_difference(divisors); self.dim_factors = new_dim_factors; ...
code_fim
hard
{ "lang": "rust", "repo": "ulysseB/telamon", "path": "/src/ir/size.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }