text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> objs.push(ObjRenderable { name: grp.name.clone(), mat_name: grp.mat.clone(), v_pos: v_pos, v_norm: v_norm, v_tx : v_tx, inds : inds }); } Ok(objs) } fn add_corner(mut ind_lookup : HashMap<(u32,u32,u32),u32>, ...
code_fim
hard
{ "lang": "rust", "repo": "hnen/import-obj", "path": "/src/obj_renderable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { LinalgError::NotSquare { rows, cols } => write!(f, "Not square: rows({}) != cols({})", rows, cols), LinalgError::Lapack { return_code } => write!(f, "LAPACK: return_code = {}", return_code), LinalgError::InvalidStride { s0, s1 } => write!(f, "invali...
code_fim
medium
{ "lang": "rust", "repo": "elsuizo/ndarray-linalg", "path": "/src/error.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elsuizo/ndarray-linalg path: /src/error.rs //! Define Errors use ndarray::{Ixs, ShapeError}; use std::error; use std::fmt; pub type Result<T> = ::std::result::Result<T, LinalgError>; /// Master Error type of this crate #[derive(Debug)] pub enum LinalgError { /// Matrix is not square N...
code_fim
medium
{ "lang": "rust", "repo": "elsuizo/ndarray-linalg", "path": "/src/error.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Drakesinger/rg3d path: /src/scene/camera.rs use crate::{ core::{ visitor::{ Visitor, VisitResult, Visit }, math::{ Rect, mat4::Mat4, vec2::Vec2, }, }, scene::base::{ Base, ...
code_fim
hard
{ "lang": "rust", "repo": "Drakesinger/rg3d", "path": "/src/scene/camera.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn is_enabled(&self) -> bool { self.enabled } #[inline] pub fn set_enabled(&mut self, enabled: bool) -> &mut Self { self.enabled = enabled; self } } pub struct CameraBuilder { base_builder: BaseBuilder, fov: f32, z_near: f32, ...
code_fim
hard
{ "lang": "rust", "repo": "Drakesinger/rg3d", "path": "/src/scene/camera.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn z_near(&self) -> f32 { self.z_near } /// In radians #[inline] pub fn set_fov(&mut self, fov: f32) -> &mut Self { self.fov = fov; self } #[inline] pub fn fov(&self) -> f32 { self.fov } #[inline] pub fn is_en...
code_fim
hard
{ "lang": "rust", "repo": "Drakesinger/rg3d", "path": "/src/scene/camera.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "async_")] impl<T, W> RecordWriter<T, W> where T: GenericRecord, W: AsyncWriteExt + Unpin, { /// Write a record. /// /// The method is enabled if the underlying writer implements [AsyncWriteExt]. pub async fn send_async(&mut self, record: T) -> Result<(), Error> { ...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderEkdahl/rust-tfrecord", "path": "/src/writer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexanderEkdahl/rust-tfrecord path: /src/writer.rs //! Writing TFRecord data format. //! //! The [RecordWriter] is initialized by [RecordWriterInit]. It can write //! either [Example], [RawExampple](crate::RawExample), [Vec\<u8\>](Vec), and many other record types. //! that implements [GenericRe...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderEkdahl/rust-tfrecord", "path": "/src/writer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sudowork/adventofcode path: /2020/04-passport/src/main.rs use regex::Regex; use std::collections::HashMap; use std::str::FromStr; use util; macro_rules! hashmap( { $($key:expr => $value:expr),+ } => { { let mut m = ::std::collections::HashMap::new(); $( ...
code_fim
hard
{ "lang": "rust", "repo": "sudowork/adventofcode", "path": "/2020/04-passport/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn is_len(len: usize) -> ValidationRule { Box::new(move |val: &str| val.len() == len) } fn is_parsable<T>() -> ValidationRule where T: FromStr, { Box::new(|val: &str| val.parse::<T>().is_ok()) } fn is_bounded(min: usize, max: usize) -> ValidationRule { Box::new(move |val: &str| { ...
code_fim
hard
{ "lang": "rust", "repo": "sudowork/adventofcode", "path": "/2020/04-passport/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn is_bounded(min: usize, max: usize) -> ValidationRule { Box::new(move |val: &str| { let val: usize = val.parse().unwrap(); val >= min && val <= max }) } fn matches_regex(re: regex::Regex) -> ValidationRule { Box::new(move |val: &str| re.is_match(val)) } fn is_one_of(options...
code_fim
hard
{ "lang": "rust", "repo": "sudowork/adventofcode", "path": "/2020/04-passport/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Trark/magmaflow path: /src/spv/dis.rs use std::fmt; use std::fmt::Display; use std::fmt::Formatter; use spv::types::*; /// Helper for printing the result id pub struct Result<'a>(pub &'a ResultId); impl<'a> Display for Result<'a> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { ...
code_fim
hard
{ "lang": "rust", "repo": "Trark/magmaflow", "path": "/src/spv/dis.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for element in self { try!(write!(f, " ")); try!(<T as DisplayArg>::display_arg(element, f)); } Ok(()) } } /// Formats an argument element for display inside a formatted argument. pub trait DisplayArg { fn display_arg(&self, f: &mut Formatter) -> fm...
code_fim
hard
{ "lang": "rust", "repo": "Trark/magmaflow", "path": "/src/spv/dis.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let res = self.eps.remove(key); self.progress.set_progress(self.eps.watched(), self.eps.len() as u32).unwrap(); res } } impl<'a> IntoIterator for &'a Video { type Item = &'a Episode; type IntoIter = Iter<'a>; fn into_iter(self) -> Self::IntoIter { self.iter...
code_fim
hard
{ "lang": "rust", "repo": "snylonue/navbg", "path": "/video/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snylonue/navbg path: /video/src/lib.rs pub mod episode; use chrono; use chrono::Utc; use serde_json; use serde::Serialize; use serde::Deserialize; use ngtools; use ngtools::random_hash; use basetask; use basetask::Tid; use episode::*; #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]...
code_fim
hard
{ "lang": "rust", "repo": "snylonue/navbg", "path": "/video/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nachiguro1003/rust-enved path: /examples/reader.rs use envded::{read_yaml, parse_yaml}; <|fim_suffix|>#[derive(Serialize, Deserialize,Debug)] struct Sample { aaa: String, bbb: String, } fn main() { let buf = read_yaml("sample.yaml"); let s: Sample = Sample { aaa: "".to_string()...
code_fim
easy
{ "lang": "rust", "repo": "nachiguro1003/rust-enved", "path": "/examples/reader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let buf = read_yaml("sample.yaml"); let s: Sample = Sample { aaa: "".to_string(), bbb: "".to_string() }; let res = parse_yaml(buf,s); println!("{:?}",res) }<|fim_prefix|>// repo: nachiguro1003/rust-enved path: /examples/reader.rs use envded::{read_yaml, parse_yaml}; <|fim_middle|>use ser...
code_fim
medium
{ "lang": "rust", "repo": "nachiguro1003/rust-enved", "path": "/examples/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let buf = read_yaml("sample.yaml"); let s: Sample = Sample { aaa: "".to_string(), bbb: "".to_string() }; let res = parse_yaml(buf,s); println!("{:?}",res) }<|fim_prefix|>// repo: nachiguro1003/rust-enved path: /examples/reader.rs use envded::{read_yaml, parse_yaml}; use serde...
code_fim
medium
{ "lang": "rust", "repo": "nachiguro1003/rust-enved", "path": "/examples/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use decode::{SectionDecoder, SectionsDecoder}; pub use encode::{SectionEncoder, SectionsEncoder}; pub use preview::SectionPreview;<|fim_prefix|>// repo: sudachen/svm path: /crates/codec/src/section/mod.rs pub mod decode; pub mod encode; <|fim_middle|>pub mod kind; pub mod preview; pub mod sections; ...
code_fim
easy
{ "lang": "rust", "repo": "sudachen/svm", "path": "/crates/codec/src/section/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sudachen/svm path: /crates/codec/src/section/mod.rs pub mod decode; pub mod encode; <|fim_suffix|>pub use decode::{SectionDecoder, SectionsDecoder}; pub use encode::{SectionEncoder, SectionsEncoder}; pub use preview::SectionPreview;<|fim_middle|>pub mod kind; pub mod preview; pub mod sections; ...
code_fim
easy
{ "lang": "rust", "repo": "sudachen/svm", "path": "/crates/codec/src/section/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wduquette/molt path: /molt/src/interp.rs use molt::types::*; /// # use molt::molt_ok; /// # fn dummy() -> MoltResult { /// # let mut interp = Interp::new(); /// interp.set_scalar("a", Value::from(1))?; /// interp.set_element("b", "1", Value::from(2)); /// /// assert!(...
code_fim
hard
{ "lang": "rust", "repo": "wduquette/molt", "path": "/molt/src/interp.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Merges a flat vector of keys and values into the named array. /// It's an error if the vector has an odd number of elements, or if the named variable /// is a scalar. This method is used to implement the `array set` command. /// /// # Example /// /// For example, the follo...
code_fim
hard
{ "lang": "rust", "repo": "wduquette/molt", "path": "/molt/src/interp.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Unsets an array variable givee its name. Nothing happens if the variable doesn't /// exist, or if the variable is not an array variable. pub(crate) fn array_unset(&mut self, array_name: &str) { self.scopes.array_unset(array_name); } /// Determines whether or not the name ...
code_fim
hard
{ "lang": "rust", "repo": "wduquette/molt", "path": "/molt/src/interp.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ssh352/crypto-trading-bot-public path: /src/order_book_snapshots.rs use crate::{ constants::{FEATURES_DATA_LIFETIME, ORDER_BOOK_SNAPSHOT_INTERVAL}, event::{OrderBookEventType, OrderBookUpdate}, order_book::OrderBook, price::Price, }; use chrono::{DateTime, Duration, Utc}; use std...
code_fim
hard
{ "lang": "rust", "repo": "ssh352/crypto-trading-bot-public", "path": "/src/order_book_snapshots.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// 60s of 100ms time interval snapshots of 25 price levels pub fn make_snapshot( &self, timestamp: DateTime<Utc>, ) -> VecDeque<(Vec<(Price, i32)>, Vec<(Price, i32)>, DateTime<Utc>)> { let mut snapshots = VecDeque::new(); let mut last_ss_ts: Option<DateTime<Utc...
code_fim
hard
{ "lang": "rust", "repo": "ssh352/crypto-trading-bot-public", "path": "/src/order_book_snapshots.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..FEATURES_DATA_LIFETIME * 1000 / ORDER_BOOK_SNAPSHOT_INTERVAL { let ts_cutoff = timestamp - Duration::milliseconds(i * ORDER_BOOK_SNAPSHOT_INTERVAL); for snapshot in self.snapshots.iter().rev() { let ss_ts = snapshot.2; if (last_s...
code_fim
hard
{ "lang": "rust", "repo": "ssh352/crypto-trading-bot-public", "path": "/src/order_book_snapshots.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>key for this session."] #[doc = ""] #[doc = " Each message is sent with a different ratchet key. This function returns the"] #[doc = " ratchet key that will be used for the next message."] #[doc = ""] #[doc = " Returns the length of the ratchet key on success or olm_error() on"] #[...
code_fim
hard
{ "lang": "rust", "repo": "valkum/olm-sys", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valkum/olm-sys path: /src/lib.rs #[doc = " Check if the session has been verified as a valid session."] #[doc = ""] #[doc = " (A session is verified either because the original session share was signed,"] #[doc = " or because we have subsequently successfully decrypted a message....
code_fim
hard
{ "lang": "rust", "repo": "valkum/olm-sys", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: valkum/olm-sys path: /src/lib.rs pickled_length: usize, ) -> usize; } extern "C" { #[doc = " Stores a session as a base64 string. Encrypts the session using the"] #[doc = " supplied key. Returns the length of the pickled session on success."] #[doc = " Returns olm_error() on fai...
code_fim
hard
{ "lang": "rust", "repo": "valkum/olm-sys", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let start : String = word.chars().skip(pos).collect(); let end : String = word.chars().take(pos).collect(); println!("{} {}{}",pos, start, end); } }<|fim_prefix|>// repo: NiklasJonsson/dailyprogrammer path: /314/inter.rs use std::env; use std::fs::File; use std::io::BufReader...
code_fim
hard
{ "lang": "rust", "repo": "NiklasJonsson/dailyprogrammer", "path": "/314/inter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NiklasJonsson/dailyprogrammer path: /314/inter.rs use std::env; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; fn rotate(a: &String, pos : usize) -> String { return format!("{}{}", a.chars().skip(pos).collect::<String>(), a.chars().take(pos).collect::<String>()); } fn ...
code_fim
hard
{ "lang": "rust", "repo": "NiklasJonsson/dailyprogrammer", "path": "/314/inter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emabee/flexi_logger path: /scripts/check.rs #!/usr/bin/env rust-script //! ```cargo //! [dependencies] //! yansi = "0.5" //! ``` extern crate yansi; use std::process::Command; macro_rules! run_command { ($cmd:expr , $($arg:expr),*) => ( let mut command = command!($cmd, $($arg),*); ...
code_fim
hard
{ "lang": "rust", "repo": "emabee/flexi_logger", "path": "/scripts/check.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Clippy in important variants run_command!("cargo", "clippy", "--all-features", "--", "-D", "warnings"); // doc #[rustfmt::skip] run_command!("cargo", "+nightly", "doc", "--all-features", "--no-deps", "--open"); // say goodbye println!("\n> checks are done :-) Looks like y...
code_fim
hard
{ "lang": "rust", "repo": "emabee/flexi_logger", "path": "/scripts/check.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MathisBurger/sporty-leaderboards path: /backend/src/database/actions/get_all_workouts.rs use crate::database::database_service::DatabaseService; use crate::database::models::workout_model::WorkoutModel; use sqlx::query_as; <|fim_suffix|> // query all workouts of user let workouts: Vec<Wo...
code_fim
medium
{ "lang": "rust", "repo": "MathisBurger/sporty-leaderboards", "path": "/backend/src/database/actions/get_all_workouts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // query all workouts of user let workouts: Vec<WorkoutModel> = query_as!(WorkoutModel, "SELECT * FROM `workouts` WHERE `username`=?", username) .fetch_all(&service.conn).await.unwrap(); return workouts; }<|fim_prefix|>// repo: MathisBurger/sporty-leaderboards path: /backend/src/datab...
code_fim
medium
{ "lang": "rust", "repo": "MathisBurger/sporty-leaderboards", "path": "/backend/src/database/actions/get_all_workouts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: veniamin-ilmer/crate-race path: /benches/bigint_arithmetic/_num_bigint.rs use bencher::Bencher; use num_bigint::BigUint; use num_traits::One; pub fn baseline(b: &mut Bencher) { b.iter(|| { let num_1: BigUint = One::one(); let mut num_sum: BigUint = One::one(); num_sum += &num_1; ...
code_fim
hard
{ "lang": "rust", "repo": "veniamin-ilmer/crate-race", "path": "/benches/bigint_arithmetic/_num_bigint.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn fact95(b: &mut Bencher) { b.iter(|| { let num_1: BigUint = One::one(); let mut num_sum: BigUint = One::one(); let mut fact: BigUint = One::one(); for _ in 1..95 { num_sum += &num_1; fact *= &num_sum; } let ten = BigUint::from(10u8); assert_eq!(BigUint:...
code_fim
hard
{ "lang": "rust", "repo": "veniamin-ilmer/crate-race", "path": "/benches/bigint_arithmetic/_num_bigint.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.writer.unwrap_self(); // TODO join the previous, written out text node with any now adjacent ones? // TODO apply above comment to the .delete() method ALSO } fn WrapPrevious(&mut self, count: usize, attrs: S::GroupProperties) { // console_log!("(A) {:?}", sel...
code_fim
hard
{ "lang": "rust", "repo": "hoangpq/edit-text", "path": "/oatie/src/stepper/docmutator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hoangpq/edit-text path: /oatie/src/stepper/docmutator.rs use super::*; use serde_json::json; use wasm_bindgen::prelude::*; impl Program { pub fn new() -> Program { Program(vec![]) } // Collapse trivial operations together. pub fn place(&mut self, mut code: Bytecode) { ...
code_fim
hard
{ "lang": "rust", "repo": "hoangpq/edit-text", "path": "/oatie/src/stepper/docmutator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.bc.place(Bytecode::DeleteElements(count)); for _ in 0..count { // No-op writer self.stepper.next(); } } fn InsertDocString(&mut self, docstring: DocString, styles: S::CharsProperties) { self.bc .place(Bytecode::InsertDocSt...
code_fim
hard
{ "lang": "rust", "repo": "hoangpq/edit-text", "path": "/oatie/src/stepper/docmutator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avranju/ntex-amqp path: /src/client/connect.rs use ntex::codec::Framed; use crate::Configuration; <|fim_suffix|>pub struct Handshake { _cfg: Configuration, }<|fim_middle|>trait IntoFramed<T, U: Default> { fn into_framed(self) -> Framed<T, U>; }
code_fim
medium
{ "lang": "rust", "repo": "avranju/ntex-amqp", "path": "/src/client/connect.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Handshake { _cfg: Configuration, }<|fim_prefix|>// repo: avranju/ntex-amqp path: /src/client/connect.rs use ntex::codec::Framed; use crate::Configuration; <|fim_middle|>trait IntoFramed<T, U: Default> { fn into_framed(self) -> Framed<T, U>; }
code_fim
medium
{ "lang": "rust", "repo": "avranju/ntex-amqp", "path": "/src/client/connect.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avranju/ntex-amqp path: /src/client/connect.rs use ntex::codec::Framed; <|fim_suffix|>} pub struct Handshake { _cfg: Configuration, }<|fim_middle|>use crate::Configuration; trait IntoFramed<T, U: Default> { fn into_framed(self) -> Framed<T, U>;
code_fim
medium
{ "lang": "rust", "repo": "avranju/ntex-amqp", "path": "/src/client/connect.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aaronjeline/aoc2019 path: /6.rs use std::fs; use std::collections::HashMap; type Orbits = HashMap<String, Vec<String>>; <|fim_suffix|> let mut os : Orbits = HashMap::new(); let contents = fs::read_to_string(f).expect("Can't read input"); for line in contents.split("\n") { le...
code_fim
medium
{ "lang": "rust", "repo": "aaronjeline/aoc2019", "path": "/6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let os = load("6.test"); } fn load(f : &str) -> Orbits { let mut os : Orbits = HashMap::new(); let contents = fs::read_to_string(f).expect("Can't read input"); for line in contents.split("\n") { let ld : Vec<&str> = line.split(")").collect(); let mut cur = os.get(ld[0]).un...
code_fim
medium
{ "lang": "rust", "repo": "aaronjeline/aoc2019", "path": "/6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", author_col.authors_with_indexes()); } fn handle_add_sub_command(mut authors: AuthorCollection, new_author: Author, file_path: &PathBuf) { authors.add_author(new_author); persistence::save(PathBuf::from(file_path), &authors); } fn handle_message_sub_command(authors: AuthorColle...
code_fim
hard
{ "lang": "rust", "repo": "jjmark15/pair-commit-rust", "path": "/src/cli/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjmark15/pair-commit-rust path: /src/cli/mod.rs use std::path::PathBuf; use clap::{App, Arg, SubCommand}; use pair_commit_tool::models::author::author_collection::AuthorCollection; use pair_commit_tool::models::author::Author; use crate::cli::user_input::get_user_input; use crate::config::Con...
code_fim
hard
{ "lang": "rust", "repo": "jjmark15/pair-commit-rust", "path": "/src/cli/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[widget(row = 1, col = 0, cspan = 2, rspan = 1, valign = top, halign = centre)] frame: Frame<Label>, #[widget(row = 2, col = 0, cspan = 2, rspan = 2, valign = stretch, halign = stretch, handler = list_handler)] scroll_list: ScrollRegion<Column<ListEntry>>, child_contents: Vec...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/slam-vbox-gui", "path": "/src/files_panel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/slam-vbox-gui path: /src/files_panel.rs use kas::{event::Response, prelude::*, widget::Column, widget::EditBox, widget::Filler, widget::Frame, widget::ScrollRegion, widget::TextButton}; use kas::widget::{Label}; use kas::class::HasString; use crate::{TopLevelMessage, edit_box_guards::...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/slam-vbox-gui", "path": "/src/files_panel.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[layout(grid)] #[derive(Debug, Widget)] #[handler(msg=TopLevelMessage)] pub struct FilesPanel { #[widget_core] core: CoreData, #[layout_data] layout_data: <Self as LayoutData>::Data, #[widget(row = 0, col = 1, cspan = 1, rspan = 1, valign = top, halign = centre, handler = ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/slam-vbox-gui", "path": "/src/files_panel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leshow/twilio-async path: /src/macros.rs macro_rules! execute { ($ty:tt) => { #[async_trait] impl<'a> Execute for $ty<'a> { fn request<U>( &self, method: Method, url: U, body: Option<String>, ...
code_fim
hard
{ "lang": "rust", "repo": "leshow/twilio-async", "path": "/src/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let res = self .client .client .request(req) .await .map_err(TwilioErr::NetworkErr)?; let body = hyper::body::aggregate(res).await?; let json_resp = serde_j...
code_fim
hard
{ "lang": "rust", "repo": "leshow/twilio-async", "path": "/src/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> school_member::teacher::get_salary(); }<|fim_prefix|>// repo: talalriaz/A_7 path: /q1/src/main.rs mod school_member{ pub mod teacher{ pub fn get_salary(){ println!("Salary"); } } } <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "talalriaz/A_7", "path": "/q1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: talalriaz/A_7 path: /q1/src/main.rs mod school_member{ pub mod teacher{ pub fn get_salary(){ println!("Salary"); } } } <|fim_suffix|> school_member::teacher::get_salary(); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "talalriaz/A_7", "path": "/q1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn field_type(&self) -> &FieldType { &self.field_type } pub fn field_type(&self) -> &i64 { &self.timestamp } }<|fim_prefix|>// repo: saromanov/textse path: /src/core/field.rs // // field.rs represents implementation // of the field for schema and serialization // an...
code_fim
hard
{ "lang": "rust", "repo": "saromanov/textse", "path": "/src/core/field.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saromanov/textse path: /src/core/field.rs // // field.rs represents implementation // of the field for schema and serialization // and deserialization on the fields based on type use std::fmt; use std::time::{SystemTime, UNIX_EPOCH}; pub enum FieldType { I64, STRING, F64 } <|fim_suff...
code_fim
hard
{ "lang": "rust", "repo": "saromanov/textse", "path": "/src/core/field.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akubera/flo path: /flo-client-lib/src/async/ops/handshake.rs use std::fmt::{self, Display, Debug}; use std::io; use futures::{Future, Async, Poll}; use protocol::{ProtocolMessage, ClientAnnounce}; use async::{AsyncConnection, ErrorType, ClientProtocolMessage}; use async::ops::{RequestResponse...
code_fim
hard
{ "lang": "rust", "repo": "akubera/flo", "path": "/flo-client-lib/src/async/ops/handshake.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl <D: Debug> Future for Handshake<D> { type Item = AsyncConnection<D>; type Error = HandshakeError; fn poll(&mut self) -> Poll<Self::Item, Self::Error> { let (response, connection) = try_ready!(self.request_response.poll()); result_from_response(response, connection) } ...
code_fim
hard
{ "lang": "rust", "repo": "akubera/flo", "path": "/flo-client-lib/src/async/ops/handshake.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/src/elf_runner/tests/lifecycle/lifecycle_timeout.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { component_events::{...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/elf_runner/tests/lifecycle/lifecycle_timeout.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // We expect three components to stop: the root component and its two children. EventSequence::new() .has_subset( vec![ EventMatcher::ok() .moniker(custom_timeout_child.clone()) .stop(Some(ExitStatusMatcher::Clean)), ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/elf_runner/tests/lifecycle/lifecycle_timeout.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>red for container management #[allow(clippy::module_inception)] mod command; pub mod linux; pub mod test; pub use command::Command;<|fim_prefix|>// repo: sasurau4/youki path: /src/command/mod.rs //! Contains a wrapper of syscalls for unit tests //! This provide<|fim_middle|>s a uniform interface for re...
code_fim
medium
{ "lang": "rust", "repo": "sasurau4/youki", "path": "/src/command/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sasurau4/youki path: /src/command/mod.rs //! Contains a wrapper of syscalls for unit tests //! This provides a uniform interface for rest of Youki //! to call syscalls requi<|fim_suffix|>od command; pub mod linux; pub mod test; pub use command::Command;<|fim_middle|>red for container management...
code_fim
medium
{ "lang": "rust", "repo": "sasurau4/youki", "path": "/src/command/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { Personality::Employee(e) => e.ided(), Personality::Professor(p) => p.ided(), Personality::Student(s) => s.ided(), } } }<|fim_prefix|>// repo: MaxLuchs/trait_test path: /src/ided.rs use crate::student::Student; use crate::professor::Prof...
code_fim
hard
{ "lang": "rust", "repo": "MaxLuchs/trait_test", "path": "/src/ided.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn use_ided_generic<T: Ided>(item: T) { println!("use ided: {}", item.ided()) } // static Trait usage: pub enum Personality { Employee(Employee), Professor(Professor), Student(Student), } impl Ided for Personality { fn ided(&self) -> u64 { match self { Perso...
code_fim
medium
{ "lang": "rust", "repo": "MaxLuchs/trait_test", "path": "/src/ided.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaxLuchs/trait_test path: /src/ided.rs use crate::student::Student; use crate::professor::Professor; use crate::employee::Employee; pub trait Ided { fn ided(&self) -> u64; } // dynamic Trait usage: pub fn use_ided_impl(item: impl Ided) { println!("use ided: {}", item.ided()) } pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "MaxLuchs/trait_test", "path": "/src/ided.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: melbyruarus/rusttorrent path: /src/messages.rs use super::support::*; use super::network::*; use std; use std::thread::{self, JoinGuard}; use std::sync::mpsc::{channel, Sender, Receiver, SendError}; use std::io; pub enum Message { Handshake(Protocol, Extensions, InfoHash, PeerId), KeepAlive,...
code_fim
hard
{ "lang": "rust", "repo": "melbyruarus/rusttorrent", "path": "/src/messages.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> SocketManager<'a> { pub fn start<S: 'a + io::Write + Send, R: 'a + io::Read + Send>(mut sending_socket: S, mut listening_socket: R) -> SocketManager<'a> { let (client_send, server_listen) = channel::<Message>(); let (server_send, client_listen) = channel::<Message>(); SocketManager { s...
code_fim
hard
{ "lang": "rust", "repo": "melbyruarus/rusttorrent", "path": "/src/messages.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtwood/rlibc path: /src/macros.rs #[macro_export] macro_rules! forward { ($sys: ident) => { forward!($sys,) }; ($sys: ident, $($p: expr),*) => { match syscall!($sys $(, $p)*) as i32 { n if n < 0 => { errno = -n; -1 }, ...
code_fim
hard
{ "lang": "rust", "repo": "dtwood/rlibc", "path": "/src/macros.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ($name: ident = $mangled_name: expr) => { #[export_name=$mangled_name] #[allow(non_snake_case)] pub unsafe extern "C" fn $name() { undef_helper!($name); } }; }<|fim_prefix|>// repo: dtwood/rlibc path: /src/macros.rs #[macro_export] macro_rules! forward ...
code_fim
hard
{ "lang": "rust", "repo": "dtwood/rlibc", "path": "/src/macros.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hbowers/sneat path: /src/main.rs use amethyst::{ core::{SystemBundle, TransformBundle}, ecs::DispatcherBuilder, error::Error, input::{Bindings, InputSystemDesc, StringBindings}, prelude::*, renderer::{ plugins::{RenderFlat2D, RenderToWindow}, types::Defaul...
code_fim
hard
{ "lang": "rust", "repo": "Hbowers/sneat", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let game_data = GameDataBuilder::default() .with_bundle(StartingBundle {})? .with_bundle(render_bundle)? .with(systems::AnimationSystem, "animation_system", &[]) .with( systems::AnimationChangingSystem, "animation_changing_system", &[...
code_fim
hard
{ "lang": "rust", "repo": "Hbowers/sneat", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn search(_index_name: String) -> String { //TODO : Search document in index format!("SEARCH {}", "OK") }<|fim_prefix|>// repo: Universemul/search_engine path: /src/internal/routes/index.rs use std::fs; use std::path::Path; use crate::internal::models::Index; use crate::fs::lz4_provider::LZ4...
code_fim
medium
{ "lang": "rust", "repo": "Universemul/search_engine", "path": "/src/internal/routes/index.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Universemul/search_engine path: /src/internal/routes/index.rs use std::fs; use std::path::Path; use crate::internal::models::Index; use crate::fs::lz4_provider::LZ4Provider; use crate::fs::provider::FsProvider; <|fim_suffix|>pub fn search(_index_name: String) -> String { //TODO : Search do...
code_fim
hard
{ "lang": "rust", "repo": "Universemul/search_engine", "path": "/src/internal/routes/index.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stepnivlk/ohboy path: /src/gpu.rs use crate::mmu::{OAM_SIZE, V_RAM_SIZE}; const SCREEN_SIZE: usize = 168 * 144 * 4; enum Mode { ScanlineOam, ScanlineVram, Hblank, Vblank, } // TODO: Who should own the CPU, what is the hiearchy of components? // RN: CPU -> Bus -> GPU // Q? Bus ...
code_fim
hard
{ "lang": "rust", "repo": "stepnivlk/ohboy", "path": "/src/gpu.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Write scanline } }, Mode::Hblank => { if self.modeclock >= 204 { self.modeclock = 0; self.line += self.line; if self.line == 143 { self...
code_fim
hard
{ "lang": "rust", "repo": "stepnivlk/ohboy", "path": "/src/gpu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Mode::Hblank => { if self.modeclock >= 204 { self.modeclock = 0; self.line += self.line; if self.line == 143 { self.mode = Mode::Vblank; // TODO: screen to framebuffer ...
code_fim
hard
{ "lang": "rust", "repo": "stepnivlk/ohboy", "path": "/src/gpu.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luhuimao/morgan path: /netutil/src/bin/ip_address.rs use clap::{crate_version, App, Arg}; fn main() { morgan_logger::setup(); let matches = App::new("morgan-ip-address") .version(crate_version!()) .arg( Arg::with_name("host_port") .index(1) ...
code_fim
medium
{ "lang": "rust", "repo": "luhuimao/morgan", "path": "/netutil/src/bin/ip_address.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match morgan_netutil::get_public_ip_addr(&addr) { Ok(ip) => println!("{}", ip), Err(err) => { eprintln!("{}: {}", addr, err); std::process::exit(1) } } }<|fim_prefix|>// repo: luhuimao/morgan path: /netutil/src/bin/ip_address.rs use clap::{crate_ver...
code_fim
medium
{ "lang": "rust", "repo": "luhuimao/morgan", "path": "/netutil/src/bin/ip_address.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vadfabi/orjson path: /src/encode.rs // SPDX-License-Identifier: (Apache-2.0 OR MIT) use crate::typeref::*; use pyo3::prelude::*; use pyo3::types::*; use pyo3::ToPyPointer; use serde::ser::{self, Serialize, SerializeMap, SerializeSeq, Serializer}; pub fn serialize(py: Python, obj: PyObject) -> ...
code_fim
hard
{ "lang": "rust", "repo": "vadfabi/orjson", "path": "/src/encode.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where S: Serializer, { let obj_ptr = self.obj.get_type_ptr(); if unsafe { obj_ptr == STR_PTR } { let val = unsafe { <PyUnicode as PyTryFrom>::try_from_unchecked(self.obj) }; serializer.serialize_str(unsafe { std::str::from_utf8_unchecked(val.as_bytes...
code_fim
hard
{ "lang": "rust", "repo": "vadfabi/orjson", "path": "/src/encode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: justinmchase/verse-lang path: /src/runtime/library.rs extern crate regex; use crate::ast::{Expression, Pattern}; use crate::runtime::{exec, Context, Name, Namespace, RuntimeError, Value, Verse}; use semver::Version; use std::cell::RefCell; use std::collections::HashMap; use std::hash::{Hash, Has...
code_fim
hard
{ "lang": "rust", "repo": "justinmchase/verse-lang", "path": "/src/runtime/library.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let lib = Library::new(&Name::from("test"), &Version::parse("1.0.0").unwrap()); let res = lib .add_module(&Namespace::parse("foo.bar"), Expression::None)? .add_module(&Namespace::parse("foo.bar"), Expression::None); assert_eq!( res, Err(RuntimeError::DuplicateNamespaceE...
code_fim
hard
{ "lang": "rust", "repo": "justinmchase/verse-lang", "path": "/src/runtime/library.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bbb651/system_uri path: /src/ffi.rs // Copyright 2018 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT // http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD // https://opensource.org/licenses/BSD-3-Clause>, at ...
code_fim
hard
{ "lang": "rust", "repo": "bbb651/system_uri", "path": "/src/ffi.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Install the given App definition for each scheme URI on the system. /// Schemes are a comma delimited list of schemes. #[no_mangle] pub unsafe extern "C" fn install( bundle: *const c_char, vendor: *const c_char, name: *const c_char, exec_args: *const *const c_char, exec_args_len: u...
code_fim
hard
{ "lang": "rust", "repo": "bbb651/system_uri", "path": "/src/ffi.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> out[3] = xy - wz; out[4] = T::one() - (xx + zz); out[5] = yz + wx; out[6] = xz + wy; out[7] = yz - wx; out[8] = T::one() - (xx + yy); out }<|fim_prefix|>// repo: nathanfaucett/rs-mat3 path: /src/transform.rs use num::Num; #[inline] pub fn scale<'a, 'b, T: Copy + Num>(out: &...
code_fim
hard
{ "lang": "rust", "repo": "nathanfaucett/rs-mat3", "path": "/src/transform.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nathanfaucett/rs-mat3 path: /src/transform.rs use num::Num; #[inline] pub fn scale<'a, 'b, T: Copy + Num>(out: &'a mut [T; 9], a: &'b [T; 9], v: &'b [T; 3]) -> &'a mut [T; 9] { let x = v[0]; let y = v[1]; let z = v[2]; out[0] = a[0] * x; out[3] = a[3] * y; out[6] = a[6...
code_fim
hard
{ "lang": "rust", "repo": "nathanfaucett/rs-mat3", "path": "/src/transform.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match (a, b, c) { (Cell::Allive, Cell::Allive, Cell::Allive) => Cell::Dead, // 7 (Cell::Allive, Cell::Allive, Cell::Dead) => Cell::Allive, // 6 (Cell::Allive, Cell::Dead, Cell::Allive) => Cell::Allive, // 5 (Cell::Allive, Cell::Dead, Cell::Dead) => Cell::Dead, // 4 ...
code_fim
hard
{ "lang": "rust", "repo": "cowboy8625/CookBook", "path": "/Languages/rule110/rule110-rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cowboy8625/CookBook path: /Languages/rule110/rule110-rust/src/main.rs use std::time::Duration; const WIDTH: usize = 100; #[derive(Debug, Clone, Copy)] enum Cell { Allive, Dead, } fn main() { let mut grid = vec![Cell::Dead; WIDTH]; grid[WIDTH - 1] = Cell::Allive; loop { ...
code_fim
medium
{ "lang": "rust", "repo": "cowboy8625/CookBook", "path": "/Languages/rule110/rule110-rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MDGSF/JustCoding path: /rust-leetcode/leetcode_sw_40_02/src/main.rs use std::collections::BinaryHeap; impl Solution { pub fn get_least_numbers(arr: Vec<i32>, k: i32) -> Vec<i32> { let mut heap = BinaryHeap::with_capacity(k as usize); for num in arr { if heap.len() < k as usize {...
code_fim
medium
{ "lang": "rust", "repo": "MDGSF/JustCoding", "path": "/rust-leetcode/leetcode_sw_40_02/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let arr = vec![3, 2, 1]; let k = 2; let result = Solution::get_least_numbers(arr, k); println!("result = {:?}", result); }<|fim_prefix|>// repo: MDGSF/JustCoding path: /rust-leetcode/leetcode_sw_40_02/src/main.rs use std::collections::BinaryHeap; impl Solution { pub fn get_least_nu...
code_fim
medium
{ "lang": "rust", "repo": "MDGSF/JustCoding", "path": "/rust-leetcode/leetcode_sw_40_02/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use std::iter::FromIterator; let iter = (0..3).map(|i| OscType::Int(i)); let osc_arr = OscArray::from_iter(iter); assert_eq!( osc_arr, OscArray { content: vec![OscType::Int(0), OscType::Int(1), OscType::Int(2)] } ); }<|fim_prefix|>// repo: helgoboss/...
code_fim
easy
{ "lang": "rust", "repo": "helgoboss/rosc", "path": "/tests/types_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: helgoboss/rosc path: /tests/types_test.rs extern crate rosc; use rosc::{OscArray, OscType}; <|fim_suffix|> use std::iter::FromIterator; let iter = (0..3).map(|i| OscType::Int(i)); let osc_arr = OscArray::from_iter(iter); assert_eq!( osc_arr, OscArray { ...
code_fim
easy
{ "lang": "rust", "repo": "helgoboss/rosc", "path": "/tests/types_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //placeholder for debug trait println!("{:?}",(12,true,"hello")); //(12, true, "hello") //basic math println!("10 + 10= {}",10+10); //10 + 10= 20 }<|fim_prefix|>// repo: simonvista/Rust path: /src/print_format.rs pub fn run(){ // print to console println!("hello from printFormat...
code_fim
hard
{ "lang": "rust", "repo": "simonvista/Rust", "path": "/src/print_format.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simonvista/Rust path: /src/print_format.rs pub fn run(){ // print to console println!("hello from printFormat.rs file"); // basic format println!("num: {}", 1); //num: 1 println!("{} is from {}","bread","wheat"); //bread is from wheat // positional arguments pri...
code_fim
medium
{ "lang": "rust", "repo": "simonvista/Rust", "path": "/src/print_format.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krre/ocean-backend path: /src/ocean/controller/activity.rs use crate::controller::forum; use crate::controller::mandela; use crate::controller::*; use serde::{Deserialize, Serialize}; <|fim_suffix|> let req: Req = data.params()?; #[derive(Serialize)] struct Resp { comments: ...
code_fim
medium
{ "lang": "rust", "repo": "krre/ocean-backend", "path": "/src/ocean/controller/activity.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let topics = forum::new_topics(&data.db, req.limit, 0)?; let comments = mandela::new_comments(&data.db, req.limit, 0)?; let resp = Resp { comments, topics }; let result = serde_json::to_value(&resp)?; Ok(Some(result)) }<|fim_prefix|>// repo: krre/ocean-backend path: /src/ocean/contro...
code_fim
medium
{ "lang": "rust", "repo": "krre/ocean-backend", "path": "/src/ocean/controller/activity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Serialize)] struct Resp { comments: Vec<mandela::Comment>, topics: Vec<forum::Topic>, } let topics = forum::new_topics(&data.db, req.limit, 0)?; let comments = mandela::new_comments(&data.db, req.limit, 0)?; let resp = Resp { comments, topics }; let r...
code_fim
medium
{ "lang": "rust", "repo": "krre/ocean-backend", "path": "/src/ocean/controller/activity.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] mod tests { use super::Token; use super::Lexer; #[test] fn lexer() { let input = " let five = 5; let add = fn(x, y) { x + y; }; !-/*5; 5 < 10 > 5; if (5 < 10) { ...
code_fim
hard
{ "lang": "rust", "repo": "pastchick3/monkey", "path": "/src/lexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let add = fn(x, y) { x + y; }; !-/*5; 5 < 10 > 5; if (5 < 10) { return true; } else { return false; } 10 == 10; 10 != 9; \"a b\"; ...
code_fim
hard
{ "lang": "rust", "repo": "pastchick3/monkey", "path": "/src/lexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pastchick3/monkey path: /src/lexer.rs use crate::token::Token; pub struct Lexer { input: Vec<char>, pos: usize, } impl Lexer { pub fn new(input: &str) -> Lexer{ Lexer { input: input.chars().collect(), pos: 0, } } fn ch(&self) -> Opti...
code_fim
hard
{ "lang": "rust", "repo": "pastchick3/monkey", "path": "/src/lexer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }