text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let mut v1 = vec![5, 3, 4, 1, 6, 2]; { quicksort(&mut v1); } assert_eq!(&v1, &[1, 2, 3, 4, 5, 6]); } }<|fim_prefix|>// repo: 0xack13/programming-rust path: /chapter_05/quicksort_borrow/src/lib.rs pub fn quicksort(list: &mut [i32]) { if list.len() <= 1 {...
code_fim
hard
{ "lang": "rust", "repo": "0xack13/programming-rust", "path": "/chapter_05/quicksort_borrow/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn it_works() { let mut v1 = vec![5, 3, 4, 1, 6, 2]; { quicksort(&mut v1); } assert_eq!(&v1, &[1, 2, 3, 4, 5, 6]); } }<|fim_prefix|>// repo: 0xack13/programming-rust path: /chapter_05/quicksort_bor...
code_fim
hard
{ "lang": "rust", "repo": "0xack13/programming-rust", "path": "/chapter_05/quicksort_borrow/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xack13/programming-rust path: /chapter_05/quicksort_borrow/src/lib.rs pub fn quicksort(list: &mut [i32]) { if list.len() <= 1 { return; } else if list.len() == 2 { if list[0] > list[1] { list.swap(0, 1); } return; } let pivot = list[0...
code_fim
medium
{ "lang": "rust", "repo": "0xack13/programming-rust", "path": "/chapter_05/quicksort_borrow/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn validate_field_and_values(field: &str) -> i8 { if valid_field(field) == 1 { let mut data = field.split(":"); fields() .get(data.next().unwrap()) .unwrap() .validate(data.next().unwrap().to_string()) as i8 } else { 0 } } impl Valid...
code_fim
hard
{ "lang": "rust", "repo": "savekirk/advent-of-code-2020", "path": "/src/days/four.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: savekirk/advent-of-code-2020 path: /src/days/four.rs use regex::Regex; use std::collections::HashMap; pub fn part1(lines: Vec<String>) -> usize { count_valid_passports(lines, valid_field) } pub fn part2(lines: Vec<String>) -> usize { count_valid_passports(lines, validate_field_and_valu...
code_fim
hard
{ "lang": "rust", "repo": "savekirk/advent-of-code-2020", "path": "/src/days/four.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Snell's law: // sin (incident) / sin(refracted) = n_inside / n_outside // So: sin (refracted) = (n_outside / n_inside) * sin (incident) let sine_incident = (1.0 - cosine_incident * cosine_incident).sqrt(); let sine_refracted = n * sine_incident; let cosin...
code_fim
hard
{ "lang": "rust", "repo": "ChCronstrom/rayon", "path": "/src/texture/glass.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn fresnel_equations(index_of_refraction: Float, cosine_incident: Float, cosine_refracted: Float) -> Float { let reflectance_s_sqrt = (cosine_incident - index_of_refraction * cosine_refracted) / (cosine_incident + index_of_refraction * cosine_refracted); let reflectan...
code_fim
hard
{ "lang": "rust", "repo": "ChCronstrom/rayon", "path": "/src/texture/glass.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChCronstrom/rayon path: /src/texture/glass.rs use basics::*; use texture::{Texture, LightInteraction}; use na::{Norm}; use rand::{Rand}; #[derive(Clone, Copy, Debug)] pub struct Glass { index_of_refraction: Float, } impl Glass { pub fn new(index_of_refraction: Float) -> Glass { ...
code_fim
hard
{ "lang": "rust", "repo": "ChCronstrom/rayon", "path": "/src/texture/glass.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nanpuyue/nc path: /src/platform/linux-ppc64/mod.rs pub mod call; pub mod errno; pub mod sysno; #[cfg(not(nightly))] use crate::syscalls; pub use call::*; pub use errno::*; pub use sysno::*; const MAX_ERRNO: i32 = 4095; #[inline(always)] pub fn check_errno(ret: usize) -> Result<usize, Errno> {...
code_fim
hard
{ "lang": "rust", "repo": "nanpuyue/nc", "path": "/src/platform/linux-ppc64/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(nightly)] #[inline(always)] pub unsafe fn syscall4( n: Sysno, a1: usize, a2: usize, a3: usize, a4: usize, ) -> Result<usize, Errno> { let mut r0 = n; let mut r3 = a1; let mut r4 = a2; let mut r5 = a3; let mut r6 = a4; asm!("sc" : "+{r0}"(r0), "+{r...
code_fim
hard
{ "lang": "rust", "repo": "nanpuyue/nc", "path": "/src/platform/linux-ppc64/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(nightly)] #[inline(always)] pub unsafe fn syscall1(n: Sysno, a1: usize) -> Result<usize, Errno> { let mut r0 = n; let mut r3 = a1; asm!("sc" : "+{r0}"(r0), "+{r3}"(r3) : : "memory", "cr0", "r4", "5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" : "volat...
code_fim
hard
{ "lang": "rust", "repo": "nanpuyue/nc", "path": "/src/platform/linux-ppc64/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.debug_type != DebugType::NONE { self.debug_effect.as_ref().unwrap().program().add_uniform_mat4("viewProjectionInverse", &(camera.get_projection() * camera.get_view()).invert().unwrap())?; self.debug_effect.as_ref().unwrap().program().use_texture(self.geometry_pass_t...
code_fim
hard
{ "lang": "rust", "repo": "6174/three-d", "path": "/src/phong/renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 6174/three-d path: /src/phong/renderer.rs use crate::*; use std::rc::Rc; use crate::PhongForwardMesh; pub struct PhongForwardPipeline { gl: Gl, mesh_color_ambient_program: Rc<Program>, mesh_color_ambient_directional_program: Rc<Program>, mesh_texture_ambient_program: Rc<Program...
code_fim
hard
{ "lang": "rust", "repo": "6174/three-d", "path": "/src/phong/renderer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jashka34/myprojecteuler path: /problem003/rust/src/prime.rs pub fn is_prime(n: u64) -> bool { //println!("------------------"); //println!("is_prime: {}", n); if n == 2 { return true; } if n % 2 == 0 { return false; } e...
code_fim
hard
{ "lang": "rust", "repo": "jashka34/myprojecteuler", "path": "/problem003/rust/src/prime.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(is_prime(2)); assert!(!is_prime(4)); assert!( is_prime(5)); assert!(!is_prime(15)); assert!( is_prime(29)); assert!( is_prime(73)); assert!(!is_prime(74)); assert!(!is_prime(91)); assert!( is_prime(97)); assert!(!is_pr...
code_fim
hard
{ "lang": "rust", "repo": "jashka34/myprojecteuler", "path": "/problem003/rust/src/prime.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }, if l.light.state.xy.is_some() { l.light.state.xy.unwrap().0 } else { 0.0 }, if l.light.state.xy.is_some() { l.light.state.xy.unwrap().1 ...
code_fim
hard
{ "lang": "rust", "repo": "kali/hue.rs", "path": "/src/bin/hue_get_all_lights.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }, if l.light.state.sat.is_some() { l.light.state.sat.unwrap() } else { 0 }, if l.light.state.ct.is_some() { l.light .st...
code_fim
hard
{ "lang": "rust", "repo": "kali/hue.rs", "path": "/src/bin/hue_get_all_lights.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kali/hue.rs path: /src/bin/hue_get_all_lights.rs extern crate hueclient; use std::env; #[allow(dead_code)] fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 2 { println!("usage : {:?} <username>", args[0]); return; } let bridge = hueclien...
code_fim
hard
{ "lang": "rust", "repo": "kali/hue.rs", "path": "/src/bin/hue_get_all_lights.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type Node = state::Node<State>; impl State { pub fn start(player_1_team: Team, player_2_team: Team) -> Node { let state = State { player_1: PlayerState { team: player_1_team, active_pokemon_idx: None, turn_action: None, ...
code_fim
hard
{ "lang": "rust", "repo": "Palladinium/tiketetaketitak", "path": "/src/single.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Palladinium/tiketetaketitak path: /src/single.rs use strum_macros::Display; use crate::{ pokemon::{Pokemon, Team}, state::{self, DecisionBuilder, EventHandler, PlayerBase, PlayerStateBase, StateBase}, }; #[derive(Debug, Clone)] pub struct State { player_1: PlayerState, player_2...
code_fim
hard
{ "lang": "rust", "repo": "Palladinium/tiketetaketitak", "path": "/src/single.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fedelebron/rust-raytracing-in-one-weekend path: /src/material2.rs use crate::object::*; use crate::ray::*; use crate::texture::*; use crate::vec3::*; use rand::Rng; type T = f32; pub struct ScatterResult { pub attenuation: Color, pub scattered_ray: Ray, } #[derive(Clone)] pub enum Material...
code_fim
hard
{ "lang": "rust", "repo": "fedelebron/rust-raytracing-in-one-weekend", "path": "/src/material2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> refraction_index: T, incident_ray: &Ray, hit: &HitResultPayload, ) -> Option<ScatterResult> { let attenuation = Color::new(1.0, 1.0, 1.0); let refraction_ratio = if hit.front_face { 1.0 / refraction_index } else { refraction_index }; let r = incident_ray.direction; let unit_dire...
code_fim
hard
{ "lang": "rust", "repo": "fedelebron/rust-raytracing-in-one-weekend", "path": "/src/material2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Urhengulas/pl_from_scratch path: /eldiro/src/expr.rs use crate::utils::*; use crate::val::Val; #[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] pub struct Number(pub i32); impl Number { pub fn new(s: &str) -> Result<(Self, &str), String> { let (num, s) = extract_digits(s)?; ...
code_fim
hard
{ "lang": "rust", "repo": "Urhengulas/pl_from_scratch", "path": "/eldiro/src/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Op::new("+"), Ok((Op::Add, ""))); } #[test] fn parse_sub_op() { assert_eq!(Op::new("-"), Ok((Op::Sub, ""))); } #[test] fn parse_mul_op() { assert_eq!(Op::new("*"), Ok((Op::Mul, ""))); } #[test] fn parse_div_op() { assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "Urhengulas/pl_from_scratch", "path": "/eldiro/src/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //fn get_accept_policy<'a, 'b, P: Into<Option<&'a gio::Cancellable>>, Q: Into<Option<&'b /*Ignored*/gio::AsyncReadyCallback>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, cancellable: P, callback: Q, user_data: R); //#[cfg_attr(feature = "v2_16", deprecated)] //fn get_doma...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/webkit2gtk-rs", "path": "/src/auto/cookie_manager.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: antoyo/webkit2gtk-rs path: /src/auto/cookie_manager.rs // This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4) // from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) // DO NOT EDIT use CookieAcceptPolicy; use CookiePersistentStorage; use ffi; use glib; use glib::o...
code_fim
hard
{ "lang": "rust", "repo": "antoyo/webkit2gtk-rs", "path": "/src/auto/cookie_manager.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use chrono::prelude::*; #[test] fn test_blog_posts() { let conn = SqliteConnection::establish("../test-assets/test-access.db").expect("To open db"); let rng = Range { from: Utc.ymd(2017, 11, 14).and_hms(13, 0, ...
code_fim
hard
{ "lang": "rust", "repo": "fengweijp/rrinlog", "path": "/rrinlog-server/src/dao.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( result[0], BlogPost { referer: "https://nbsoftsolutions.com/blog/monitoring-windows-system-metrics-with-grafana" .to_string(), views: 6, } ); assert_eq!( result[1], ...
code_fim
hard
{ "lang": "rust", "repo": "fengweijp/rrinlog", "path": "/rrinlog-server/src/dao.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fengweijp/rrinlog path: /rrinlog-server/src/dao.rs use diesel::prelude::*; use diesel::types::*; use diesel::sql_query; use diesel::query_source::QueryableByName; use diesel::sqlite::Sqlite; use diesel::row::NamedRow; use std::error::Error; use api::*; use dim::si; #[derive(PartialEq, Debug)] p...
code_fim
hard
{ "lang": "rust", "repo": "fengweijp/rrinlog", "path": "/rrinlog-server/src/dao.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let s = NSString::from_str(s); let ptr = msg_send![class!(NSURL), URLWithString: s]; Id::from_retained_ptr(ptr) } } fn absolute_string(&self) -> Id<NSString> { unsafe { let s = msg_send![self, absoluteString]; ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/native-dialog-rs", "path": "/src/dialog_impl/mac/ffi/cocoa/url.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/native-dialog-rs path: /src/dialog_impl/mac/ffi/cocoa/url.rs use objc_foundation::{INSObject, INSString, NSString}; use objc_id::Id; use std::path::PathBuf; pub trait INSURL: INSObject { fn from_str(s: &str) -> Id<Self> { unsafe { let s = NSString::from_str(s); ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/native-dialog-rs", "path": "/src/dialog_impl/mac/ffi/cocoa/url.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("low_points: {}", low_point_values.len()); println!( "risk: {}", low_point_values.iter().map(|p| p + 1).sum::<u32>() ); }<|fim_prefix|>// repo: harcomaase/aoc path: /rs-21/src/bin/day9.rs fn main() { let file_content = std::fs::read_to_string("../input/21/day9.txt...
code_fim
hard
{ "lang": "rust", "repo": "harcomaase/aoc", "path": "/rs-21/src/bin/day9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harcomaase/aoc path: /rs-21/src/bin/day9.rs fn main() { let file_content = std::fs::read_to_string("../input/21/day9.txt").expect("read input file"); let input: Vec<Vec<u32>> = file_content .lines() .map(|line| line.chars().map(|c| c.to_digit(10).unwrap()).collect()) ...
code_fim
hard
{ "lang": "rust", "repo": "harcomaase/aoc", "path": "/rs-21/src/bin/day9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> => { match $e { Ok(e) => e, Err(_e) => return $r, } }; }<|fim_prefix|>// repo: stcfd/starcoin path: /cmd/faucet/src/lib.rs pub mod faucet; pub mod web; #[macro_export] macr<|fim_middle|>o_rules! unwrap_or_return { ($e:expr, $r:expr)
code_fim
easy
{ "lang": "rust", "repo": "stcfd/starcoin", "path": "/cmd/faucet/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Err(_e) => return $r, } }; }<|fim_prefix|>// repo: stcfd/starcoin path: /cmd/faucet/src/lib.rs pub mod faucet; pub mod web; #[macro_export] macro_rules! unwrap_or_return { ($e:expr, $r:expr)<|fim_middle|> => { match $e { Ok(e) => e,
code_fim
easy
{ "lang": "rust", "repo": "stcfd/starcoin", "path": "/cmd/faucet/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stcfd/starcoin path: /cmd/faucet/src/lib.rs pub mod faucet; pub mod web; #[macro_export] macr<|fim_suffix|> Err(_e) => return $r, } }; }<|fim_middle|>o_rules! unwrap_or_return { ($e:expr, $r:expr) => { match $e { Ok(e) => e,
code_fim
medium
{ "lang": "rust", "repo": "stcfd/starcoin", "path": "/cmd/faucet/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Trait for combinations of `Memory` and `Ownership` that can be dereferenced safely. /// This is an internal interface. pub unsafe trait SafeDeref<Kind: Memory, Own: Ownership> { /// Returns a safe reference to the underlying object. #[doc(hidden)] fn impl_as_ref<T: GodotObject<Memory = Kin...
code_fim
hard
{ "lang": "rust", "repo": "tom-leys/godot-rust", "path": "/gdnative-core/src/object/bounds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, 'r> LifetimeConstraint<ManuallyManaged> for AssumeSafeLifetime<'a, 'r> {} impl<'a, 'r: 'a> LifetimeConstraint<RefCounted> for AssumeSafeLifetime<'a, 'r> {} // -----------------------------------------------------------------------------------------------------------------------------------------...
code_fim
hard
{ "lang": "rust", "repo": "tom-leys/godot-rust", "path": "/gdnative-core/src/object/bounds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tom-leys/godot-rust path: /gdnative-core/src/object/bounds.rs //! Various traits to verify memory policy, ownership policy or lifetime bounds //! //! The symbols defined in this module are internal and used to enhance type safety. //! You typically will not need to work with them. use crate::ob...
code_fim
hard
{ "lang": "rust", "repo": "tom-leys/godot-rust", "path": "/gdnative-core/src/object/bounds.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: summerlinryan/myo path: /core/src/lib.rs #![no_std] #![no_main] #![feature(custom_test_frameworks)] #![test_runner(crate::test::test_runner)] #![reexport_test_harness_main = "test_main"] #![feature(abi_x86_interrupt)] <|fim_suffix|>#[cfg(test)] #[no_mangle] pub extern "C" fn _start() -> ! { ...
code_fim
medium
{ "lang": "rust", "repo": "summerlinryan/myo", "path": "/core/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] #[no_mangle] pub extern "C" fn _start() -> ! { test_main(); loop {} }<|fim_prefix|>// repo: summerlinryan/myo path: /core/src/lib.rs #![no_std] #![no_main] #![feature(custom_test_frameworks)] #![test_runner(crate::test::test_runner)] #![reexport_test_harness_main = "test_main"] #![fe...
code_fim
medium
{ "lang": "rust", "repo": "summerlinryan/myo", "path": "/core/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marccane/RayRuster path: /src/raytracing/hit_record.rs //use cgmath::Point3; //use cgmath::{Vector3, Point3}; use cgmath::prelude::InnerSpace; use crate::raytracing::{Point32, Vec3, Ray2, Material}; <|fim_suffix|> #[inline] pub fn set_face_normal(&mut self, r: &Ray2, outward_normal: Vec...
code_fim
hard
{ "lang": "rust", "repo": "marccane/RayRuster", "path": "/src/raytracing/hit_record.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn set_face_normal(&mut self, r: &Ray2, outward_normal: Vec3) { self.front_face = r.dir.dot(outward_normal) < 0.0; self.normal = if self.front_face { outward_normal } else { -outward_normal }; } }<|fim_prefix|>// repo: marccane/RayRuster path: /src/raytracing/hit...
code_fim
hard
{ "lang": "rust", "repo": "marccane/RayRuster", "path": "/src/raytracing/hit_record.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let window = RefCell::new(window); for e in event::events(&window) { use event::RenderEvent; first_person.event(&e); if let Some(args) = e.render_args() { graphics.clear( gfx::ClearData { color: [0.3, 0.3, 0.3, 1.0], ...
code_fim
hard
{ "lang": "rust", "repo": "robo-corg/piston-examples", "path": "/gfx_cube/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>//---------------------------------------- fn main() { let (win_width, win_height) = (640, 480); let mut window = Sdl2Window::new( shader_version::OpenGL::_3_2, window::WindowSettings { title: "cube".to_string(), size: [win_width, win_height], f...
code_fim
hard
{ "lang": "rust", "repo": "robo-corg/piston-examples", "path": "/gfx_cube/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robo-corg/piston-examples path: /gfx_cube/src/main.rs #![feature(plugin)] #![feature(collections)] #![allow(unstable)] #![crate_name = "cube"] extern crate quack; extern crate shader_version; extern crate vecmath; extern crate event; extern crate window; extern crate input; extern crate cam; ex...
code_fim
hard
{ "lang": "rust", "repo": "robo-corg/piston-examples", "path": "/gfx_cube/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 2color/prisma-engines path: /migration-engine/migration-engine-tests/tests/list_migration_directories/mod.rs use crate::*; #[test_each_connector] async fn list_migration_directories_with_an_empty_migrations_folder_works(api: &TestApi) -> TestResult { let migrations_directory = api.create_mi...
code_fim
hard
{ "lang": "rust", "repo": "2color/prisma-engines", "path": "/migration-engine/migration-engine-tests/tests/list_migration_directories/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> api.apply_migrations(&migrations_directory) .send() .await? .assert_applied_migrations(&["init"])?; api.list_migration_directories(&migrations_directory) .send() .await? .assert_listed_directories(&["init"])?; Ok(()) }<|fim_prefix|>// repo: 2co...
code_fim
hard
{ "lang": "rust", "repo": "2color/prisma-engines", "path": "/migration-engine/migration-engine-tests/tests/list_migration_directories/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod model; #[cfg(test)] mod tests;<|fim_prefix|>// repo: tarkah/stats-api path: /src/lib.rs mod client; #[cfg(feature = "mlb")] pub use client::mlb::Client as MlbClient; <|fim_middle|>#[cfg(feature = "nhl")] pub use client::nhl::Client as NhlClient;
code_fim
medium
{ "lang": "rust", "repo": "tarkah/stats-api", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests;<|fim_prefix|>// repo: tarkah/stats-api path: /src/lib.rs mod client; #[cfg(feature = "mlb")] pub use client::mlb::Client as MlbClient; #[cfg(feature = "nhl")] pub use client::nhl::Client as NhlClient; <|fim_middle|>pub mod model;
code_fim
easy
{ "lang": "rust", "repo": "tarkah/stats-api", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarkah/stats-api path: /src/lib.rs mod client; #[cfg(feature = "mlb")] pub use client::mlb::Client as MlbClient; #[cfg(feature = "nhl")] pub use client::nhl::Client as NhlClient; <|fim_suffix|>#[cfg(test)] mod tests;<|fim_middle|>pub mod model;
code_fim
easy
{ "lang": "rust", "repo": "tarkah/stats-api", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let output = i64_file("./tests/i64.txt").unwrap(); assert_eq!(output, [104042, 112116, 57758, 139018, 105580]); } #[test] fn test_i64_csv() { let output = i64_csv("./tests/i64.csv").unwrap(); assert_eq!(output, [104042, 112116, 57758, 139018, 105580]); }<|fim_prefix|>// repo: colvinwellbo...
code_fim
hard
{ "lang": "rust", "repo": "colvinwellborn/advent-of-code-2019", "path": "/parse_input/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: colvinwellborn/advent-of-code-2019 path: /parse_input/src/lib.rs use std::fs::File; use std::io::prelude::*; pub fn file(p: &str) -> std::io::Result<Vec<String>> { let mut input = String::new(); let mut f = File::open(p)?; f.read_to_string(&mut input)?; let r: Vec<String> = inp...
code_fim
medium
{ "lang": "rust", "repo": "colvinwellborn/advent-of-code-2019", "path": "/parse_input/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>missing-attr = { foo.missing } missing-missing = { missing.missing } ", ); let bundle = assert_get_bundle_no_errors(&res, None); assert_format_no_errors(bundle.format("use-foo", None), "Foo"); assert_format_no_errors(bundle.format("use-foo-attr", None), "Foo Attr"); assert_forma...
code_fim
hard
{ "lang": "rust", "repo": "3c1u/fluent-rs", "path": "/fluent-bundle/tests/resolve_attribute_expression.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 3c1u/fluent-rs path: /fluent-bundle/tests/resolve_attribute_expression.rs mod helpers; use fluent_bundle::errors::FluentError; use fluent_bundle::resolve::ResolverError; use self::helpers::{ assert_format, assert_format_no_errors, assert_get_bundle_no_errors, assert_get_resource_from_st...
code_fim
hard
{ "lang": "rust", "repo": "3c1u/fluent-rs", "path": "/fluent-bundle/tests/resolve_attribute_expression.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_format( bundle.format("missing-missing", None), "missing.missing", vec![FluentError::ResolverError(ResolverError::Reference( "Unknown message: missing.missing".into(), ))], ); } #[test] fn attribute_reference_cyclic() { { let res = as...
code_fim
hard
{ "lang": "rust", "repo": "3c1u/fluent-rs", "path": "/fluent-bundle/tests/resolve_attribute_expression.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<P> discovery::Topology for PipeTopology<P> where P: Clone, { fn update(&mut self, _cfg: &str, _name: &str) { todo!() } } impl<P> left_right::Absorb<(String, String)> for PipeTopology<P> where P: Clone, { fn absorb_first(&mut self, cfg: &mut (String, String), _other: &Self)...
code_fim
hard
{ "lang": "rust", "repo": "Aimable-rich/breeze", "path": "/endpoint/src/pipe.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> todo!() } } impl<P> left_right::Absorb<(String, String)> for PipeTopology<P> where P: Clone, { fn absorb_first(&mut self, cfg: &mut (String, String), _other: &Self) { discovery::Topology::update(self, &cfg.0, &cfg.1); } fn sync_with(&mut self, first: &Self) { *s...
code_fim
hard
{ "lang": "rust", "repo": "Aimable-rich/breeze", "path": "/endpoint/src/pipe.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aimable-rich/breeze path: /endpoint/src/pipe.rs use discovery::ServiceDiscover; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::net::TcpStream; use std::io::Result; pub struct Pipe<P> { stream: TcpStream, _mark: std::marker::PhantomData<P>, } impl<P> Pipe<P> { #[inline] pu...
code_fim
hard
{ "lang": "rust", "repo": "Aimable-rich/breeze", "path": "/endpoint/src/pipe.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/pipeline/graphics/vertex/index_buffer.rs self.buffer.data() } pub(crate) fn offset_in_bytes(&self) -> usize { self.offset_in_bytes } /// The size in bytes of the viewed index buffer region. pub fn size_in_bytes(&s...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/pipeline/graphics/vertex/index_buffer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> state.bind_vertex_array(None).apply(gl).unwrap(); unsafe { self.buffer_data .id() .unwrap() .with_value_unchecked(|buffer_object| { state .bind_element_array_buffer(Some(&buffer_object)...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/pipeline/graphics/vertex/index_buffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A helper trait type for indexing operations on an [IndexBufferView]. pub trait IndexBufferViewSliceIndex<T>: Sized { /// Returns a view on the [IndexBufferView] if in bounds, or `None` otherwise. fn get<'a>(self, view: &'a IndexBufferView<T>) -> Option<IndexBufferView<'a, T>>; /// Returns...
code_fim
hard
{ "lang": "rust", "repo": "RSSchermer/web_glitz.rs", "path": "/web_glitz/src/pipeline/graphics/vertex/index_buffer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 等效的写法,指定panic的内容 let f = File::open("hello.txt").expect("open file failed"); println!("file is = {:#?}", f); // 传播(propagating)错误,让调用者知道这个错误并决定该如何处理。 let s = read_file().unwrap(); println!("file content is = {:#?}", s); } // 错误传播,留给上层处理 // ? 只能被用于返回 Result 的函数 fn read_file() ...
code_fim
hard
{ "lang": "rust", "repo": "b41sh/rust-learning", "path": "/src/basic/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: b41sh/rust-learning path: /src/basic/errors.rs // Rust 将错误组合成两个主要类别:可恢复错误(recoverable)和 不可恢复错误(unrecoverable)。 // 可恢复错误通常代表向用户报告错误和重试操作是合理的情况,比如未找到文件。 // 不可恢复错误通常是 bug 的同义词,比如尝试访问超过数组结尾的位置。 // Rust 并没有异常。对于可恢复错误有 Result<T, E> 值,以及 panic!,它在遇到不可恢复错误时停止程序执行。 // 当出现 panic 时,程序默认会开始 展开(unwinding),这...
code_fim
hard
{ "lang": "rust", "repo": "b41sh/rust-learning", "path": "/src/basic/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitter-badger/y-crdt path: /lib0/src/encoding.rs use crate::binary; use crate::{any::Any, number::Uint}; use std::io::Write; #[derive(Default)] pub struct Encoder { pub buf: Vec<u8>, } impl Encoder { pub fn new() -> Encoder { Encoder::with_capacity(10000) } pub fn with_c...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/y-crdt", "path": "/lib0/src/encoding.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>is here for compatibility to lib0/encoding. Instead you should use // write_int_64; pub fn write_big_uint64(&mut self, num: u64) { self.write_buffer(&num.to_be_bytes()); } // Encode data with efficient binary format. // // Differences to JSON: // • Transforms data to a ...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/y-crdt", "path": "/lib0/src/encoding.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pctg-x8/interlude path: /vk/defs/src/device_generated_commands_nvx.rs //! VK_NVX_device_generated_commands extensions pub const VK_NVX_DEVICE_GENERATED_COMMANDS_SPEC_VERSION: usize = 1; pub static VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME: &'static str = "VK_NVX_device_generated_commands"...
code_fim
hard
{ "lang": "rust", "repo": "Pctg-x8/interlude", "path": "/vk/defs/src/device_generated_commands_nvx.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[repr(C)] #[derive(Debug, Clone, PartialEq, Eq)] pub struct VkIndirectCommandsTokenNVX { pub tokenType: VkIndirectCommandsTokenTypeNVX, pub buffer: VkBuffer, pub offset: VkDeviceSize } impl Default for VkIndirectCommandsTokenNVX { fn default() -> Self { unsafe { std::mem::zeroed() } } } #[repr(C)] #[d...
code_fim
hard
{ "lang": "rust", "repo": "Pctg-x8/interlude", "path": "/vk/defs/src/device_generated_commands_nvx.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let mut input = Value::Text("Springsteen, Bruce".to_owned()); replace_all_with_regex("", &mut input, &find_regex, &replace_text, &event, variables) .unwrap(); assert_eq!(Value::Text("Bruce Springsteen".to_owned()), input); } } ...
code_fim
hard
{ "lang": "rust", "repo": "krait-yxin/tornado", "path": "/engine/matcher/src/matcher/modifier/replace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krait-yxin/tornado path: /engine/matcher/src/matcher/modifier/replace.rs use crate::accessor::Accessor; use crate::error::MatcherError; use crate::model::InternalEvent; use regex::Regex; use tornado_common_api::Value; #[inline] pub fn replace_all( variable_name: &str, value: &mut Value,...
code_fim
hard
{ "lang": "rust", "repo": "krait-yxin/tornado", "path": "/engine/matcher/src/matcher/modifier/replace.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chenenjie/bridge path: /src/bridge/mod.rs use tokio_core::reactor::{Core, Handle}; use tokio_core::net::{TcpListener, TcpStream}; use tokio_io::{AsyncRead,AsyncWrite}; use tokio_io::io; use futures::{Stream, Sink}; use futures::Future; use result; pub fn run() -> result::Result<()> { <|fim_suf...
code_fim
hard
{ "lang": "rust", "repo": "chenenjie/bridge", "path": "/src/bridge/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let socket_addr = "127.0.0.1:1024".parse()?; let listener = TcpListener::bind(&socket_addr, &handle)?; let bridge = listener.incoming().for_each(|(stream, addr)|{ let (reader, writer) = stream.split(); let bytes_copied = io::copy(reader, writer); let h...
code_fim
medium
{ "lang": "rust", "repo": "chenenjie/bridge", "path": "/src/bridge/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nhyne/user-api path: /src/main.rs #![feature(proc_macro_hygiene)] #![feature(decl_macro)] #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; #[macro_use] extern crate serde_derive; mod auth; mod db; mod responses; use auth::authentication::AuthenticatedJWT; use db::user...
code_fim
hard
{ "lang": "rust", "repo": "nhyne/user-api", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> json!("{\"message\": \"Unauthorized! Make sure you're including the Authorization header.\"}") } fn rocket() -> rocket::Rocket { rocket::ignite() .mount("/api/users", routes![new, login, verify_jwt]) .register(catchers![not_found, bad_request, unauthorized]) } fn main() { roc...
code_fim
hard
{ "lang": "rust", "repo": "nhyne/user-api", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lettucemode/advent-of-code path: /2017/src/main.rs #![allow(dead_code)] mod common; mod d1; mod d10; mod d11; mod d12; mod d13; mod d14; mod d15; mod d16; mod d17; mod d18; mod d19; mod d2; mod d20; mod d21; mod d22; mod d23; mod d24; mod d25; mod d3; mod d4; mod d5; mod d6; mod d7; mod d8; mod ...
code_fim
hard
{ "lang": "rust", "repo": "lettucemode/advent-of-code", "path": "/2017/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // run_puzzle(1, d1::solve); // run_puzzle(2, d2::solve); // run_puzzle(3, d3::solve); // run_puzzle(4, d4::solve); // run_puzzle(5, d5::solve); // run_puzzle(6, d6::solve); // run_puzzle(7, d7::solve); // run_puzzle(8, d8::solve); // run_puzzle(9, d9::solve); // ru...
code_fim
hard
{ "lang": "rust", "repo": "lettucemode/advent-of-code", "path": "/2017/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JCFlores93/rust-learning path: /section6/ownership.rs fn main() { let mut s = String::from("Hello"); take(s); println!("{} ", s); } <|fim_suffix|> println!("{} ", s1); s1; }<|fim_middle|>// Return ownership back fn take(s1: String) -> String {
code_fim
easy
{ "lang": "rust", "repo": "JCFlores93/rust-learning", "path": "/section6/ownership.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} ", s1); s1; }<|fim_prefix|>// repo: JCFlores93/rust-learning path: /section6/ownership.rs fn main() { let mut s = String::from("Hello"); take(s); println!("{} ", s); } <|fim_middle|>// Return ownership back fn take(s1: String) -> String {
code_fim
easy
{ "lang": "rust", "repo": "JCFlores93/rust-learning", "path": "/section6/ownership.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn change(&mut self, props: Self::Properties, _: &mut Env<CTX, Self>) -> ShouldRender { self.name = props.name; self.image_url = props.image_url; self.link_url = props.link_url; true } } impl<CTX> Renderable<CTX, Card> for Card where CTX: 'static, { fn view...
code_fim
medium
{ "lang": "rust", "repo": "niba1122/rust_app", "path": "/src/card.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> html! { <div> <a href=self.link_url.clone(), target="_blank", > <img src=self.image_url.clone(), /> { self.name.clone() } </a> </div> } } }<|fim_prefix|>// repo: niba1122/rust_app path: /sr...
code_fim
hard
{ "lang": "rust", "repo": "niba1122/rust_app", "path": "/src/card.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: niba1122/rust_app path: /src/card.rs use yew::prelude::*; pub struct Card { name: String, image_url: String, link_url: String, } pub struct Msg {} #[derive(Default, Clone, PartialEq)] pub struct CardProps { pub name: String, pub image_url: String, pub link_url: String,...
code_fim
medium
{ "lang": "rust", "repo": "niba1122/rust_app", "path": "/src/card.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: invariantfields/svgbobrus path: /svgbob/src/fragments.rs /// exact location of point /// relative to the Character Block /// The block is divided in to 5x5 small blocks enum Block{ 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 } impl Block{ /// +*-_|\/ ...
code_fim
hard
{ "lang": "rust", "repo": "invariantfields/svgbobrus", "path": "/svgbob/src/fragments.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.0.push( Fragment{ loc: loc.clone(), elements: elements, interacted: true, consumed: false, } ) } /// push elements at this location as interacted and consumed fn push_consumed(&mut sel...
code_fim
hard
{ "lang": "rust", "repo": "invariantfields/svgbobrus", "path": "/svgbob/src/fragments.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// push elements at this location as interacted and consumed fn push_consumed(&mut self, loc: &Loc, elements: Vec<Element>){ self.0.push( Fragment{ loc: loc.clone(), elements: elements, interacted: true, consumed:...
code_fim
hard
{ "lang": "rust", "repo": "invariantfields/svgbobrus", "path": "/svgbob/src/fragments.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Box::init(self.width / 2, self.height / 2, self.depth / 2, |x, y, z| { // get 8 source cells let c000 = self.get(x * 2 + 0, y * 2 + 0, z * 2 + 0); let c100 = self.get(x * 2 + 1, y * 2 + 0, z * 2 + 0); let c010 = self.get(x * 2 + 0, y * 2 + 1, z * 2 +...
code_fim
hard
{ "lang": "rust", "repo": "nettan20/oxid", "path": "/src/oxid/voxel/vbox.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nettan20/oxid path: /src/oxid/voxel/vbox.rs use std::slice; #[deriving(Clone)] pub struct Cell { pub occupancy: u8, pub material: u8 } pub struct Box { pub width: uint, pub height: uint, pub depth: uint, data: ~[Cell] } impl Box { pub fn new(width: uint, height: ui...
code_fim
hard
{ "lang": "rust", "repo": "nettan20/oxid", "path": "/src/oxid/voxel/vbox.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cholcombe973/libcephfs-sys path: /src/cephfs.rs { return Err(RadosError::new(try!(get_error(ret_code)))); } } Ok(()) } pub fn lchown(cmount: &mut ceph_mount_info, path: &str, uid: i32, gid: i32) -> Result<(), Ra...
code_fim
hard
{ "lang": "rust", "repo": "cholcombe973/libcephfs-sys", "path": "/src/cephfs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cholcombe973/libcephfs-sys path: /src/cephfs.rs ))); } } Ok(()) } pub fn readdirplus_r(cmount: &mut ceph_mount_info, dirp: &mut ceph_dir_result, de: &mut dirent, st: &mut stat, stmask: i32) ...
code_fim
hard
{ "lang": "rust", "repo": "cholcombe973/libcephfs-sys", "path": "/src/cephfs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_pool_replication(cmount: &mut ceph_mount_info, pool_id: i32) -> Result<(), RadosError> { unsafe { let ret_code = ceph_get_pool_replication(cmount, pool_id); if ret_code < 0 { return Err(RadosError::new(try!(get_error(ret_code)))); } } Ok(()) } pu...
code_fim
hard
{ "lang": "rust", "repo": "cholcombe973/libcephfs-sys", "path": "/src/cephfs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ompare 1 Register"] pub struct RC1R { register: ::vcell::VolatileCell<u32>, } #[doc = "Receive Compare 1 Register"] pub mod rc1r; #[doc = "Status Register"] pub struct SR { register: ::vcell::VolatileCell<u32>, } #[doc = "Status Register"] pub mod sr; #[doc = "Interrupt Enable Register"] pub struc...
code_fim
hard
{ "lang": "rust", "repo": "inferiorhumanorgans/sam3x8e-fork", "path": "/src/ssc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: inferiorhumanorgans/sam3x8e-fork path: /src/ssc.rs #[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control Register"] pub cr: CR, #[doc = "0x04 - Clock Mode Register"] pub cmr: CMR, _reserved2: [u8; 8usize], #[doc = "0x10 - Receive Clock ...
code_fim
hard
{ "lang": "rust", "repo": "inferiorhumanorgans/sam3x8e-fork", "path": "/src/ssc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mnwa/rxRust path: /src/subject.rs use crate::prelude::*; use std::fmt::{Debug, Formatter}; mod local_subject; pub use local_subject::*; mod shared_subject; pub use shared_subject::*; #[derive(Default, Clone)] pub struct Subject<V, S> { pub(crate) observers: SubjectObserver<V>, pub(crate) s...
code_fim
hard
{ "lang": "rust", "repo": "Mnwa/rxRust", "path": "/src/subject.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<Item, Err, U, O, V> Observer for Subject<V, U> where V: InnerDerefMut<Target = Vec<O>>, O: Observer<Item = Item, Err = Err> + SubscriptionLike, Item: Clone, Err: Clone, { type Item = Item; type Err = Err; #[inline] fn next(&mut self, value: Item) { self.observers.next(value) } #[in...
code_fim
hard
{ "lang": "rust", "repo": "Mnwa/rxRust", "path": "/src/subject.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: google/fully-homomorphic-encryption path: /transpiler/examples/ifte/ifte_rs_lib.rs use tfhe::shortint::prelude::*; use tfhe::shortint::CiphertextBig as Ciphertext; // Encrypt an i8 pub fn encrypt(value: i8, client_key: &ClientKey) -> Vec<Ciphertext> { (0..8) .map(|shift| { ...
code_fim
hard
{ "lang": "rust", "repo": "google/fully-homomorphic-encryption", "path": "/transpiler/examples/ifte/ifte_rs_lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_ifte() { assert_eq!(run_test_for(true, 1, 0), 1); assert_eq!(run_test_for(false, 1, 0), 0); } }<|fim_prefix|>// repo: google/fully-homomorphic-encryption path: /transpiler/examples/ifte/ifte_rs_lib.rs use tfhe::shortint::prelude::*; use tfhe::shortint::Cipherte...
code_fim
hard
{ "lang": "rust", "repo": "google/fully-homomorphic-encryption", "path": "/transpiler/examples/ifte/ifte_rs_lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LinusPhoenix/daily-desktop-background-rust path: /src/main.rs #![windows_subsystem = "windows"] use reqwest::blocking::Client; use serde_json::Value; const DESKTOP_BACKGROUND_ENDPOINT: &str = "https://api.unsplash.com/photos/random?query=desktop%20background&orientation=landscape"; fn mai...
code_fim
hard
{ "lang": "rust", "repo": "LinusPhoenix/daily-desktop-background-rust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> UnsplashPhoto { image_url: String::from(image_url), download_tracking_url: String::from(download_tracking_url), } } fn call_download_tracking_url(photo: &UnsplashPhoto) { reqwest::blocking::get(&photo.download_tracking_url).unwrap(); }<|fim_prefix|>// repo: LinusPhoenix/daily-...
code_fim
hard
{ "lang": "rust", "repo": "LinusPhoenix/daily-desktop-background-rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "Insert 1 blank line after class docstring".to_string() } } /// ## What it does /// Checks for docstrings on class definitions that are preceded by a blank /// line. /// /// ## Why is this bad? /// Avoid introducing any blank lines between a class definition and its /// docstring, for consist...
code_fim
hard
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs use ruff_python_ast::Ranged; use ruff_text_size::{TextLen, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ru...
code_fim
hard
{ "lang": "rust", "repo": "astral-sh/ruff", "path": "/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kbingman/stellar path: /src/util.rs use crate::models::{Coords, SphereCoords}; use rand::prelude::*; use sha2::{Digest, Sha256}; /** * Turn a string into a string 64 characters in length */ fn create_hash(text: &str) -> String { let mut hasher = Sha256::default(); hasher.input(text.as...
code_fim
hard
{ "lang": "rust", "repo": "kbingman/stellar", "path": "/src/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }