text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: rsaarelm/otlbook path: /base/src/lib.rs mod collection; pub use collection::Collection; mod date; pub use date::VagueDate; pub mod parse; mod section; pub use section::{EntityIdentifier, Section}; <|fim_suffix|>pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send ...
code_fim
medium
{ "lang": "rust", "repo": "rsaarelm/otlbook", "path": "/base/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub mod parse; mod section; pub use section::{EntityIdentifier, Section}; mod symbol; pub use symbol::{Sym, Uri}; pub type Symbol = Sym<String>; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; mod tree; mod typed_attribute;<|fim_prefix|>// repo: rsaarelm/otl...
code_fim
easy
{ "lang": "rust", "repo": "rsaarelm/otlbook", "path": "/base/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod section; pub use section::{EntityIdentifier, Section}; mod symbol; pub use symbol::{Sym, Uri}; pub type Symbol = Sym<String>; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; mod tree; mod typed_attribute;<|fim_prefix|>// repo: rsaarelm/otlbook path: /bas...
code_fim
easy
{ "lang": "rust", "repo": "rsaarelm/otlbook", "path": "/base/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Global19-atlassian-net/rusty path: /functions/src/main.rs fn main() { println!("Hello, world!"); another_function(5, 6); express(); multi(); println!("The value of x is: {}", five()); } // Function could be defined anywhere as long as it is there. // Argumentś type MUST al...
code_fim
medium
{ "lang": "rust", "repo": "Global19-atlassian-net/rusty", "path": "/functions/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // implicitly returns value of last expression in block let g = (-5) * 5; println!("The value of g is: {}", g); } // about the ; // anything that ends with a semicolon will retun a an empty tuple like so () // the empty tuple is Rust's way to decribe a void, None, nil, ... // statements are ...
code_fim
medium
{ "lang": "rust", "repo": "Global19-atlassian-net/rusty", "path": "/functions/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rgoulter/amethyst-action-game-3d path: /src/systems/mod.rs mod debug; mod material_replace; mod player_movement; mo<|fim_suffix|>terial_replace::ReplaceMaterialSystem; pub use self::player_movement::MovementSystem; pub use self::ui::UISystem;<|fim_middle|>d ui; pub use self::debug::DebugSystem;...
code_fim
easy
{ "lang": "rust", "repo": "rgoulter/amethyst-action-game-3d", "path": "/src/systems/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>terial_replace::ReplaceMaterialSystem; pub use self::player_movement::MovementSystem; pub use self::ui::UISystem;<|fim_prefix|>// repo: rgoulter/amethyst-action-game-3d path: /src/systems/mod.rs mod debug; mod material_replace; mod player_movement; mo<|fim_middle|>d ui; pub use self::debug::DebugSystem;...
code_fim
easy
{ "lang": "rust", "repo": "rgoulter/amethyst-action-game-3d", "path": "/src/systems/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match (self.0.is_nan(), other.0.is_nan()) { // Non-NaNs are all comparable. (false, false) => self.0.partial_cmp(&other.0).unwrap(), // Otherwise any non-NaN is larger, or two NaNs are equal. (x, y) => y.cmp(&x), } } } impl From<OrdFloat...
code_fim
hard
{ "lang": "rust", "repo": "varkor/reflections", "path": "/src/approximation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: varkor/reflections path: /src/approximation.rs use std::cmp::Ordering; use crate::spatial::Point2D; /// A closed interval; essentially a floating-point `RangeInclusive` with some convenience methods. #[derive(Clone)] pub struct Interval { pub start: f64, pub end: f64, pub step: f64...
code_fim
hard
{ "lang": "rust", "repo": "varkor/reflections", "path": "/src/approximation.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Equation<'a, f64> { /// Sample the equation over an interval. pub fn sample(&self, interval: &Interval) -> Vec<Point2D> { interval.clone().map(|t| (self.function)(t)).collect() } /// Return a new equation representing the normal at the given `t`. pub fn normal(&self, ...
code_fim
hard
{ "lang": "rust", "repo": "varkor/reflections", "path": "/src/approximation.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Bullet { pub fn draw_bullet( &mut self, ctx: &mut Context, bullet_batch: &mut ggez::graphics::spritebatch::SpriteBatch, bullet_image_width: f32, bullet_image_height: f32, colliders: &mut DefaultColliderSet<f64>, ) -> ggez::GameResult { l...
code_fim
medium
{ "lang": "rust", "repo": "MatthewFrench/rust_2d_game", "path": "/src/bullet.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MatthewFrench/rust_2d_game path: /src/bullet.rs use crate::common::{GAME_HEIGHT, GAME_WIDTH}; use ggez::graphics::{Color, Rect}; extern crate nalgebra as na; use self::na::{Isometry2, Translation2}; use ggez::{graphics, Context}; use na::{Point2, Rotation2, UnitComplex, Vector2}; use nphysics2d:...
code_fim
medium
{ "lang": "rust", "repo": "MatthewFrench/rust_2d_game", "path": "/src/bullet.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: provable-things/ptokens-core path: /src/btc_on_eth/btc/mod.rs pub mod submit_btc_block; pub(crate) mod account_for_fees; pub(crate) mod get_btc_output_json; pub(crate) m<|fim_suffix|>sactions; pub(crate) mod sign_normal_eth_transactions;<|fim_middle|>od minting_params; pub(crate) mod sign_any_s...
code_fim
easy
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/btc_on_eth/btc/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>sactions; pub(crate) mod sign_normal_eth_transactions;<|fim_prefix|>// repo: provable-things/ptokens-core path: /src/btc_on_eth/btc/mod.rs pub mod submit_btc_block; pub(crate) mod account_for_<|fim_middle|>fees; pub(crate) mod get_btc_output_json; pub(crate) mod minting_params; pub(crate) mod sign_any_s...
code_fim
medium
{ "lang": "rust", "repo": "provable-things/ptokens-core", "path": "/src/btc_on_eth/btc/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PolyMeilex/YetAnotherPowerMenu path: /src/config.rs use glib::translate::{FromGlib, ToGlib}; use serde::{Deserialize, Serialize}; /// Button event #[derive(Debug, Clone, Serialize, Deserialize)] pub enum Event { Lock, Logout, Reboot, Shutdown, Suspend, Custom(Vec<String>...
code_fim
hard
{ "lang": "rust", "repo": "PolyMeilex/YetAnotherPowerMenu", "path": "/src/config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let default_config = include_str!("./config.ron"); let default_style = include_bytes!("./style.css"); let (ron_str, style_str) = if let Some(config_dir) = config_dir { let bar_config_dir = config_dir.join("YetAnotherPowerMenu"); let _ = std::fs::create_dir_all(&bar_config_dir)...
code_fim
hard
{ "lang": "rust", "repo": "PolyMeilex/YetAnotherPowerMenu", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ron } } pub fn get_config() -> (Config, Vec<u8>) { let config_dir = config_dir(); let default_config = include_str!("./config.ron"); let default_style = include_bytes!("./style.css"); let (ron_str, style_str) = if let Some(config_dir) = config_dir { let bar_config_di...
code_fim
hard
{ "lang": "rust", "repo": "PolyMeilex/YetAnotherPowerMenu", "path": "/src/config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl FromStr for ChannelType { type Err = ParseChannelError; #[inline] fn from_str(s: &str) -> Result<Self, Self::Err> { ChannelType::from_bytes(s) } } impl fmt::Display for ChannelType { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(...
code_fim
hard
{ "lang": "rust", "repo": "Waelwindows/bvh_anim", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns an iterator over all the `Joint`s in the `Bvh`. #[inline] pub fn joints(&self) -> Iter<'_, Joint> { self.joints.iter() } /// Returns a mutable iterator over all the joints in the `Bvh`. pub fn joints_mut(&mut self) -> IterMut<'_, Joint> { self.joints.it...
code_fim
hard
{ "lang": "rust", "repo": "Waelwindows/bvh_anim", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Waelwindows/bvh_anim path: /src/lib.rs //! HEIRARCHY //! ROOT <Root-name> //! { //! OFFSET <Root-offset-x> <Root-offset-y> <Root-offset-z> //! CHANNELS <Num-root-joint-channels> Xposition Yposition <other-root-channels ...> //! JOINT <Joint-1-name> //! { //! OFFSET <Joint...
code_fim
hard
{ "lang": "rust", "repo": "Waelwindows/bvh_anim", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct ServerListener{ inner : Arc<Mutex<InnerListener>>, } impl ServerListener{ pub fn new(game : Arc<Mutex<Game>>,on_send : mpsc::Receiver<String>) -> ServerListener{ ServerListener {inner : Arc::new(Mutex::new(InnerListener::new(game,on_send)))} } pub fn start(&mut self){ ...
code_fim
hard
{ "lang": "rust", "repo": "WiseEye97/RustPingPong", "path": "/src/server_listener.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WiseEye97/RustPingPong path: /src/server_listener.rs use crate::game::{Game,Side}; use std::sync::{Arc,Mutex}; use std::sync::mpsc; use std::thread; use crate::types::*; use std::time::{Duration}; use std::thread::sleep; struct InnerListener{ game : Arc<Mutex<Game>>, on_send : mpsc::R...
code_fim
hard
{ "lang": "rust", "repo": "WiseEye97/RustPingPong", "path": "/src/server_listener.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e = File::open(file_path)?; let mut buf_reader = BufReader::new(file); let mut contents = String::new(); buf_reader.read_to_string(&mut contents)?; Ok(contents) }<|fim_prefix|>// repo: Ubugeeei/firegen path: /src/reader/fs.rs use std::fs::{self, File}; use std::io::{self, prelude::*, BufR...
code_fim
medium
{ "lang": "rust", "repo": "Ubugeeei/firegen", "path": "/src/reader/fs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ubugeeei/firegen path: /src/reader/fs.rs use std::fs::{self, File}; use std::io::{self, prelude::*, BufReader}; use std::path::{Path, PathBuf}; pub fn read_file(file_path: &str) -> std::io::Result<String> { let fil<|fim_suffix|>ntents = String::new(); buf_reader.read_to_string(&mut cont...
code_fim
medium
{ "lang": "rust", "repo": "Ubugeeei/firegen", "path": "/src/reader/fs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn difference(number: u32) -> u32 { square_of_sum(number) - sum_of_squares(number) }<|fim_prefix|>// repo: cjstehno/rust-exercism path: /difference-of-squares/src/lib.rs pub fn square_of_sum(number: u32) -> u32 { ((1..number+1).fold(0, |sum, x| sum + x)).pow(2) } <|fim_middle|>pub fn sum_of...
code_fim
medium
{ "lang": "rust", "repo": "cjstehno/rust-exercism", "path": "/difference-of-squares/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cjstehno/rust-exercism path: /difference-of-squares/src/lib.rs pub fn square_of_sum(number: u32) -> u32 { ((1..number+1).fold(0, |sum, x| sum + x)).pow(2) } <|fim_suffix|>pub fn difference(number: u32) -> u32 { square_of_sum(number) - sum_of_squares(number) }<|fim_middle|>pub fn sum_of...
code_fim
medium
{ "lang": "rust", "repo": "cjstehno/rust-exercism", "path": "/difference-of-squares/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub const Py_END_OF_BUFFER: Py_ssize_t = -1; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub fn PyBuffer_FromObject( base: *mut PyObject, offset: Py_ssize_t, size: Py_ssize_t, ) -> *mut PyObject; pub fn PyBuffer_FromReadWriteObject( base: *mut Py...
code_fim
medium
{ "lang": "rust", "repo": "dgrunwald/rust-cpython", "path": "/python27-sys/src/bufferobject.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgrunwald/rust-cpython path: /python27-sys/src/bufferobject.rs use libc::{c_int, c_void}; use crate::object::*; use crate::pyport::Py_ssize_t; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut PyBuffer_Type: PyTypeObject; } #[inline(always)] pub unsafe fn PyBuffer_...
code_fim
medium
{ "lang": "rust", "repo": "dgrunwald/rust-cpython", "path": "/python27-sys/src/bufferobject.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut name = String::new(); println!("Hello there"); println!("Please enter your name: "); let read_name = std::io::stdin().read_line(&mut name).unwrap(); println!("Hello, {}", name.gradient(Color::Red)); println!("{}", "Welcome to mydia!".gradient(Color::Green)); ...
code_fim
hard
{ "lang": "rust", "repo": "admodev/mydia-journal", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: admodev/mydia-journal path: /src/main.rs use ::std::*; use colorful::Color; use colorful::Colorful; use dialoguer::{ Select, theme::ColorfulTheme }; use console::Term; #[macro_use] extern crate colorful; <|fim_suffix|> Ok(()) } fn main() { let mut name = String::new(); prin...
code_fim
hard
{ "lang": "rust", "repo": "admodev/mydia-journal", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn select_menu() -> std::io::Result<()> { let items = vec!["Today's goal", "Plan", "Write", "Delete", "Sign up", "Sign in", "Sign Out", "Exit"]; let selection = Select::with_theme(&ColorfulTheme::default()) .items(&items) .default(0) .interact_on_opt(&Term::stderr())?; ...
code_fim
medium
{ "lang": "rust", "repo": "admodev/mydia-journal", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeizsm/trello-rs path: /src/board.rs use Client; use Error; #[derive(RustcDecodable, RustcEncodable, Debug)] pub struct Board { pub id: String, pub name: String, pub desc: String, pub pinned: Option<bool>, pub starred: Option<bool>, pub url: String } impl Board { pu...
code_fim
medium
{ "lang": "rust", "repo": "jeizsm/trello-rs", "path": "/src/board.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let boards_result = Board::list(&client); assert!(boards_result.is_ok()); let boards = boards_result.unwrap(); assert_eq!(1, boards.len()); let board = boards.get(0).unwrap(); assert_eq!("trello", board.name)...
code_fim
hard
{ "lang": "rust", "repo": "jeizsm/trello-rs", "path": "/src/board.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let v = vec![2, 3, 2, 3, 3]; println!("{}", majority_element(v)); }<|fim_prefix|>// repo: Martins3/ACM path: /leetcode/1/169.rs use std::collections::BTreeMap; // lost control of reference pub fn majority_element(nums: Vec<i32>) -> i32 { // why should use divide and conquer l...
code_fim
hard
{ "lang": "rust", "repo": "Martins3/ACM", "path": "/leetcode/1/169.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Martins3/ACM path: /leetcode/1/169.rs use std::collections::BTreeMap; // lost control of reference pub fn majority_element(nums: Vec<i32>) -> i32 { // why should use divide and conquer let threshold = nums.len() as i32 / 2; let mut scores = BTreeMap::new(); for i in &nums { ...
code_fim
medium
{ "lang": "rust", "repo": "Martins3/ACM", "path": "/leetcode/1/169.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v = vec![2, 3, 2, 3, 3]; println!("{}", majority_element(v)); }<|fim_prefix|>// repo: Martins3/ACM path: /leetcode/1/169.rs use std::collections::BTreeMap; // lost control of reference pub fn majority_element(nums: Vec<i32>) -> i32 { // why should use divide and conquer let threshold...
code_fim
hard
{ "lang": "rust", "repo": "Martins3/ACM", "path": "/leetcode/1/169.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for ControlMode { fn default() -> Self { Self::Local { sudo: false } } } impl Configuration { pub fn new(args: Args) -> Result<Self> { let file = File::open(args.config_path)?; let reader = BufReader::new(file); let res = serde_yaml::from_reader(re...
code_fim
hard
{ "lang": "rust", "repo": "metal-csi/metal-csi", "path": "/driver/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: metal-csi/metal-csi path: /driver/src/config.rs use crate::args::Args; use crate::Result; use std::fs::File; use std::io::BufReader; use std::sync::Arc; #[derive(Debug, Deref, Default, Clone)] pub struct Configuration(Arc<InnerConfiguration>); #[derive(Debug, Default, Serialize, Deserialize)] ...
code_fim
hard
{ "lang": "rust", "repo": "metal-csi/metal-csi", "path": "/driver/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[serde(rename = "ssh")] SSH { #[serde(default)] sudo: bool, #[serde(default)] user: String, #[serde(default)] private_key: String, #[serde(default)] host: String, #[serde(default)] port: u16, }, } impl Default fo...
code_fim
hard
{ "lang": "rust", "repo": "metal-csi/metal-csi", "path": "/driver/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use crate::{ components::trace::{Trace, TraceRef}, test_utils::{make_traces, traces_to_value, value_to_traces}, }; use super::*; fn before_each() -> (DeviceRef, RefVec<Trace>, RefVec<Trace>, RefVec<Trace>) { let device = Ic2114::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "Barandis/rust-c64", "path": "/src/devices/chips/ic2114.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The place where the data is actually stored. The 2114 is 4-bit memory, and there is /// not a u4 type in Rust, so we use a u8 along with an address resolution function. /// (Memory is cheap and there isn't a practical reason to just not use a [u8; 1024] and /// ignore the high bits, bu...
code_fim
hard
{ "lang": "rust", "repo": "Barandis/rust-c64", "path": "/src/devices/chips/ic2114.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Barandis/rust-c64 path: /src/devices/chips/ic2114.rs // Copyright (c) 2021 Thomas J. Otterson // // This software is released under the MIT License. // https://opensource.org/licenses/MIT pub mod constants { /// Pin assignment for address pin A0. pub const A0: usize = 5; /// Pin ass...
code_fim
hard
{ "lang": "rust", "repo": "Barandis/rust-c64", "path": "/src/devices/chips/ic2114.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sayden/rust-tutorials path: /part4.rs fn work_on_vector(v: &Vec<i32>) { for e in v { println!("{}", e); } } <|fim_suffix|> let mut min = None; for e in v.iter() { min = Some(match min { None => *e, Some(n) => cmp::min(n, *e) }); ...
code_fim
medium
{ "lang": "rust", "repo": "sayden/rust-tutorials", "path": "/part4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn vec_inc(v: &mut Vec<i32>) { for e in v.iter_mut() { *e += 1; } } fn main(){ let v = vec![1,2,3,4]; let first = &v[0]; work_on_vector(&v); work_on_vector(&v); println!("The first element is {}", *first); let mut vv = v.to_owned(); vec_inc(&mut vv); work_...
code_fim
medium
{ "lang": "rust", "repo": "sayden/rust-tutorials", "path": "/part4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut vv = v.to_owned(); vec_inc(&mut vv); work_on_vector(&vv); work_on_vector(&v); let res = vec_min(&v); match res { Some(n) => println!("Min number is {}", n), _ => println!("Res was nothing"), } }<|fim_prefix|>// repo: sayden/rust-tutorials path: /part4.r...
code_fim
hard
{ "lang": "rust", "repo": "sayden/rust-tutorials", "path": "/part4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let line_num = error.pos.start_pos.line as usize; let preceding_lines = source.split('\n').take(line_num + 1); let preceding_chars = preceding_lines .clone() .take(line_num) .fold(0, |acc, cur| acc + cur.len()) + line_num; let line = preceding_lines.last().unwrap(); let index_on...
code_fim
hard
{ "lang": "rust", "repo": "caravel-lang/caravel", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caravel-lang/caravel path: /src/error.rs use crate::ansi::{style, BOLD, RED}; use crate::position::source_position::SourceSpan; pub type Result<T> = std::result::Result<T, Error>; pub enum ErrorKind { UnexpectedChar, UnexpectedToken, UndeclaredVariable, TypeMismatch, Redeclaration, }...
code_fim
hard
{ "lang": "rust", "repo": "caravel-lang/caravel", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[stable(feature = "steed", since = "1.0.0")] impl AsRawFd for fs::File { fn as_raw_fd(&self) -> RawFd { self.as_inner().fd().raw() } } #[stable(feature = "from_raw_os", since = "1.1.0")] impl FromRawFd for fs::File { unsafe fn from_raw_fd(fd: RawFd) -> fs::File { fs::File::fro...
code_fim
hard
{ "lang": "rust", "repo": "fabianschuiki/steed", "path": "/src/sys/linux/ext/io.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fabianschuiki/steed path: /src/sys/linux/ext/io.rs #![stable(feature = "steed", since = "1.0.0")] use fs; use os::raw; use sys; use sys_common::{AsInner, FromInner, IntoInner}; #[stable(feature = "steed", since = "1.0.0")] pub type RawFd = raw::c_int; #[stable(feature = "steed", since = "1.0....
code_fim
medium
{ "lang": "rust", "repo": "fabianschuiki/steed", "path": "/src/sys/linux/ext/io.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { Get(cmd) => cmd.apply(db, dst).await, Publish(cmd) => cmd.apply(db, dst).await, Set(cmd) => cmd.apply(db, dst).await, Subscribe(cmd) => cmd.apply(db, dst, shutdown).await, Unknown(cmd) => cmd.apply(dst).await, // ...
code_fim
hard
{ "lang": "rust", "repo": "trungtin/mini-redis", "path": "/src/cmd/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Check if there is any remaining unconsumed fields in the `Parse` // value. If fields remain, this indicates an unexpected frame format // and an error is returned. parse.finish()?; // The command has been successfully parsed Ok(command) } /// Ap...
code_fim
hard
{ "lang": "rust", "repo": "trungtin/mini-redis", "path": "/src/cmd/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trungtin/mini-redis path: /src/cmd/mod.rs mod get; pub use get::Get; mod publish; pub use publish::Publish; mod set; pub use set::Set; mod subscribe; pub use subscribe::{Subscribe, Unsubscribe}; mod unknown; pub use unknown::Unknown; use crate::{Connection, Db, Frame, Parse, ParseError, Shu...
code_fim
hard
{ "lang": "rust", "repo": "trungtin/mini-redis", "path": "/src/cmd/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<i32> { if let Poll::Ready(result) = self.promise.poll() { Poll::Ready(unsafe { result.into_i32() }) } else { unsafe { self.promise.set_waker() }; Poll::Pending } } }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "libcala/cala_core", "path": "/examples/cala-webapp/src/timer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Poll::Ready(result) = self.promise.poll() { Poll::Ready(unsafe { result.into_i32() }) } else { unsafe { self.promise.set_waker() }; Poll::Pending } } }<|fim_prefix|>// repo: libcala/cala_core path: /examples/cala-webapp/src/timer.rs u...
code_fim
hard
{ "lang": "rust", "repo": "libcala/cala_core", "path": "/examples/cala-webapp/src/timer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libcala/cala_core path: /examples/cala-webapp/src/timer.rs use std::{pin::Pin, task::{Poll, Context}, future::Future}; use cala_core::os::web::{JsFn, JsVar}; /// A JavaScript timer future that resolves to a predetermined value. pub(crate) struct JsTimer { promise: JsVar, } <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "libcala/cala_core", "path": "/examples/cala-webapp/src/timer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[command] #[owners_only] fn shutdown(_: &mut Context, _: &Message, _: Args) -> CommandResult { exit(0); }<|fim_prefix|>// repo: the-sporkening/Sporkbot-Rust path: /src/commands/system/shutdown.rs use serenity::framework::standard::{macros::command, Args, CommandResult}; use serenity::model::channel:...
code_fim
easy
{ "lang": "rust", "repo": "the-sporkening/Sporkbot-Rust", "path": "/src/commands/system/shutdown.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: the-sporkening/Sporkbot-Rust path: /src/commands/system/shutdown.rs use serenity::framework::standard::{macros::command, Args, CommandResult}; use serenity::model::channel::Message; use serenity::prelude::Context; <|fim_suffix|>#[command] #[owners_only] fn shutdown(_: &mut Context, _: &Message,...
code_fim
easy
{ "lang": "rust", "repo": "the-sporkening/Sporkbot-Rust", "path": "/src/commands/system/shutdown.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isabella232/dcli path: /src/dcli/src/response/drs.rs /* * Copyright 2021 Mike Chambers * https://github.com/mikechambers/dcli * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the ...
code_fim
medium
{ "lang": "rust", "repo": "isabella232/dcli", "path": "/src/dcli/src/response/drs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const API_RESPONSE_STATUS_SUCCESS: u32 = 1; pub fn check_destiny_response_status( status: &DestinyResponseStatus, ) -> Result<(), Error> { match status.error_code { 1 => Ok(()), 5 => Err(Error::ApiNotAvailableException), 7 => Err(Error::ParameterParseFailure), ...
code_fim
medium
{ "lang": "rust", "repo": "isabella232/dcli", "path": "/src/dcli/src/response/drs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn check_destiny_response_status( status: &DestinyResponseStatus, ) -> Result<(), Error> { match status.error_code { 1 => Ok(()), 5 => Err(Error::ApiNotAvailableException), 7 => Err(Error::ParameterParseFailure), 18 => Err(Error::InvalidParameters), 1665...
code_fim
medium
{ "lang": "rust", "repo": "isabella232/dcli", "path": "/src/dcli/src/response/drs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match warp::test::request() .method("POST") .path("/refresh") .body(payload) .header(SIGNATURE_HEADER_NAME, signature) .filter(&filter) .await { Ok(r) => Ok(r.into_response().status()), Err(_) =...
code_fim
hard
{ "lang": "rust", "repo": "ZIziofficial/repl.deploy", "path": "/daemon/src/event_handlers/http.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZIziofficial/repl.deploy path: /daemon/src/event_handlers/http.rs use { super::constants::{ REFRESH_PATH, SIGNATURE_HEADER_NAME, STAT_REQUEST_RECEIVED, STAT_SIGNATURE_VALIDATION_FAILED, STAT_SIGNATURE_VALIDATION_SUCCESS, }, super::signature_verifier, super::types,...
code_fim
hard
{ "lang": "rust", "repo": "ZIziofficial/repl.deploy", "path": "/daemon/src/event_handlers/http.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use rand::rngs::OsRng; let mut rng = OsRng; let bits = 2048; let private_key = RSAPrivateKey::new(&mut rng, bits).expect("Failed to generate private key"); let public_key = RSAPublicKey::from(&private_key); (public_key, private_key) } fn...
code_fim
hard
{ "lang": "rust", "repo": "ZIziofficial/repl.deploy", "path": "/daemon/src/event_handlers/http.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] struct Ringtone { pub r3tl: &'static str, pub name: &'static str, pub duration: u32, pub octave: u32, pub bpm: u32, pub tones: Option<Split<'static, &'static str>>, } impl Ringtone { pub fn parse(r3tl: &'static str) -> Ringtone { let mut duration = 4; ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hack-the-crab", "path": "/src/r3tl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/hack-the-crab path: /src/r3tl.rs /// RTTTL (RingTone Text Transfer Language) is the primary format used to distribute /// ringtones for Nokia phones. An RTTTL file is a text file, containing the /// ringtone name, a control section and a section containing a comma separated /// sequence ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hack-the-crab", "path": "/src/r3tl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kjunichi/webcamrs path: /src/webcam/ffi/mod.rs extern crate libc; use self::libc::{c_char, c_int, c_void, c_uchar}; mod link; pub enum Capture {} pub enum IplImage {} #[repr(C)] pub struct CvVideoCapture { private: [u8; 0] } #[repr(C)] pub struct Cv2Mat { private: [u8; 0] } <|fim_suffix|>ext...
code_fim
hard
{ "lang": "rust", "repo": "kjunichi/webcamrs", "path": "/src/webcam/ffi/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct CvMat { pub _type: c_int, pub step: c_int, pub refcount: *mut c_int, pub hdr_refcount: c_int, pub ptr: *mut c_uchar, pub rows: c_int, pub cols: c_int, } extern "C" { pub fn cv_destroy_all_windows() -> c_void; pub fn cv_named_window(title: *const c_char) -> ...
code_fim
medium
{ "lang": "rust", "repo": "kjunichi/webcamrs", "path": "/src/webcam/ffi/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrimati1992/structural_crates path: /structural/tests/submodules/into_fields/drop_order.rs shOnDrop}, unsafe_delegate_structural_with, Structural, StructuralExt, }; use std::cell::RefCell; #[derive(Structural)] #[struc(pre_move = "drop_pre_post_structa")] #[struc(pre_post_drop_fields)] s...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/structural_crates", "path": "/structural/tests/submodules/into_fields/drop_order.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> g: PushOnDrop<'a, u32>, }, } fn drop_pre_move_enum(this: &mut PreMoveEnum<'_>) { let PreMoveEnum::Variant { ref mut cell, .. } = *this; cell.borrow_mut().push(120); } #[test] fn drop_order_pre_move_enum() { pre_post_drop_test! { type_name=PreMoveEnum, constructor(...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/structural_crates", "path": "/structural/tests/submodules/into_fields/drop_order.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrimati1992/structural_crates path: /structural/tests/submodules/into_fields/drop_order.rs tor:tt $( variant=$variant:ident, post_method=$unwrap:ident, )? before($($before:expr),*) after($($after:expr),*) $(pre_post_drop_fields $(...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/structural_crates", "path": "/structural/tests/submodules/into_fields/drop_order.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ignatenkobrain/flat-manager path: /src/tokens.rs use actix_web::{HttpRequest, Result, HttpMessage}; use actix_web::http::header::{HeaderValue, AUTHORIZATION}; use actix_service::{Service, Transform}; use actix_web::dev::{ServiceRequest, ServiceResponse}; use actix_web::error::Error; use futures:...
code_fim
hard
{ "lang": "rust", "repo": "ignatenkobrain/flat-manager", "path": "/src/tokens.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<S, B> Service for TokenParserMiddleware<S> where S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>, S::Future: 'static, B: 'static, { type Request = ServiceRequest; type Response = ServiceResponse<B>; type Error = Error; type Future = Eithe...
code_fim
hard
{ "lang": "rust", "repo": "ignatenkobrain/flat-manager", "path": "/src/tokens.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>: Item > > where T : Stream U : Stream < Item = T : : Item > { use Poll : : * ; let mut done = true ; match first . poll_next ( cx ) { Ready ( Some ( val ) ) = > return Ready ( Some ( val ) ) Ready ( None ) = > { } Pending = > done = false } match second . poll_next ( cx ) { Ready ( Some ( val ) ) = > ret...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tokio-stream/src/stream_ext/merge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio-stream/src/stream_ext/merge.rs use crate : : stream_ext : : Fuse ; use crate : : Stream ; use core : : pin : : Pin ; use core : : task : : { Context Poll } ; use pin_project_lite : : pin_project ; pin_project ! { / / / Stream returned by ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tokio-stream/src/stream_ext/merge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LeSeulArtichaut/twilight path: /http/src/request/channel/create_pin.rs use crate::{ client::Client, error::Error, request::{self, AuditLogReason, AuditLogReasonError, Pending, Request}, routing::Route, }; use twilight_model::id::{ChannelId, MessageId}; /// Create a new pin in a ...
code_fim
hard
{ "lang": "rust", "repo": "LeSeulArtichaut/twilight", "path": "/http/src/request/channel/create_pin.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } } impl<'a> AuditLogReason for CreatePin<'a> { fn reason(mut self, reason: impl Into<String>) -> Result<Self, AuditLogReasonError> { self.reason .replace(AuditLogReasonError::validate(reason.into())?); Ok(self) } } poll_req!(CreatePin<'_>, ());<|f...
code_fim
medium
{ "lang": "rust", "repo": "LeSeulArtichaut/twilight", "path": "/http/src/request/channel/create_pin.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> AuditLogReason for CreatePin<'a> { fn reason(mut self, reason: impl Into<String>) -> Result<Self, AuditLogReasonError> { self.reason .replace(AuditLogReasonError::validate(reason.into())?); Ok(self) } } poll_req!(CreatePin<'_>, ());<|fim_prefix|>// repo: LeSe...
code_fim
hard
{ "lang": "rust", "repo": "LeSeulArtichaut/twilight", "path": "/http/src/request/channel/create_pin.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YoshikawaMasashi/toid path: /src/players/websocket_player/send_data.rs use serde::{Deserialize, Serialize}; use super::super::super::state_management::serialize; #[derive(Serialize, Deserialize)] pub enum SendData { StateUpdate(String), SyncState(String), ApplyReader(String), A...
code_fim
hard
{ "lang": "rust", "repo": "YoshikawaMasashi/toid", "path": "/src/players/websocket_player/send_data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Ok(string) = serde_json::from_str(serialized.as_str()) { Ok(string) } else { Err(String::from("error in deserizalization")) } } }<|fim_prefix|>// repo: YoshikawaMasashi/toid path: /src/players/websocket_player/send_data.rs use serde::{Deserialize...
code_fim
hard
{ "lang": "rust", "repo": "YoshikawaMasashi/toid", "path": "/src/players/websocket_player/send_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl serialize::Serialize<SendData> for SendData { fn serialize(&self) -> Result<String, String> { if let Ok(serialized) = serde_json::to_string(&self) { Ok(serialized) } else { Err(String::from("error in serizalization")) } } fn deserialize(seri...
code_fim
medium
{ "lang": "rust", "repo": "YoshikawaMasashi/toid", "path": "/src/players/websocket_player/send_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { self.localIdentifier.hash(state); unsafe { self.multicastGroupId.raw.hash(state) }; } } impl MulticastGroupIdentifier { #[inline(always)] pub fn new(subnetPrefix: __be64, interfaceId: __be64, localIdentifier: LocalIdentifier) -> Self { Self { localIdentifier: localIdentifier, multica...
code_fim
medium
{ "lang": "rust", "repo": "jisuanjidaqiang/rdma-core", "path": "/workspace/rdma-core/src/verbs/model/queuePairs/MulticastGroupIdentifier.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Hash for MulticastGroupIdentifier { fn hash<H: Hasher>(&self, state: &mut H) { self.localIdentifier.hash(state); unsafe { self.multicastGroupId.raw.hash(state) }; } } impl MulticastGroupIdentifier { #[inline(always)] pub fn new(subnetPrefix: __be64, interfaceId: __be64, localIdentifier: Loc...
code_fim
hard
{ "lang": "rust", "repo": "jisuanjidaqiang/rdma-core", "path": "/workspace/rdma-core/src/verbs/model/queuePairs/MulticastGroupIdentifier.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jisuanjidaqiang/rdma-core path: /workspace/rdma-core/src/verbs/model/queuePairs/MulticastGroupIdentifier.rs // This file is part of dpdk. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonr...
code_fim
hard
{ "lang": "rust", "repo": "jisuanjidaqiang/rdma-core", "path": "/workspace/rdma-core/src/verbs/model/queuePairs/MulticastGroupIdentifier.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let bmp_opts = parsebgp_bmp_opts { peer_ip_afi: parsebgp_bgp_afi_t_PARSEBGP_BGP_AFI_IPV4, parse_headers_only: 0, }; return parsebgp_opts { ignore_not_implemented: 0, silence_not_implemented: 0, ignore_invalid: 0, silence_invalid: 0, bgp:...
code_fim
hard
{ "lang": "rust", "repo": "digizeph/libparsebgp-rs", "path": "/src/bin/parsebgp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digizeph/libparsebgp-rs path: /src/bin/parsebgp.rs use parsebgp_rs::*; use std::{io::Read, fs::File}; /// ```rust /// pub fn parsebgp_decode( /// opts: parsebgp_opts_t, /// type_: parsebgp_msg_type_t, /// msg: *mut parsebgp_msg_t, /// buffer: *const u8, /// ...
code_fim
hard
{ "lang": "rust", "repo": "digizeph/libparsebgp-rs", "path": "/src/bin/parsebgp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiegec/rcore_plus path: /kernel/src/arch/aarch64/mod.rs //! Entrance and initialization for aarch64. use core::sync::atomic::{spin_loop_hint, AtomicBool, Ordering}; mod boot; pub mod consts; pub mod cpu; pub mod fp; pub mod interrupt; pub mod io; pub mod memory; pub mod paging; pub mod rand; p...
code_fim
hard
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/kernel/src/arch/aarch64/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while !AP_CAN_INIT.load(Ordering::Relaxed) { spin_loop_hint(); } unsafe { trapframe::init(); } memory::init_other(); //timer::init(); crate::kmain(); }<|fim_prefix|>// repo: jiegec/rcore_plus path: /kernel/src/arch/aarch64/mod.rs //! Entrance and initializatio...
code_fim
hard
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/kernel/src/arch/aarch64/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> board::early_final(); crate::lkm::manager::ModuleManager::init(); board::init(); crate::process::init(); // wake up other CPUs AP_CAN_INIT.store(true, Ordering::Relaxed); crate::kmain(); } #[no_mangle] pub extern "C" fn others_start() -> ! { println!("Hello {}! from CPU...
code_fim
hard
{ "lang": "rust", "repo": "jiegec/rcore_plus", "path": "/kernel/src/arch/aarch64/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JesseWright/aws-sdk-rust path: /sdk/forecast/src/operation_ser.rs // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. pub fn serialize_operation_create_dataset( input: &crate::input::CreateDatasetInput, ) -> Result<smithy_http::body::SdkBody, smithy_types::Error>...
code_fim
hard
{ "lang": "rust", "repo": "JesseWright/aws-sdk-rust", "path": "/sdk/forecast/src/operation_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn serialize_operation_delete_dataset_import_job( input: &crate::input::DeleteDatasetImportJobInput, ) -> Result<smithy_http::body::SdkBody, smithy_types::Error> { let mut out = String::new(); let mut object = smithy_json::serialize::JsonObjectWriter::new(&mut out); crate::json_ser::se...
code_fim
hard
{ "lang": "rust", "repo": "JesseWright/aws-sdk-rust", "path": "/sdk/forecast/src/operation_ser.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Solution { pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> { let result: Vec<i32> = Vec::new(); for i in 0..nums.len() { for j in 1..2 { if i == j { continue; } if target == nums[i] + nums[j] {...
code_fim
medium
{ "lang": "rust", "repo": "jiangwenhan/LeetCode", "path": "/rust/P-00001/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiangwenhan/LeetCode path: /rust/P-00001/src/main.rs /* Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2: Input: nums = [3,2,4], target = 6 Output: [1,2] Example 3: Input: nums = [3,3], targ...
code_fim
hard
{ "lang": "rust", "repo": "jiangwenhan/LeetCode", "path": "/rust/P-00001/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let nums = vec![3, 3]; let target = 6; Solution::two_sum(nums, target); }<|fim_prefix|>// repo: jiangwenhan/LeetCode path: /rust/P-00001/src/main.rs /* Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1...
code_fim
hard
{ "lang": "rust", "repo": "jiangwenhan/LeetCode", "path": "/rust/P-00001/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: phil-opp/drivers path: /ps2d/src/state.rs use orbclient::{KeyEvent, MouseEvent, ButtonEvent, ScrollEvent}; use std::cmp; use std::fs::File; use std::io::Write; use std::os::unix::io::AsRawFd; use syscall; use controller::Ps2; use vm; bitflags! { flags MousePacketFlags: u8 { const L...
code_fim
hard
{ "lang": "rust", "repo": "phil-opp/drivers", "path": "/ps2d/src/state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if dz != 0 { self.input.write(&ScrollEvent { x: 0, y: dz, }.to_event()).expect("ps2d: failed to write scroll event"); } let left = flags.cont...
code_fim
hard
{ "lang": "rust", "repo": "phil-opp/drivers", "path": "/ps2d/src/state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Liu-WeiHu/learn-rust path: /test/test-example/examples/demo1.rs use std::fs::File; use std::io::Read; use anyhow::Context; #[tokio::main] a<|fim_suffix|>ing(&mut s) .expect("读取到字符串失败"); println!("{}", s); Ok(()) }<|fim_middle|>sync fn main() -> anyhow::Result<()> { let mut s...
code_fim
medium
{ "lang": "rust", "repo": "Liu-WeiHu/learn-rust", "path": "/test/test-example/examples/demo1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ing(&mut s) .expect("读取到字符串失败"); println!("{}", s); Ok(()) }<|fim_prefix|>// repo: Liu-WeiHu/learn-rust path: /test/test-example/examples/demo1.rs use std::fs::File; use std::io::Read; use anyhow::Context; #[tokio::main] async fn main() -> anyhow::Result<()> { let mut s = String::new...
code_fim
medium
{ "lang": "rust", "repo": "Liu-WeiHu/learn-rust", "path": "/test/test-example/examples/demo1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WeAreRust/Nes path: /nes/src/cpu/instruction/tya.rs use cpu::{ instruction::{ExtraCycle, Instruction}, operation::Operation, Core, }; use memory::WriteAddr; /// Transfer index y to accumulator /// /// Flags affected: N, Z #[inline(always)] fn tya(core: &mut Core, _memory: &mut WriteAddr) ...
code_fim
hard
{ "lang": "rust", "repo": "WeAreRust/Nes", "path": "/nes/src/cpu/instruction/tya.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut core = Core::new(Registers::empty()); core.reg.y_idx = 128; tya(&mut core, &mut BlockMemory::with_size(0)); assert_eq!(core.reg.acc, 128); assert!(core.reg.status.contains(StatusFlags::N_FLAG)); } #[test] fn opcode() { assert_eq!(nes_asm!("TYA")[0], IMPLIED.opcode); ...
code_fim
hard
{ "lang": "rust", "repo": "WeAreRust/Nes", "path": "/nes/src/cpu/instruction/tya.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl IndexMut<usize> for OrFrame { #[inline] fn index_mut(&mut self, index: usize) -> &mut Self::Output { let prelude_offset = prelude_size::<OrFramePrelude>(); let index_offset = index * mem::size_of::<Addr>(); unsafe { let ptr = mem::transmute::<&mut OrFrame,...
code_fim
hard
{ "lang": "rust", "repo": "GavinMendelGleason/scryer-prolog", "path": "/src/prolog/machine/stack.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }