text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // Mean and variance via Welford's algorithm n += 1; let delta = elapsed_ns as f64 - mean; mean += delta / n as f64; let delta2 = elapsed_ns as f64 - mean; m2 += delta * delta2; } let variance = m2 / (n - 1) as f64; println!("latency: avg {}ns ...
code_fim
hard
{ "lang": "rust", "repo": "JohnColanduoni/sandbox-ipc", "path": "/benches/shm_queue.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("latency: avg {}ns (sig2 = {}, sig = {}) min {}ns max {}ns", mean as u32, variance as u32, variance.sqrt() as u32, min.unwrap(), max.unwrap()); } fn run_child(mut tokio_loop: TokioLoop, channel: MessageChannel<Message, Message>) { let (message, _channel) = tokio_loop.run(channel.into_fut...
code_fim
hard
{ "lang": "rust", "repo": "JohnColanduoni/sandbox-ipc", "path": "/benches/shm_queue.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { &Foo(ref s) => println!("f\"{}\"", s), } } } fn main() {}<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/19064.rs struct Foo(pub str); <|fim_middle|>impl Foo { fn print(&self) {
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/fixed/19064.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/19064.rs struct Foo(pub str); <|fim_suffix|> match self { &Foo(ref s) => println!("f\"{}\"", s), } } } fn main() {}<|fim_middle|>impl Foo { fn print(&self) {
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/glacier", "path": "/fixed/19064.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Some(MacAddress::parse_str("12-34-56-AB-CD-EF").unwrap()), "'12-34-56-ab-cd-ef'", ), (None, "NULL"), ], ) .await }<|fim_prefix|>// repo: sfackler/rust-postgres path: /tokio-postgres/tests/test/types/eui48_1.rs use eui48_1::MacAddress; use crate...
code_fim
medium
{ "lang": "rust", "repo": "sfackler/rust-postgres", "path": "/tokio-postgres/tests/test/types/eui48_1.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sfackler/rust-postgres path: /tokio-postgres/tests/test/types/eui48_1.rs use eui48_1::MacAddress; use crate::types::test_type; #[tokio::test] async fn test_e<|fim_suffix|> Some(MacAddress::parse_str("12-34-56-AB-CD-EF").unwrap()), "'12-34-56-ab-cd-ef'", ), ...
code_fim
medium
{ "lang": "rust", "repo": "sfackler/rust-postgres", "path": "/tokio-postgres/tests/test/types/eui48_1.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ak1211/irremocon path: /ir-command/src/receive_codes.rs /* irremocon <https://github.com/ak1211/irremocon> Copyright 2019 Akihiro Yamamoto 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 ...
code_fim
hard
{ "lang": "rust", "repo": "ak1211/irremocon", "path": "/ir-command/src/receive_codes.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // リモコン信号を検出したのでカウント開始 let mut previous: Level = ASSERT_IR; let mut count: u16 = 0; while count < TIMEOUT_COUNTS { if previous == pin.read() { // 信号が変化しないならカウンタを増やす count += COUNT_PACE; } else { // 信号が変化したら // カウント値をバッファに入れて ...
code_fim
hard
{ "lang": "rust", "repo": "ak1211/irremocon", "path": "/ir-command/src/receive_codes.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bitwalker/lumen path: /liblumen_codegen/src/config.rs use std::fmt; use std::convert::AsRef; use std::path::{Path, PathBuf}; use super::llvm; use super::llvm::enums::*; use super::llvm::target::{Target, TargetData, TargetMachine}; use super::{Result, CodeGenError}; /// The configuration build...
code_fim
hard
{ "lang": "rust", "repo": "bitwalker/lumen", "path": "/liblumen_codegen/src/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn set_output_type(mut self, ty: OutputType) -> Self { self.output_type = ty; self } #[inline] pub fn finalize(self) -> Result<Config> { if self.target.has_target_machine() { Config::new(self) } else { Err(CodeGenEr...
code_fim
hard
{ "lang": "rust", "repo": "bitwalker/lumen", "path": "/liblumen_codegen/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> f.debug_struct("ConfigBuilder") .field("target_triple", &self.target_triple) .field("target_features", &self.target_features) .field("target_cpu", &self.target_cpu) .field("opt_level", &self.opt_level) .field("relocation_mode", &self.relo...
code_fim
hard
{ "lang": "rust", "repo": "bitwalker/lumen", "path": "/liblumen_codegen/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn render(scene: &Scene) -> DynamicImage { let pixels = par_render_pixels(scene); let w = scene.width; let image = ImageBuffer::from_fn(scene.width, scene.height, |x, y| { Rgba::from(pixels[(x + y * w) as usize].to_rgba8()) // Rgba::from(render_a_pixel(scene, x, y).to_rgba8...
code_fim
hard
{ "lang": "rust", "repo": "Nalleyer/naive-raytracer", "path": "/src/rendering.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ray = Ray::new_prime(x, y, scene); if let Some(intersection) = trace(scene, &ray) { get_color(scene, &ray, &intersection, 0).clamp() } else { Color::black() } } pub fn render(scene: &Scene) -> DynamicImage { let pixels = par_render_pixels(scene); let w = scene....
code_fim
hard
{ "lang": "rust", "repo": "Nalleyer/naive-raytracer", "path": "/src/rendering.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nalleyer/naive-raytracer path: /src/rendering.rs use crate::color::Color; use crate::math::{Point, Vector3}; use crate::scene::{ material::{Material, SurfaceType, TextureCoords}, Distance, Scene, }; use rayon::prelude::*; pub const SHADOW_BIAS: Distance = 1e-12; pub const MAX_RECURSION...
code_fim
hard
{ "lang": "rust", "repo": "Nalleyer/naive-raytracer", "path": "/src/rendering.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Returning values from functions can also transfer ownership: let s_that_came_from_a_function = gives_ownership(); // gives_ownership moves its return value into s2 println!("s_that_came_from_a_function = {}", s_that_came_from_a_function); let s3 = String::from("hello"); // s3 comes...
code_fim
hard
{ "lang": "rust", "repo": "fgavilondo/rusty", "path": "/the-book/src/chapter4ownership.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fgavilondo/rusty path: /the-book/src/chapter4ownership.rs pub(crate) fn move_with_variables() { println!(); println!("4. Ownership - Move - Variables"); println!(); // For primitive (scalar) types, an assignment is a copy, not a move, // as these are stack values, there is n...
code_fim
hard
{ "lang": "rust", "repo": "fgavilondo/rusty", "path": "/the-book/src/chapter4ownership.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Taking ownership and then returning ownership with every function is a bit tedious. // What if we want to let a function use a value but not take ownership? // It’s quite annoying that anything we pass in also needs to be passed back if we want to // use it again, in addition to any dat...
code_fim
hard
{ "lang": "rust", "repo": "fgavilondo/rusty", "path": "/the-book/src/chapter4ownership.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn state(&self) -> AudioSourceState { self.state } fn pause(&mut self) { self.state = AudioSourceState::Paused; self.streaming_source.pause(); } fn resume(&mut self) { if self.state == AudioSourceState::Paused { self.state = AudioSourceStat...
code_fim
hard
{ "lang": "rust", "repo": "dontpanic92/radiance", "path": "/radiance/src/audio/openal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dontpanic92/radiance path: /radiance/src/audio/openal.rs use super::{ decoders::{Decoder, Mp3Decoder, OggDecoder, Samples, WavDecoder}, Codec, }; use super::{AudioEngine, AudioSource, AudioSourceState}; use alto::{Alto, Context, Mono, OutputDevice, Source, Stereo}; use std::rc::Rc; pub ...
code_fim
hard
{ "lang": "rust", "repo": "dontpanic92/radiance", "path": "/radiance/src/audio/openal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: parallel-programming-hwr/ocl-stream-rs path: /src/lib.rs /* * opencl stream executor * Copyright (C) 2021 trivernis * See LICENSE for more information */ pub mod executor; pub mod traits; pub mod utils; pub use executor::stream; pub use executor::OCLStreamExecutor; // reexport the ocl crat...
code_fim
hard
{ "lang": "rust", "repo": "parallel-programming-hwr/ocl-stream-rs", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) }); let mut count = 0; let num = (99f32.powf(2.0) + 99f32) / 2f32; while let Ok(n) = stream.next() { assert_eq!(n, num as u32); count += 1; } assert_eq!(count, 100) } }<|fim_prefix|>// repo: parallel-programmi...
code_fim
hard
{ "lang": "rust", "repo": "parallel-programming-hwr/ocl-stream-rs", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl CharSet { pub fn new() -> Self { Self::default() } } impl Default for CharSet { fn default() -> Self { CharSet(unsafe { NonNull::new(FcCharSetCreate()).unwrap() }) } } impl CharSetRef { pub fn add(&mut self, glyph: char) -> bool { unsafe { FcCharSetAddCha...
code_fim
hard
{ "lang": "rust", "repo": "thunderseethe/alacritty", "path": "/font/src/ft/fc/char_set.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for CharSet { fn default() -> Self { CharSet(unsafe { NonNull::new(FcCharSetCreate()).unwrap() }) } } impl CharSetRef { pub fn add(&mut self, glyph: char) -> bool { unsafe { FcCharSetAddChar(self.as_ptr(), glyph as _) == 1 } } }<|fim_prefix|>// repo: thunderse...
code_fim
medium
{ "lang": "rust", "repo": "thunderseethe/alacritty", "path": "/font/src/ft/fc/char_set.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thunderseethe/alacritty path: /font/src/ft/fc/char_set.rs // Copyright 2016 Joe Wilm, The Alacritty Project Contributors // // 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 Licen...
code_fim
hard
{ "lang": "rust", "repo": "thunderseethe/alacritty", "path": "/font/src/ft/fc/char_set.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> a.insert("Hello, world!".to_string(), 1i32); a.insert("Hi".to_string(), 10); }<|fim_prefix|>// repo: simnalamburt/snippets path: /rust/hashmap.rs use std::collections::HashMap; fn main() { <|fim_middle|> let mut a = HashMap::new();
code_fim
easy
{ "lang": "rust", "repo": "simnalamburt/snippets", "path": "/rust/hashmap.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simnalamburt/snippets path: /rust/hashmap.rs use std::collections::HashMap; fn main() { <|fim_suffix|> a.insert("Hello, world!".to_string(), 1i32); a.insert("Hi".to_string(), 10); }<|fim_middle|> let mut a = HashMap::new();
code_fim
easy
{ "lang": "rust", "repo": "simnalamburt/snippets", "path": "/rust/hashmap.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThibautGeriz/rustor path: /src/window.rs extern crate termion; use std::io::Write; use termion::{color, style}; use cursor::*; use editor::Editor; pub fn print_line<W: Write>( stream: &mut W, left_pad: u16, terminal_line_nb: u16, file_line_nb: u16, content: &str, curs...
code_fim
hard
{ "lang": "rust", "repo": "ThibautGeriz/rustor", "path": "/src/window.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> // Given let padding = 2; let line_number = 57; // When let result = render_line_nb(padding, line_number); // Then assert_eq!(result, "57"); } #[test] fn test_render_line_nb_4_out_of_5() { // Given let padding = 4; ...
code_fim
hard
{ "lang": "rust", "repo": "ThibautGeriz/rustor", "path": "/src/window.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> let home: IpAddrKind = IpAddrKind::V4(127, 0, 0, 1); let loopback: IpAddrKind = IpAddrKind::V6(String::from("::1")); } fn route(ip_kind: IpAddrKind) {}<|fim_prefix|>// repo: DerDoni/rust_book path: /rectangle/Enum/src/main.rs enum IpAddrKind { V4(u8, u8, u8, u8), V6(String), } enum Mes...
code_fim
medium
{ "lang": "rust", "repo": "DerDoni/rust_book", "path": "/rectangle/Enum/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DerDoni/rust_book path: /rectangle/Enum/src/main.rs enum IpAddrKind { V4(u8, u8, u8, u8), V6(String), } enum Message { Quit, Move { x: i32, y: i32 }, Write(String), ChangeColor(i32, i32, i32), } <|fim_suffix|> let home: IpAddrKind = IpAddrKind::V4(127, 0, 0, 1); ...
code_fim
hard
{ "lang": "rust", "repo": "DerDoni/rust_book", "path": "/rectangle/Enum/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl <'s> System<'s> for BallSystem { type SystemData = ( Read<'s, EventChannel<PongEvent>>, Entities<'s>, WriteStorage<'s, Ball>, WriteStorage<'s, Transform>, WriteStorage<'s, SpriteRender>, ReadExpect<'s, SpriteSheetHandler>, ReadExpect<'s, Tim...
code_fim
hard
{ "lang": "rust", "repo": "bateramos/pong-amethyst-demo", "path": "/src/systems/ball.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bateramos/pong-amethyst-demo path: /src/systems/ball.rs use amethyst::{ ecs::{Join, Entities, Read, WriteStorage, ReadExpect, System, SystemData, World}, assets::{Handle}, shrev::{EventChannel, ReaderId}, core::{SystemDesc, transform::Transform, timing::Time}, renderer::{Spri...
code_fim
hard
{ "lang": "rust", "repo": "bateramos/pong-amethyst-demo", "path": "/src/systems/ball.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for event in event_channel.read(&mut self.reader_id) { match event { PongEvent::Score => { for (entity, _ball) in (&*entities, &mut balls).join() { match entities.delete(entity) { Ok(_) => {}, ...
code_fim
hard
{ "lang": "rust", "repo": "bateramos/pong-amethyst-demo", "path": "/src/systems/ball.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut k = KBox::new_atom(42u8); println!("{}", k); assert_eq!(k.value(), 42); k.set_value(43); assert_eq!(k.value(), 43); }<|fim_prefix|>// repo: Fifthrow/rust-kdb path: /examples/using_atoms.rs extern crate kdb; use kdb::KBox; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "Fifthrow/rust-kdb", "path": "/examples/using_atoms.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fifthrow/rust-kdb path: /examples/using_atoms.rs extern crate kdb; use kdb::KBox; <|fim_suffix|> let mut k = KBox::new_atom(42u8); println!("{}", k); assert_eq!(k.value(), 42); k.set_value(43); assert_eq!(k.value(), 43); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "Fifthrow/rust-kdb", "path": "/examples/using_atoms.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Folyd/variant-counter path: /tests/no_std.rs #![cfg(not(feature = "std"))] use variant_counter::VariantCount; #[derive(VariantCount)] enum Lang { #[counter(group = "Non-GC")] Rust, #[counter(group = "Non-GC")] Cpp, #[counter(group = "GC")] Golang, #[counter(group = ...
code_fim
medium
{ "lang": "rust", "repo": "Folyd/variant-counter", "path": "/tests/no_std.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut counter = Lang::counter(); counter.record(&Lang::Rust); counter.record(&Lang::Cpp); counter.record(&Lang::Golang); counter.record(&Lang::Swift); let data = counter.group_aggregate(); assert_eq!(data[0], ("GC", 2)); assert_eq!(data[1], ("Non-GC", 2)); }<|fim_prefix|...
code_fim
medium
{ "lang": "rust", "repo": "Folyd/variant-counter", "path": "/tests/no_std.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azov/aprs-rs path: /src/lib.rs //! # Automatic Position Reporting System protocol //! //! ## What's APRS? //! Automatic Packet Reporting System (APRS) is a system for real time digital communication //! over HAM radio. It is a packet communications protocol for disseminating live data to //! e...
code_fim
hard
{ "lang": "rust", "repo": "azov/aprs-rs", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_latlng_precise(lat: f32, lng: f32, precision: Feet) -> Position { Position{ latitude: lat, longitude: lng, precision: Some(precision), } } pub fn set_precision(&mut self, precision : Feet) -> &mut Self { self.precision = S...
code_fim
hard
{ "lang": "rust", "repo": "azov/aprs-rs", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl IndexMut<Register> for Registers { fn index_mut(&mut self, r: Register) -> &mut u16 { &mut self.0[r as usize] } }<|fim_prefix|>// repo: Yamakaky/dcpu path: /src/emulator/registers.rs use std::ops::*; use types::Register; pub struct Registers([u16; 8]); impl Default for Registers {...
code_fim
medium
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/emulator/registers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yamakaky/dcpu path: /src/emulator/registers.rs use std::ops::*; use types::Register; pub struct Registers([u16; 8]); impl Default for Registers { fn default() -> Registers { Registers([0xdead; 8]) } } <|fim_suffix|>impl IndexMut<Register> for Registers { fn index_mut(&mut...
code_fim
medium
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/emulator/registers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lpc55/lpc55-pac path: /src/rtc/ctrl.rs } #[doc = "Field `ALARM1HZ` writer - RTC 1 Hz timer alarm flag status."] pub struct ALARM1HZ_W<'a> { w: &'a mut W, } impl<'a> ALARM1HZ_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: ALARM1HZ...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/rtc/ctrl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Field `WAKEDPD_EN` reader - RTC 1 kHz timer wake-up enable for Deep power-down."] pub struct WAKEDPD_EN_R(crate::FieldReader<bool, WAKEDPD_EN_A>); impl WAKEDPD_EN_R { #[inline(always)] pub(crate) fn new(bits: bool) -> Self { WAKEDPD_EN_R(crate::F...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/rtc/ctrl.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lpc55/lpc55-pac path: /src/rtc/ctrl.rs **self == SWRESET_A::NOT_IN_RESET } #[doc = "Checks if the value of the field is `IN_RESET`"] #[inline(always)] pub fn is_in_reset(&self) -> bool { **self == SWRESET_A::IN_RESET } } impl core::ops::Deref for SWRESET_R { ...
code_fim
hard
{ "lang": "rust", "repo": "lpc55/lpc55-pac", "path": "/src/rtc/ctrl.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Panchob/Advent-of-code-2020 path: /day01/src/main.rs use std::{ fs::File, io::{prelude::*, BufReader}, path::Path, }; fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> { let file = File::open(filename).expect("no such file"); let buf = BufReader::new(file); b...
code_fim
hard
{ "lang": "rust", "repo": "Panchob/Advent-of-code-2020", "path": "/day01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut res = 0; for x in vector.iter() { for y in vector.iter() { for z in vector.iter() { if x + y + z == 2020 { res = x * y * z } } } } res } fn main() { let lines = lines_from_file("...
code_fim
hard
{ "lang": "rust", "repo": "Panchob/Advent-of-code-2020", "path": "/day01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let lines = lines_from_file("input.txt"); let mut vector = vec![]; for line in lines { vector.push(line.parse::<i32>().unwrap()); } println!("Part 1: {}", part_1(&vector)); println!("Part 2: {}", part_2(&vector)); }<|fim_prefix|>// repo: Panchob/Advent-of-code-2020 path: /...
code_fim
hard
{ "lang": "rust", "repo": "Panchob/Advent-of-code-2020", "path": "/day01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: veekxt/xt_lang path: /src/lexer.rs use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::collections::HashMap; use std::fmt; use std::str::FromStr; #[derive(Clone)] pub enum Token { // literal STR(String), INT(isize), FLOAT(f64), // operational character ...
code_fim
hard
{ "lang": "rust", "repo": "veekxt/xt_lang", "path": "/src/lexer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { if let Some(now) = self.now_char() { if now == '\r' || now == ' ' || now == '\t' { self.i += 1; } else if is_comment_start(now) { self.i += 1; whil...
code_fim
hard
{ "lang": "rust", "repo": "veekxt/xt_lang", "path": "/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn is_num(c: char) -> bool { match c { '0' ... '9' => true, _ => false, } } fn is_str_start(c: char) -> bool { match c { '\"' => true, _ => false, } } fn is_comment_start(c: char) -> bool { match c { '#' => true, _ => false, } } im...
code_fim
hard
{ "lang": "rust", "repo": "veekxt/xt_lang", "path": "/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let color = get_color_for_operation_type(&operation.operation_type); vec![ operation.id.cell().justify(Justify::Right), operation.address.cell(), operation.denom.cell(), operation.amount.cell().justify(Justify::Right), operation .operation_type ...
code_fim
hard
{ "lang": "rust", "repo": "landanhu/ibc-solo-machine", "path": "/solo-machine/src/command/bank.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let table = history .into_iter() .map(into_row) .collect::<Vec<RowStruct>>() .table() .title(vec![ "ID".cell().bold(true), "Address".cell().bo...
code_fim
hard
{ "lang": "rust", "repo": "landanhu/ibc-solo-machine", "path": "/solo-machine/src/command/bank.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: landanhu/ibc-solo-machine path: /solo-machine/src/command/bank.rs use anyhow::{Context, Result}; use cli_table::{format::Justify, print_stdout, Cell, Color, Row, RowStruct, Style, Table}; use solo_machine_core::{ ibc::core::ics24_host::identifier::Identifier, model::{AccountOperation, Op...
code_fim
hard
{ "lang": "rust", "repo": "landanhu/ibc-solo-machine", "path": "/solo-machine/src/command/bank.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut l: usize = data.len(); unsafe { let buf_ptr = self.buffer.as_mut_ptr(); let mut data_ptr = data.as_ptr(); //add data in tail of rest buffer data if self.bufsize > 0 { let mut chunk = 64 - self.bufsize; ...
code_fim
hard
{ "lang": "rust", "repo": "ddulesov/rs_streebog", "path": "/src/streebog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write_bytes(ptr, 0, l); *ptr = 0x01; } } unsafe fn stage2(&mut self, data: *const u8) { self.h.g(&self.n, data); self.n.add(&BUFFER512); self.sigma.add_bytes(data); //_mm256_zeroupper(); } unsafe fn stage3(&mut self) { let...
code_fim
hard
{ "lang": "rust", "repo": "ddulesov/rs_streebog", "path": "/src/streebog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ddulesov/rs_streebog path: /src/streebog.rs //! An implementation of the [Streebog][1] cryptographic hash function. It's //! officially known as GOST R 34.11-2012. //! //! [1]: https://en.wikipedia.org/wiki/Streebog //! //! This implementation returns digest result using little-endian encoding /...
code_fim
hard
{ "lang": "rust", "repo": "ddulesov/rs_streebog", "path": "/src/streebog.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diodesign/diosix path: /src/hypervisor/src/virtmem.rs /* diosix capsule virtual memory management * * (c) Chris Williams, 2019-2020. * * See LICENSE for usage and copying. */ use platform::physmem::PhysMemBase; use platform::virtmem::VirtMemBase; use super::physmem::Region; use super::err...
code_fim
hard
{ "lang": "rust", "repo": "diodesign/diosix", "path": "/src/hypervisor/src/virtmem.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /* translate host physical address to capsule virtual address using this mapping, or None for outside mapping or None if translation not possible as mapping is not configured */ pub fn physical_to_virtual(&self, physaddr: PhysMemBase) -> Option<VirtMemBase> { match(self.virtual_bas...
code_fim
hard
{ "lang": "rust", "repo": "diodesign/diosix", "path": "/src/hypervisor/src/virtmem.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl LevelConfig { pub fn load(level_dir: PathBuf) -> Result<Self, ron::de::Error> { assert!(level_dir.is_dir()); let config_file = File::open(level_dir.join(constants::path::GAME_LEVELS_CFG_NAME.as_path())).map_err(|err| ron::de::Error::from(err))?; ron::de::from_reader::<File...
code_fim
medium
{ "lang": "rust", "repo": "S190762/dissertation-s190762", "path": "/src/eng/cfg/level_cfg.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: S190762/dissertation-s190762 path: /src/eng/cfg/level_cfg.rs use crate::{ eng::{ utils::{ constants } } }; use std::{ fs::{ File }, io::{ Write }, path::{ Path, PathBuf } }; use serde::{ Deserialize, ...
code_fim
medium
{ "lang": "rust", "repo": "S190762/dissertation-s190762", "path": "/src/eng/cfg/level_cfg.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eldruin/mcp794xx-rs path: /src/common/mod.rs use crate::{interface, BitFlags, Config, Error, Mcp794xx, OutputPinLevel, Register, SqWFreq}; pub mod alarm; pub mod conversion; pub mod datetime; pub mod sram; impl Config { pub(crate) fn with_high(self, mask: u8) -> Self { Config { ...
code_fim
hard
{ "lang": "rust", "repo": "eldruin/mcp794xx-rs", "path": "/src/common/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn write_control(&mut self, control: Config) -> Result<(), Error<E>> { self.iface.write_register(Register::CONTROL, control.bits)?; self.control = control; Ok(()) } #[allow(clippy::needless_pass_by_value)] fn check_lt<T: PartialOrd>(value: T, reference: T) -> Resul...
code_fim
hard
{ "lang": "rust", "repo": "eldruin/mcp794xx-rs", "path": "/src/common/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akks800/atcoder path: /abc183/src/bin/f.rs use proconio::input; #[allow(unused_imports)] use proconio::marker::{Bytes, Chars, Usize1}; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::ops::*; #[derive(Clone, Debug, De...
code_fim
hard
{ "lang": "rust", "repo": "akks800/atcoder", "path": "/abc183/src/bin/f.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // posの順に更新 let mut ans = vec![0; q]; let mut color_ct = vec![0; n]; let mut j = 0; for pos in 0..=n { while posq[j].pos == pos { if posq[j].is_add { ans[posq[j].qid] += color_ct[posq[j].color]; } else { ans[posq[j].qid] ...
code_fim
hard
{ "lang": "rust", "repo": "akks800/atcoder", "path": "/abc183/src/bin/f.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swipswaps/rust-pushrod path: /src/render/widget.rs License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF AN...
code_fim
hard
{ "lang": "rust", "repo": "swipswaps/rust-pushrod", "path": "/src/render/widget.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Sets a compass position for a configuration key. fn set_compass(&mut self, config: u8, value: CompassPosition) { self.get_config().set_compass(config, value); self.on_config_changed(config, Config::CompassPosition(value)); } /// Retrieves a `Points` for a configuration...
code_fim
hard
{ "lang": "rust", "repo": "swipswaps/rust-pushrod", "path": "/src/render/widget.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swipswaps/rust-pushrod path: /src/render/widget.rs e::LayoutContainer; use crate::render::texture_cache::TextureCache; use crate::render::texture_store::TextureStore; use crate::render::widget_cache::WidgetContainer; use crate::render::widget_config::*; use crate::render::{Points, Size}; use sdl...
code_fim
hard
{ "lang": "rust", "repo": "swipswaps/rust-pushrod", "path": "/src/render/widget.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hamersaw/ruzzy path: /src/jaro.rs pub fn compare(a: &str, b: &str) -> f64 { let (astr, bstr) = if a.len() < b.len() { (b.to_string(), a.to_string()) } else { (a.to_string(), b.to_string()) }; let max_distance = astr.len() as i32 / 2; let a_match = get_matchi...
code_fim
hard
{ "lang": "rust", "repo": "hamersaw/ruzzy", "path": "/src/jaro.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn compare_empty() { assert_eq!(compare("", ""), 0.0); } #[test] fn compare_eq_small() { assert_eq!(compare("x", "x"), 2.3333333333333335); } #[test] fn compare_ne_small() { assert_eq!(compare("x", "y"), 0.0); } #[test] fn compare_eq_large() { assert_eq!(compare("alphabet", "alp...
code_fim
hard
{ "lang": "rust", "repo": "hamersaw/ruzzy", "path": "/src/jaro.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn send_lambda_flatmap_query(&self, message_list:ListProto, lambda_index: &str) -> (ListProto, ListLong) { let mut message = LambdaData::new(); message.set_query_id(self.query_id.clone()); message.set_lambda_index(lambda_index.to_string()); message.set_message_list(...
code_fim
hard
{ "lang": "rust", "repo": "LDA111222/GraphScope", "path": "/interactive_engine/src/executor/runtime/src/dataflow/manager/lambda.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LDA111222/GraphScope path: /interactive_engine/src/executor/runtime/src/dataflow/manager/lambda.rs // //! Copyright 2020 Alibaba Group Holding Limited. //! //! Licensed under the Apache License, Version 2.0 (the "License"); //! you may not use this file except in compliance with the License. //...
code_fim
hard
{ "lang": "rust", "repo": "LDA111222/GraphScope", "path": "/interactive_engine/src/executor/runtime/src/dataflow/manager/lambda.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut response = self.lambda_service_client.as_ref().unwrap().map(&message).unwrap(); response.take_message_list() } pub fn send_lambda_flatmap_query(&self, message_list:ListProto, lambda_index: &str) -> (ListProto, ListLong) { let mut message = LambdaData::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "LDA111222/GraphScope", "path": "/interactive_engine/src/executor/runtime/src/dataflow/manager/lambda.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elba/website path: /src/login.rs use actix::prelude::*; use actix_web::FutureResponse; use failure::Error; use reqwest::r#async::Client; use reqwest::StatusCode; use std::sync::Arc; use tokio_async_await::await; use crate::database::Database; use crate::model::users::CreateUserOrLogin; use crat...
code_fim
hard
{ "lang": "rust", "repo": "elba/website", "path": "/src/login.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let user_id = await!(self_addr.send(LoginByAccessToken { gh_access_token: response_json.access_token }))??; Ok(user_id) } None => Err(human!( ...
code_fim
hard
{ "lang": "rust", "repo": "elba/website", "path": "/src/login.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shanithkk/RustExercism path: /spiral-matrix/src/lib.rs pub fn spiral_matrix(size: u32) -> Vec<Vec<u32>> { let size = size as usize; let mut matrix = vec![vec![0; size]; size]; if size == 0 { return matrix; } matrix[0][0] = 1; <|fim_suffix|> // down wh...
code_fim
hard
{ "lang": "rust", "repo": "shanithkk/RustExercism", "path": "/spiral-matrix/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // down while i <= size - 2 && matrix[i + 1][j] == 0 { i += 1; matrix[i][j] = val; val += 1; } // left while j >= 1 && matrix[i][j - 1] == 0 { j -= 1; matrix[i][j] = val; val += 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "shanithkk/RustExercism", "path": "/spiral-matrix/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RevelationOfTuring/Rust-exercise path: /src/lifetimes/explicit_annotation.rs /* 显式标注 借用检查器使用显式的生命周期标记来明确引用的有效时间应该持续多久。 在生命周期没有省略的情况下,Rust 需要显式标注来确定引用的生命周期应该是什么样的。 可以用撇号`'`显式地标出生命周期,语法如下: foo<'a> // foo带有一个声明周期参数 `'a` 和闭包类似,使用生命周期需要`泛型`。 另外这个生命周期的语法也表明了 f...
code_fim
hard
{ "lang": "rust", "repo": "RevelationOfTuring/Rust-exercise", "path": "/src/lifetimes/explicit_annotation.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let x = 1024; // 编译报错:error[E0597]: `x` does not live long enough // let y: &'a i32 = &x; // 因为x是在函数内部声明的,它的生命周期一定小于函数的生命周期'a // 在函数内部使用生命周期 `'a` 作为显式类型标注将导致失败, // 短生命周期不能强制转换成长生命周期。(&x为短生命周期,向长生命周期'a转换) } #[test] fn test_explicit_annotation() {...
code_fim
hard
{ "lang": "rust", "repo": "RevelationOfTuring/Rust-exercise", "path": "/src/lifetimes/explicit_annotation.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for arg_index in arg_embedding_space.models.keys() { let arg_ptr = TermPointer { type_id : arg_type_id, index : *arg_index }; let arg_ref = TermReference::FuncRef(arg_ptr); ...
code_fim
hard
{ "lang": "rust", "repo": "bubble-07/FETISH-OPT", "path": "/src/sampled_embedder_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bubble-07/FETISH-OPT path: /src/sampled_embedder_state.rs use ndarray::*; use fetish_lib::everything::*; use crate::sampled_value_field_state::*; use crate::sampled_embedding_space::*; pub fn get_best_nonvector_application_with_value(state : &SampledEmbedderState, value_field_state : &SampledVa...
code_fim
hard
{ "lang": "rust", "repo": "bubble-07/FETISH-OPT", "path": "/src/sampled_embedder_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_best_term_to_apply(state : &SampledEmbedderState, compressed_arg_vector : &TypedVector, func_type_id : TypeId, value_field_state : &SampledValueFieldState) -> Option<(TermPointer, TypedVector, f32)> { let ret_type_id = state...
code_fim
hard
{ "lang": "rust", "repo": "bubble-07/FETISH-OPT", "path": "/src/sampled_embedder_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jhartzell42/zbus path: /zvariant_derive/src/type.rs use proc_macro2::TokenStream; use quote::{quote, ToTokens}; use syn::{self, Attribute, Data, DataEnum, DeriveInput, Fields, Generics, Ident}; use crate::utils::zvariant_path; pub fn expand_derive(ast: DeriveInput) -> TokenStream { let zv ...
code_fim
hard
{ "lang": "rust", "repo": "jhartzell42/zbus", "path": "/zvariant_derive/src/type.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> name: Ident, generics: Generics, attrs: Vec<Attribute>, data: DataEnum, zv: &TokenStream, ) -> TokenStream { let repr: TokenStream = match attrs.iter().find(|attr| attr.path.is_ident("repr")) { Some(repr_attr) => repr_attr .parse_args() .expect("Fail...
code_fim
hard
{ "lang": "rust", "repo": "jhartzell42/zbus", "path": "/zvariant_derive/src/type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn impl_enum( name: Ident, generics: Generics, attrs: Vec<Attribute>, data: DataEnum, zv: &TokenStream, ) -> TokenStream { let repr: TokenStream = match attrs.iter().find(|attr| attr.path.is_ident("repr")) { Some(repr_attr) => repr_attr .parse_args() ...
code_fim
hard
{ "lang": "rust", "repo": "jhartzell42/zbus", "path": "/zvariant_derive/src/type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HaoXuan40404/ursa path: /libursa/src/encoding/hex.rs use CryptoError; pub fn bin2hex(b: &[u8]) -> String { b.iter() .map(|b| format!("{:02x}", b)) .collect::<Vec<_>>() .join("") } pub fn hex2bin(s: &str) -> Result<Vec<u8>, CryptoError> { if s.len() % 2 != 0 { ...
code_fim
medium
{ "lang": "rust", "repo": "HaoXuan40404/ursa", "path": "/libursa/src/encoding/hex.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let decoded: Vec<u8> = input .chunks(2) .map(|chunk| { ((chunk[0].to_digit(16).unwrap() << 4) | (chunk[1].to_digit(16).unwrap())) as u8 }) .collect(); Ok(decoded) }<|fim_prefix|>// repo: HaoXuan40404/ursa path: /libursa/src/encoding/hex.rs use CryptoEr...
code_fim
medium
{ "lang": "rust", "repo": "HaoXuan40404/ursa", "path": "/libursa/src/encoding/hex.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: taegyunkim/KimchiFriedRice path: /sample/src/main.rs use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; fn main() { let args: Vec<String> = env::args().collect(); if args.len() != 2 { println!("Please specify the dat...
code_fim
hard
{ "lang": "rust", "repo": "taegyunkim/KimchiFriedRice", "path": "/sample/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut types = 0; let mut indices: Vec<usize> = Vec::new(); for (_, v) in sizes_to_indices { types += v.len(); indices.extend(v.iter()); } println!("{}", types); println!( "{}", indices .iter() .map(|n| n.to_string()) ...
code_fim
hard
{ "lang": "rust", "repo": "taegyunkim/KimchiFriedRice", "path": "/sample/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Self { _instance: ManuallyDrop::new(instance), _surface: surface, _adapter: adapter, device: ManuallyDrop::new(device), queue_group, swapchain: ManuallyDrop::new(swapchain), render_area: extent.to_extent().rect(...
code_fim
hard
{ "lang": "rust", "repo": "colibre/nicegfx", "path": "/src/hal_state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: colibre/nicegfx path: /src/hal_state.rs ice, queue_group) = { let queue_family = adapter .queue_families .iter() .find(|qf| qf.supports_graphics() && surface.supports_queue_family(qf)) .ok_or("Couldn't find a QueueFamily...
code_fim
hard
{ "lang": "rust", "repo": "colibre/nicegfx", "path": "/src/hal_state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: colibre/nicegfx path: /src/hal_state.rs ut surface = instance.create_surface(window); let adapter = instance .enumerate_adapters() .into_iter() .find(|a| { a.queue_families .iter() .any(|qf| qf.su...
code_fim
hard
{ "lang": "rust", "repo": "colibre/nicegfx", "path": "/src/hal_state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn longest2<'a>(x: &str, y: &str) -> String { let result = String::from("really long string"); result } // fn longest2(str1 : &str,str2 : &str) -> &str { // if str1.len() > str2.len() { // str1 // } else { // str2 // } // } fn longest<'a>(str1: &'a str, str2: &'a str)...
code_fim
hard
{ "lang": "rust", "repo": "Mark80/rust-projects", "path": "/life_time/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mark80/rust-projects path: /life_time/src/main.rs use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; struct ImportantExcerpt<'a> { part: &'a str, } struct RpcServer {} struct TpcStream {} enum RHState { Start, Complete, Running, } struct RequestHandl...
code_fim
hard
{ "lang": "rust", "repo": "Mark80/rust-projects", "path": "/life_time/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alerdenisov/unrust path: /src/engine/imgui/image.rs use super::Metric; use super::instance::ImguiState; use super::widgets; use super::widgets::Widget; use engine::{Asset, GameObject, IEngine, Material, Mesh, MeshBuffer, MeshData, RenderQueue, Texture}; use std::cell::RefCel...
code_fim
hard
{ "lang": "rust", "repo": "alerdenisov/unrust", "path": "/src/engine/imgui/image.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Game Object let go = engine.new_game_object(parent); let mut gomut = go.borrow_mut(); let mut gtrans = gomut.transform.global(); gtrans.disp += widgets::compute_translate( &self.pos, &self.pivot, &ssize, h...
code_fim
hard
{ "lang": "rust", "repo": "alerdenisov/unrust", "path": "/src/engine/imgui/image.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hmc-memsafe-2016f/wk4-starter path: /rc/tests/required.rs #![feature(alloc_system)] extern crate alloc_system; extern crate my_rc; // This macro is an assertion with nicely formatted failure output macro_rules! assert_expected_eq_actual { ($a:expr, $b:expr) => ({ let (a, b) = (&$a,...
code_fim
hard
{ "lang": "rust", "repo": "hmc-memsafe-2016f/wk4-starter", "path": "/rc/tests/required.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.d_count.set(self.d_count.get() + 1); } } #[test] fn destrutors_run() { let d_count = Rc::new(Cell::new(0)); { let rc = MyRc::new(D { d_count: d_count.clone() }); { let rc2 = rc.clone(); assert_exp...
code_fim
hard
{ "lang": "rust", "repo": "hmc-memsafe-2016f/wk4-starter", "path": "/rc/tests/required.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn deref() { let x = MyRc::new(5); let y = x.clone(); assert_expected_eq_actual!(5, *x); assert_expected_eq_actual!(5, *y); } #[test] fn deref_identity() { let x = MyRc::new(Cell::new(5)); let y = x.clone(); y.set(6); ...
code_fim
hard
{ "lang": "rust", "repo": "hmc-memsafe-2016f/wk4-starter", "path": "/rc/tests/required.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: baitcenter/dto_derive path: /src/parse.rs use proc_macro2::Span; use syn::parse::{Parse, ParseStream}; use syn::{parenthesized, Attribute, Result}; mod entity_struct_attr; pub(crate) use self::entity_struct_attr::EntityStructAttr; mod skip_struct_attr; pub(crate) use self::skip_struct_attr::Sk...
code_fim
hard
{ "lang": "rust", "repo": "baitcenter/dto_derive", "path": "/src/parse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn parse_struct_attrs<T>(attrs: &Vec<Attribute>, mut handler: T) -> Result<()> where T: FnMut(StructAttr) -> Result<()>, { for ref attr in attrs.iter().filter(|attr| attr.path.is_ident("dto")) { handler(syn::parse2(attr.tts.clone())?)?; } Ok(()) }<|fim_prefix|>// repo: b...
code_fim
hard
{ "lang": "rust", "repo": "baitcenter/dto_derive", "path": "/src/parse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }