text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: informalsystems/amino_rs path: /benchmarks/src/lib.rs #![feature(test)] extern crate bytes; extern crate prost_amino as prost; extern crate test; #[macro_use] extern crate prost_amino_derive; mod varint; use prost::Message; pub fn bench_message_encode<M>(b: &mut test::Bencher, message: &M) ...
code_fim
hard
{ "lang": "rust", "repo": "informalsystems/amino_rs", "path": "/benchmarks/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn new(sequence_id: u8) -> Self { MySQLPacketWriter { payload: vec![0x00, 0x00, 0x00, sequence_id], } } fn write_lenenc_bytes(&mut self, b: &[u8]) { let l = b.len(); // write the length of the data using variable-length encoding if l < 0xfc...
code_fim
hard
{ "lang": "rust", "repo": "placrosse/agildata-zero", "path": "/src/proxy/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: placrosse/agildata-zero path: /src/proxy/server.rs ff | 0xfe => { match *next { Some(box ref n) => (Some(n.clone()), Action::Forward), _ => (Some(HandlerState::ExpectClientRequest), Action::Forward) ...
code_fim
hard
{ "lang": "rust", "repo": "placrosse/agildata-zero", "path": "/src/proxy/server.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_lenenc_bytes(&mut self) -> Option<Vec<u8>> { match self.read_len() { 0xfb => None, n @ _ => { let s = &self.payload[self.pos..self.pos+n]; self.pos += n; let mut v : Vec<u8> = vec![]; v.extend_f...
code_fim
hard
{ "lang": "rust", "repo": "placrosse/agildata-zero", "path": "/src/proxy/server.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Converts a Rust Duration to a Protobuf Duration. /// Taken from https://github.com/linkerd/linkerd2-proxy-api pub fn convert_duration(duration: std::time::Duration) -> prost_types::Duration { let seconds = if duration.as_secs() > std::i64::MAX as u64 { std::i64::MAX } else { duration.as_se...
code_fim
medium
{ "lang": "rust", "repo": "chimney-rock/heimdallr", "path": "/api/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chimney-rock/heimdallr path: /api/src/lib.rs // pub mod health { // tonic::include_proto!("grpc.health.v1"); // pub use health_check_response::ServingStatus; // impl From<i32> for ServingStatus { // fn from(item: i32) -> Self { // match item { // 1 => ServingStatus::Serv...
code_fim
medium
{ "lang": "rust", "repo": "chimney-rock/heimdallr", "path": "/api/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let elapsed = Instant::now(); thread::scope(|s| { s.spawn(|_| { let mut count = n/2; while count > 0 { let _unuse = json::parse(&contents).unwrap(); count -= 1; } }); s.spawn(|_| { let mut count = n/2; while count > 0 { let _unuse = json::parse(&contents).unwrap(...
code_fim
medium
{ "lang": "rust", "repo": "sillyemperor/whoisthefastestlang", "path": "/rust/json-load/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sillyemperor/whoisthefastestlang path: /rust/json-load/src/main.rs use std::fs; use std::time::Instant; use json; use crossbeam::thread; fn synchronize(contents: &str, n: u128) { let elapsed = Instant::now(); let mut count = n; while count > 0 { let _unuse = json::parse(&contents).unwrap...
code_fim
medium
{ "lang": "rust", "repo": "sillyemperor/whoisthefastestlang", "path": "/rust/json-load/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let contents = fs::read_to_string("../../data/big.json") .expect("Something went wrong reading the file"); synchronize(&contents, 100000); multiple_thread(&contents, 100000); }<|fim_prefix|>// repo: sillyemperor/whoisthefastestlang path: /rust/json-load/src/main.rs use std::fs; use std::time::Inst...
code_fim
hard
{ "lang": "rust", "repo": "sillyemperor/whoisthefastestlang", "path": "/rust/json-load/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> x % 2 == 1 } fn main() { let s1 = read::<String>(); let s = s1.chars().collect::<Vec<char>>(); let n = s.len(); //println!("{:?}", s); let mut dp = vec![0u64; n]; let mut next_l = 0; let mut last_r = n - 1; for i in 0..n { if s[i] == 'L' { next_l = ...
code_fim
medium
{ "lang": "rust", "repo": "emergent/rust-atc-solution", "path": "/abc136/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..n { if s[i] == 'R' { if i > next_l { for j in i + 1..n { if s[j] == 'L' { next_l = j; break; } } } if even(next_l - i) { ...
code_fim
hard
{ "lang": "rust", "repo": "emergent/rust-atc-solution", "path": "/abc136/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emergent/rust-atc-solution path: /abc136/d.rs #[allow(dead_code)] fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } #[allow(dead_code)] fn read_vec<T: std::str::FromStr>() -> Vec<T> { <|fim_suff...
code_fim
hard
{ "lang": "rust", "repo": "emergent/rust-atc-solution", "path": "/abc136/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvolkmann/rust-rest path: /tide/src/main.rs use async_std::sync::Arc; use parking_lot::RwLock; use std::collections::HashMap; use tide::prelude::*; use tide::{Body, Request, Response, StatusCode}; use uuid::Uuid; // We need to implement the "Clone" trait in order to // call the "cloned" method ...
code_fim
hard
{ "lang": "rust", "repo": "mvolkmann/rust-rest", "path": "/tide/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let state = State { dog_map: Arc::new(RwLock::new(dog_map)), }; let mut app = tide::with_state(state); app.at("/dog") // Get all dogs. .get(|req: Request<State>| async move { let dog_map = req.state().dog_map.read(); let dogs: Vec<Dog> = dog...
code_fim
hard
{ "lang": "rust", "repo": "mvolkmann/rust-rest", "path": "/tide/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> app.at("/dog/:id") // Get a specific dog. .get(|req: Request<State>| async move { let id = req.param("id")?; let dog_map = req.state().dog_map.read(); if let Some(dog) = dog_map.get(id.clone()) { let mut res = Response::new(StatusCode...
code_fim
hard
{ "lang": "rust", "repo": "mvolkmann/rust-rest", "path": "/tide/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_uploaded_file_url(&self, upload_path: &str) -> Url { let mut url: Url = self.get_attachment_url(); url.set_path(upload_path); url } }<|fim_prefix|>// repo: sangwon090/loco.rs path: /src/internal/attachment.rs use reqwest::Url; use crate::define_host; define_ho...
code_fim
hard
{ "lang": "rust", "repo": "sangwon090/loco.rs", "path": "/src/internal/attachment.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_attachment_url(&self) -> Url { match self { AttachmentType::Image => media_file::url(), AttachmentType::Audio => audio_file::url(), AttachmentType::Video => video_file::url(), AttachmentType::File => media_file::url(), /*_ ...
code_fim
hard
{ "lang": "rust", "repo": "sangwon090/loco.rs", "path": "/src/internal/attachment.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sangwon090/loco.rs path: /src/internal/attachment.rs use reqwest::Url; use crate::define_host; define_host!(profile_upload, "up-p.talk.kakao.com"); define_host!(media_upload, "up-gp.talk.kakao.com"); define_host!(video_upload, "up-m.talk.kakao.com"); define_host!(audio_upload, "up-v.talk.kakao...
code_fim
hard
{ "lang": "rust", "repo": "sangwon090/loco.rs", "path": "/src/internal/attachment.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> value.strip_prefix(MANA_HALF) .and_then(|stripped| Colour::try_from(stripped).ok().map(|col| Mana::Half(col))) } /// Tries to convert a string without specifiers into snow mana. /// /// # Parameters /// /// * `value` - the string to convert fn into_snow(val...
code_fim
hard
{ "lang": "rust", "repo": "at-robins/phyrexian-library", "path": "/src/magic/colour.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: at-robins/phyrexian-library path: /src/magic/colour.rs for &str { fn from(colour: Colour) -> Self { (&colour).into() } } impl From<&Colour> for &str { fn from(colour: &Colour) -> Self { match colour { Colour::Black => COLOUR_BLACK, Colour::Blu...
code_fim
hard
{ "lang": "rust", "repo": "at-robins/phyrexian-library", "path": "/src/magic/colour.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: at-robins/phyrexian-library path: /src/magic/colour.rs /// /// ``` /// use phyrexian_library::magic::colour::{Colour, ColourSet}; /// /// let mut colours = ColourSet::new(); /// assert_eq!(0, colours.length()); /// colours.add(Colour::Black); /// assert_eq!(1, colour...
code_fim
hard
{ "lang": "rust", "repo": "at-robins/phyrexian-library", "path": "/src/magic/colour.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ypoluektovich/tmux-interface-rs path: /src/commands/clients_and_sessions/list_sessions.rs use crate::commands::constants::*; use crate::{Error, TmuxCommand, TmuxOutput}; use std::borrow::Cow; // XXX: better result return? /// List all sessions managed by the server /// # Manual /// /// tmux ^1....
code_fim
hard
{ "lang": "rust", "repo": "ypoluektovich/tmux-interface-rs", "path": "/src/commands/clients_and_sessions/list_sessions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self(TmuxCommand { bin: item.bin.clone(), cmd: Some(Cow::Borrowed(LIST_SESSIONS)), ..Default::default() }) } }<|fim_prefix|>// repo: ypoluektovich/tmux-interface-rs path: /src/commands/clients_and_sessions/list_sessions.rs use crate::commands::const...
code_fim
hard
{ "lang": "rust", "repo": "ypoluektovich/tmux-interface-rs", "path": "/src/commands/clients_and_sessions/list_sessions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> From<&TmuxCommand<'a>> for ListSessions<'a> { fn from(item: &TmuxCommand<'a>) -> Self { Self(TmuxCommand { bin: item.bin.clone(), cmd: Some(Cow::Borrowed(LIST_SESSIONS)), ..Default::default() }) } }<|fim_prefix|>// repo: ypoluektovich/tm...
code_fim
hard
{ "lang": "rust", "repo": "ypoluektovich/tmux-interface-rs", "path": "/src/commands/clients_and_sessions/list_sessions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Terkwood/BUGOUT path: /gateway/src/topics.rs pub const MAKE_MOVE_TOPIC: &str = "bugout-make-move-cmd"; pub const PROVIDE_HISTORY_TOPIC: &str = "bugout-provide-history-cmd"; pub const JOIN_PRIVATE_GAME_TOPIC: &str = "bugout-join-private-game-cmd"; pub const FIND_PUBLIC_GAME_TOPIC: &str = "bugout-...
code_fim
hard
{ "lang": "rust", "repo": "Terkwood/BUGOUT", "path": "/gateway/src/topics.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>S_CHOSEN_TOPIC: &str = "bugout-colors-chosen-ev"; pub const SESSION_DISCONNECTED_TOPIC: &str = "bugout-session-disconnected-ev"; pub const BOT_ATTACHED_TOPIC: &str = "bugout-bot-attached-ev"; pub const SYNC_REPLY_TOPIC: &str = "bugout-sync-reply-ev"; pub const MOVE_UNDONE_TOPIC: &str = "bugout-move-undone...
code_fim
hard
{ "lang": "rust", "repo": "Terkwood/BUGOUT", "path": "/gateway/src/topics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_next_board(&self) -> Option<Coord> { self.previous_turns.last().map(|m| m.sub_board) } pub fn get_valid_boards(&self) -> Vec<Coord> { let next_board = self.get_next_board(); if next_board.is_some() { let next_board = next_board.unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "socialgorithm/ultimate-ttt-rust", "path": "/src/game_engine/large_board.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: socialgorithm/ultimate-ttt-rust path: /src/game_engine/large_board.rs use super::enums::{BoardState, PlayerState}; use super::sub_board::SubBoard; use super::types::{Coord, Move}; const SIZE: usize = 3; #[derive(Clone, Debug)] pub struct LargeBoard { board: [[SubBoard<PlayerState>; 3]; 3],...
code_fim
hard
{ "lang": "rust", "repo": "socialgorithm/ultimate-ttt-rust", "path": "/src/game_engine/large_board.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn state_board(&self) -> &SubBoard<BoardState> { &self.state_board } pub fn board(&self) -> &[[SubBoard<PlayerState>; 3]; 3] { &self.board } pub fn move_count(&self) -> usize { self.move_count } pub fn is_winner(&self) -> Option<BoardState> { ...
code_fim
hard
{ "lang": "rust", "repo": "socialgorithm/ultimate-ttt-rust", "path": "/src/game_engine/large_board.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for l in input.lines() { let line = l.unwrap(); let caps = pattern.captures_iter(&line).next().unwrap(); let dependency = caps[1].chars().next().unwrap(); let dependent = caps[2].chars().next().unwrap(); graph.steps.insert(dependency); graph.steps.inser...
code_fim
hard
{ "lang": "rust", "repo": "zeddidragon/Advent-of-Code-2018", "path": "/src/day07.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut min = 100; for (_, duration) in tasks.iter() { if *duration < min { min = *duration; } } time += min; tasks.retain(|(step, duration)| { if *duration > min { true } else { ...
code_fim
hard
{ "lang": "rust", "repo": "zeddidragon/Advent-of-Code-2018", "path": "/src/day07.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zeddidragon/Advent-of-Code-2018 path: /src/day07.rs extern crate regex; use self::regex::{Regex}; use std::io::{BufReader, BufRead}; use std::fs::File; use std::collections::{HashMap, HashSet}; type Deps = HashMap<char, String>; struct Graph { steps: HashSet<char>, requires: Deps, r...
code_fim
hard
{ "lang": "rust", "repo": "zeddidragon/Advent-of-Code-2018", "path": "/src/day07.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pythoneer/examples path: /protobuf/src/main.rs extern crate actix; extern crate actix_web; extern crate bytes; extern crate futures; #[macro_use] extern crate failure; extern crate env_logger; extern crate prost; #[macro_use] extern crate prost_derive; use actix_web::{ http, middleware, ser...
code_fim
medium
{ "lang": "rust", "repo": "pythoneer/examples", "path": "/protobuf/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ::std::env::set_var("RUST_LOG", "actix_web=info"); env_logger::init(); let sys = actix::System::new("protobuf-example"); server::new(|| { App::new() .middleware(middleware::Logger::default()) .resource("/", |r| r.method(http::Method::POST).f(index)) })....
code_fim
hard
{ "lang": "rust", "repo": "pythoneer/examples", "path": "/protobuf/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakubclark/aoc-2020 path: /day01/src/main.rs use std::collections::HashSet; fn part1(nums: &HashSet<u64>) -> u64 { for n in nums.iter() { for m in nums.iter() { if n + m == 2020 { return n * m; } } } unreachable!(); } fn part2...
code_fim
hard
{ "lang": "rust", "repo": "jakubclark/aoc-2020", "path": "/day01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let nums = include_str!("../input.txt") .lines() .into_iter() .map(str::parse) .map(Result::unwrap) .collect(); let part1 = part1(&nums); println!("Part 1 solution: {}", part1); let part2 = part2(&nums); println!("Part 2 solution: {}", part2); }<...
code_fim
hard
{ "lang": "rust", "repo": "jakubclark/aoc-2020", "path": "/day01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let nums = include_str!("../input.txt") .lines() .into_iter() .map(str::parse) .map(Result::unwrap) .collect(); let part1 = part1(&nums); println!("Part 1 solution: {}", part1); let part2 = part2(&nums); println!("Part 2 solution: {}"...
code_fim
hard
{ "lang": "rust", "repo": "jakubclark/aoc-2020", "path": "/day01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vinimin/fluvio path: /src/metadata/src/auth_token/status.rs //! //! # Auth Token Status //! //! Auth Token Status metadata information cached locally. //! use kf_protocol::derive::{Decode, Encode}; use k8_metadata::auth_token::AuthTokenStatus as K8AuthTokenStatus; use k8_metadata::auth_token::T...
code_fim
hard
{ "lang": "rust", "repo": "vinimin/fluvio", "path": "/src/metadata/src/auth_token/status.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> AuthTokenStatus { resolution: TokenResolution::default(), reason: "".to_owned(), } } } impl ::std::default::Default for TokenResolution { fn default() -> Self { TokenResolution::Init } } // ----------------------------------- // Implementation...
code_fim
hard
{ "lang": "rust", "repo": "vinimin/fluvio", "path": "/src/metadata/src/auth_token/status.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> *self == Self::ZERO } } impl NumCast for bf16 { #[inline] fn from<T: ToPrimitive>(n: T) -> Option<Self> { n.to_f32().map(Self::from_f32) } } impl num_traits::float::FloatCore for bf16 { #[inline] fn infinity() -> Self { Self::INFINITY } #[inline] ...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/half/src/num_traits.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self::MIN } #[inline] fn min_positive_value() -> Self { Self::MIN_POSITIVE } #[inline] fn epsilon() -> Self { Self::EPSILON } #[inline] fn max_value() -> Self { Self::MAX } #[inline] fn is_nan(self) -> bool { self....
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/half/src/num_traits.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: /vendor/half/src/num_traits.rs ().map(Self::from_f32) } #[inline] fn from_i8(n: i8) -> Option<Self> { n.to_f32().map(Self::from_f32) } #[inline] fn from_u8(n: u8) -> Option<Self> { n.to_f32().map(Self::from_f32) } #[...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/half/src/num_traits.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn parse_args(app: App) { let matches = app.clone().get_matches(); match matches.subcommand() { Some(("id", id_matches)) => { if id_matches.is_present("movie") { if let Some(ref movie_id) = id_matches.value_of("movie") { movie_by_id(movi...
code_fim
hard
{ "lang": "rust", "repo": "Mohammadreza99A/mdb-rs", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Mohammadreza99A/mdb-rs path: /src/main.rs use clap::{App, AppSettings, Arg}; use tmdb_client::TmdbClient; pub mod models; pub mod tmdb_client; fn main() { parse_args(cli_args()); } pub fn cli_args() -> App<'static> { let app = App::new("mdb") .subcommand( App::new...
code_fim
hard
{ "lang": "rust", "repo": "Mohammadreza99A/mdb-rs", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn wait(&self, context: &'static str) -> Result<()> { if let Some(handle) = self.take() { if handle.thread().id() != thread::current().id() { handle.join().expect(context)?; } } Ok(()) } }<|fim_prefix|>// repo: obayemi/lapi...
code_fim
medium
{ "lang": "rust", "repo": "obayemi/lapin", "path": "/src/thread.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: obayemi/lapin path: /src/thread.rs use crate::Result; use parking_lot::Mutex; use std::{sync::Arc, thread}; pub type JoinHandle = thread::JoinHandle<Result<()>>; <|fim_suffix|> Self(Arc::new(Mutex::new(None))) } } impl ThreadHandle { pub(crate) fn register(&self, handle: JoinHa...
code_fim
medium
{ "lang": "rust", "repo": "obayemi/lapin", "path": "/src/thread.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/lens-rs path: /lens-rs/src/traits.rs /** * A trait representing the optics describes how to construct a single value. * ## Example * ``` * use lens_rs::*; * let optic = optics!(Ok.Err.Some); * let nested: Result<Result<(), _>, ()> = optic.review((1,2,3)); * assert_eq!(nested, Ok(Err(Some...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/lens-rs", "path": "/lens-rs/src/traits.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} /** A trait representing the optics allows you to access the field. A `Lens` can access the substructure must exist. ## Example ``` let mut x = (1, (2, (3, 4))); *optics!(_1._1._1).view_mut(&mut x) *= 2; assert_eq!(optics!(_1._1._1).view(x), 8); ``` */ pub trait LensRef<T>: PrismRef<T> { fn view_re...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/lens-rs", "path": "/lens-rs/src/traits.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cirho/ci path: /src/lib.rs #[macro_use] extern crate structopt; #[macro_use] extern crate failure; #[macro_use] extern crate serde_derive; extern crate chrono; extern crate itertools; extern crate keyring; extern crate rpassword; extern crate serde; extern crate serde_json; extern crate tempfile...
code_fim
medium
{ "lang": "rust", "repo": "cirho/ci", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use cli::{Args, Command}; pub use commands::build::Codegen; pub use error::*; pub use std::{borrow::Borrow, ops::DerefMut}; pub use structopt::StructOpt; pub use ui::Ui; pub use util::connect;<|fim_prefix|>// repo: cirho/ci path: /src/lib.rs #[macro_use] extern crate structopt; #[macro_use] extern cr...
code_fim
medium
{ "lang": "rust", "repo": "cirho/ci", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Chronophylos/AMRAAM path: /src/commands/generate.rs use crate::commands::prelude::*; use amraam::{ config::{BasicConfig, Profile, ServerConfig}, tools::{chmod, chown}, util::escalate_if_needed, }; use console::{style, Term}; use dialoguer::{Editor, Input}; use std::{fs::create_dir_al...
code_fim
hard
{ "lang": "rust", "repo": "Chronophylos/AMRAAM", "path": "/src/commands/generate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !args.is_present("default") { input_config!(stdout, config.max_msg_send, u16, "Maximum number of packets (aggregate messages) that can be sent in one simulation cycle (`frame`). Increasing this value can decrease lag on high upload bandwidth servers"); input_config!(stdout, config....
code_fim
hard
{ "lang": "rust", "repo": "Chronophylos/AMRAAM", "path": "/src/commands/generate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 19h/kohonen path: /src/ui/layer_view.rs //! Viewer for SOMs as heatmaps. use crate::calc::nn::nearest_neighbor_xyf; use crate::data::DataFrame; use crate::map::som::Som; use easy_graph::color::style::text_anchor::{HPos, Pos, VPos}; use easy_graph::color::style::{ IntoFont, Palette, Palette9...
code_fim
hard
{ "lang": "rust", "repo": "19h/kohonen", "path": "/src/ui/layer_view.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.layout_columns.is_none() { let (cols, scale) = Self::calc_layout_columns(width, height, som_rows, som_cols, 1, heading, legend); self.layout_columns = Some(cols); self.scale = Some(scale); } let scale = self.scale.unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "19h/kohonen", "path": "/src/ui/layer_view.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let color_map = LinearColorMap::new(&[&RGBColor(160, 0, 150), &RED, &YELLOW, &GREEN, &CYAN]); let names = &self.names; let test_style = TextStyle::from(("sans-serif", 14).into_font()).pos(Pos::new(HPos::Left, VPos::Bottom)); self.window.draw(|b| { ...
code_fim
hard
{ "lang": "rust", "repo": "19h/kohonen", "path": "/src/ui/layer_view.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut bean = Bean::new("Assets:Test"); let mut transaction = MockTransanction::default(); transaction.date = "2020-04-01"; transaction.payee = "SomeShop"; transaction.narration = "some notes"; bean.add(transaction); let rules = r#" [payee] "SomeSho...
code_fim
hard
{ "lang": "rust", "repo": "hulufei/bean-importer", "path": "/src/lib/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hulufei/bean-importer path: /src/lib/mod.rs mod rules; use self::rules::Rules; use anyhow; use fehler::throws; type Error = anyhow::Error; #[derive(Debug, PartialEq, Clone)] pub enum Flow<'a> { Income, Expense, Unknown(&'a str), } impl Flow<'_> { pub fn is_unknown(&self) -> b...
code_fim
hard
{ "lang": "rust", "repo": "hulufei/bean-importer", "path": "/src/lib/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[throws] pub fn output(&self, edit: bool) -> String { let mut rules = Rules::from_file()?; if edit { rules.merge_with_edit(&self.transactions)?; } else { rules.merge_and_save(&self.transactions)?; } self.output_with_rules(rules)? ...
code_fim
hard
{ "lang": "rust", "repo": "hulufei/bean-importer", "path": "/src/lib/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhouzyue/cs140e path: /os/std/src/sys/redox/os.rs // Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://w...
code_fim
hard
{ "lang": "rust", "repo": "zhouzyue/cs140e", "path": "/os/std/src/sys/redox/os.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Env { iter: vec::IntoIter<(OsString, OsString)>, _dont_send_or_sync_me: PhantomData<*mut ()>, } impl Iterator for Env { type Item = (OsString, OsString); fn next(&mut self) -> Option<(OsString, OsString)> { self.iter.next() } fn size_hint(&self) -> (usize, Option<usize>) { ...
code_fim
hard
{ "lang": "rust", "repo": "zhouzyue/cs140e", "path": "/os/std/src/sys/redox/os.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(err, exports_for_import_set(j).unwrap_err()); } #[test] fn exclude_filter() { let j = "(:exclude [lib test] if)"; let exports = exports_for_import_set(j).unwrap(); assert_exports_prim(&exports, "quote", Prim::Quote); assert!(!exports.contain...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/compiler/hir/import/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let j = "(:rename [lib test] {quote new-quote, if new-if})"; let exports = exports_for_import_set(j).unwrap(); assert_exports_prim(&exports, "new-quote", Prim::Quote); assert_exports_prim(&exports, "new-if", Prim::If); let j = "(:rename [lib test] {ifz new-ifz})";...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/compiler/hir/import/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: etaoins/arret path: /compiler/hir/import/mod.rs mod filter; mod parse; use std::collections::HashMap; use arret_syntax::datum::Datum; use arret_syntax::span::Span; use crate::hir::error::Error; use crate::hir::loader::ModuleName; pub use filter::filter_imported_exports; pub use parse::{parse...
code_fim
hard
{ "lang": "rust", "repo": "etaoins/arret", "path": "/compiler/hir/import/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn reader(&self) -> CoreReader<D,T> { let tree = self.tree.reader(); CoreReader { trackers: Arc::clone(&self.trackers), main_tracker: Arc::clone(&self.main_tracker), tree, } } } pub struct CoreReader<D: PointCloud, T: Send + 'static>...
code_fim
hard
{ "lang": "rust", "repo": "radhakrishnang/goko", "path": "/serve_goko/src/core/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct CoreReader<D: PointCloud, T: Send + 'static> { pub(crate) tree: CoverTreeReader<D>, pub(crate) trackers: Arc<RwLock<HashMap<String,InternalServiceOperator<TrackingRequest<T>, TrackingResponse>>>>, pub(crate) main_tracker: Arc<InternalServiceOperator<TrackingRequest<T>, TrackingRespo...
code_fim
hard
{ "lang": "rust", "repo": "radhakrishnang/goko", "path": "/serve_goko/src/core/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: radhakrishnang/goko path: /serve_goko/src/core/mod.rs use pointcloud::PointCloud; use goko::{CoverTreeReader,CoverTreeWriter}; use std::sync::Arc; use tokio::sync::RwLock; use std::collections::HashMap; use std::ops::Deref; pub(crate) mod internal_service; use internal_service::InternalServiceO...
code_fim
hard
{ "lang": "rust", "repo": "radhakrishnang/goko", "path": "/serve_goko/src/core/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>developer.mozilla.org/en-US/docs/Web/API/SVGPointList/removeItem)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `SvgPoint`, `SvgPointList`*"] pub fn remove_item(this: &SvgPointList, index: u32) -> Result<SvgPoint, JsValue>; #[cfg(feature = "SvgPoin...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_SvgPointList.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_SvgPointList.rs #![allow(unused_imports)] #![allow(clippy::all)] use super::*; use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { # [wasm_bindgen (extends = :: js_sys :: Object , js_name = SVGPointList , typescript_type = "...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_SvgPointList.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blakesmith/tokio path: /tokio-trace/tests/macros.rs #[macro_use] extern crate tokio_trace; // Tests that macros work across various invocation syntax. // // These are quite repetitive, and _could_ be generated by a macro. However, // they're compile-time tests, so I want to get line numbers etc ...
code_fim
hard
{ "lang": "rust", "repo": "blakesmith/tokio", "path": "/tokio-trace/tests/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> trace!(foo = 3, bar = 2, baz = false); trace!(foo = 3, bar = 3,); trace!("foo"); trace!("foo: {}", 3); trace!({ foo = 3, bar = 80 }, "baz"); trace!({ foo = 2, bar = 79 }, "baz {:?}", true); trace!({ foo = 2, bar = 79 }, "baz {:?}, {quux}", true, quux = false); trace!({ foo ...
code_fim
hard
{ "lang": "rust", "repo": "blakesmith/tokio", "path": "/tokio-trace/tests/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alecmocatta/socketstat path: /src/mac.rs #![allow(non_camel_case_types, trivial_casts, missing_copy_implementations, clippy::shadow_unrelated)] use nix::libc; use std::{ convert::{TryFrom, TryInto}, fmt, mem }; #[derive(Clone, Debug)] pub struct SocketStat { unreceived: usize, unsent: usize...
code_fim
hard
{ "lang": "rust", "repo": "alecmocatta/socketstat", "path": "/src/mac.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" { fn proc_pidfdinfo( pid: int, fd: int, flavor: int, buffer: *mut libc::c_void, buffersize: int, ) -> int; } const PROC_PIDFDSOCKETINFO: int = 3; const TSI_T_NTIMERS: usize = 4; const SOCKINFO_TCP: int = 2; #[derive(Copy, Clone)] #[repr(C)] struct socket_fdinfo { pfi: proc_fileinfo, psi...
code_fim
hard
{ "lang": "rust", "repo": "alecmocatta/socketstat", "path": "/src/mac.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let input = std::fs::read_to_string("day5/input.txt").expect("unable to read input file"); let input = input.trim(); println!("part1: {}", part1(input)); println!("part2: {}", part2(input)); } #[cfg(test)] mod tests { use super::*; #[test] fn test_part1() { assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "n8henrie/advent2018-rust", "path": "/day5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: n8henrie/advent2018-rust path: /day5/src/main.rs // For example: // // In aA, a and A react, leaving nothing behind. // In abBA, bB destroys itself, leaving aA. As above, this then destroys itself, leaving nothing. // In abAB, no two adjacent units are of the same type, and so nothin...
code_fim
hard
{ "lang": "rust", "repo": "n8henrie/advent2018-rust", "path": "/day5/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let input = std::fs::read_to_string("day5/input.txt").expect("unable to read input file"); let input = input.trim(); println!("part1: {}", part1(input)); println!("part2: {}", part2(input)); } #[cfg(test)] mod tests { use super::*; #[test] fn test_part1() { ...
code_fim
hard
{ "lang": "rust", "repo": "n8henrie/advent2018-rust", "path": "/day5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = aoc_2021_5::calculate_overlapping_points_for_all_lines(&content).unwrap(); println!("Part two: {}", result); }<|fim_prefix|>// repo: tillrohrmann/rust-challenges path: /aoc_2021_5/src/main.rs fn main() { let content = aoc_common::read_raw_file_content("input.txt").unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "tillrohrmann/rust-challenges", "path": "/aoc_2021_5/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tillrohrmann/rust-challenges path: /aoc_2021_5/src/main.rs fn main() { let content = aoc_common::read_raw_file_content("input.txt").unwrap(); solve_part_one(&content); solve_part_two(&content); } fn solve_part_one(content: &Vec<String>) { <|fim_suffix|> let result = aoc_2021_5::...
code_fim
medium
{ "lang": "rust", "repo": "tillrohrmann/rust-challenges", "path": "/aoc_2021_5/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sougiovn/consolidAcao path: /src-tauri/src/brokerage_note.rs use tauri::InvokeError; use crate::brokerage_note::types::{Brokerage, BrokerageNote, BrokerageOrder}; use crate::commons::page::{PageRequest, PageResponse}; use crate::database; mod types; mod db; #[tauri::command(async)] pub(crate)...
code_fim
hard
{ "lang": "rust", "repo": "sougiovn/consolidAcao", "path": "/src-tauri/src/brokerage_note.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut connection = database::get_connection()?; let transaction = connection.transaction() .map_err(|error| InvokeError::from(format!("{}", error)))?; db::update_brokerage(&transaction, &brokerage_note.brokerage)?; db::delete_brokerage_orders(&transaction, &brokerage_note.brok...
code_fim
hard
{ "lang": "rust", "repo": "sougiovn/consolidAcao", "path": "/src-tauri/src/brokerage_note.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[tauri::command(async)] pub(crate) fn get_brokerage_note(brokerage_id: i64) -> Result<BrokerageNote, InvokeError> { let connection = database::get_connection()?; let brokerage = db::select_brokerage_by_id(&connection, &brokerage_id)?; let brokerage_orders = db::select_brokerage_orders_by_br...
code_fim
hard
{ "lang": "rust", "repo": "sougiovn/consolidAcao", "path": "/src-tauri/src/brokerage_note.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AuroransSolis/aoc-2019 path: /day-7/src/main.rs extern crate intcode_interpreter; use intcode_interpreter::Program; use std::io::{stdin, Read}; fn main() { let mut memory = String::new(); stdin().lock().read_to_string(&mut memory).unwrap(); let memory = memory.trim(); let memor...
code_fim
hard
{ "lang": "rust", "repo": "AuroransSolis/aoc-2019", "path": "/day-7/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if set.len() == 0 { return false; } let mut i = set.len() - 1; while i > 0 && set[i - 1] >= set[i] { i -= 1; } if i == 0 { return false; } let mut j = set.len() - 1; while set[j] <= set[i - 1] { j -= 1; } set.swap(i - 1, j); s...
code_fim
hard
{ "lang": "rust", "repo": "AuroransSolis/aoc-2019", "path": "/day-7/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spacejam/sled path: /src/pagecache/iterator.rs Map, io}; use super::{ pread_exact_or_eof, read_message, read_segment_header, BasedBuf, DiskPtr, LogKind, LogOffset, LogRead, Lsn, SegmentHeader, SegmentNumber, MAX_MSG_HEADER_LEN, SEG_HEADER_LEN, }; use crate::*; #[derive(Debug)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/sled", "path": "/src/pagecache/iterator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.cur_lsn = Some(segment_header.lsn + SEG_HEADER_LEN as Lsn); self.segment_base = Some(BasedBuf { buf, offset }); // NB this should only happen after we've successfully read // the header, because we want to zero the segment if we // fail to read that, and we u...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/sled", "path": "/src/pagecache/iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // -1..(2 * segment_size) - 1 => 0 // otherwise the floor of the buffer let lowest_lsn_in_tail: Lsn = std::cmp::max(0, (max_header_stable_lsn / segment_size) * segment_size); let mut expected_present = lowest_lsn_in_tail; let mut missing_item_in_tail = None; let logical_...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/sled", "path": "/src/pagecache/iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitcare-io/anton path: /src/application/command/mod.rs pub mod pull_request_assign_command; pub mod pull_req<|fim_suffix|>d; pub mod pull_request_close_handler; pub mod pull_request_open_command; pub mod pull_request_open_handler;<|fim_middle|>uest_assign_handler; pub mod pull_request_close_comm...
code_fim
easy
{ "lang": "rust", "repo": "gitcare-io/anton", "path": "/src/application/command/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>quest_open_command; pub mod pull_request_open_handler;<|fim_prefix|>// repo: gitcare-io/anton path: /src/application/command/mod.rs pub mod pull_request_assign_command; pub mod pull_req<|fim_middle|>uest_assign_handler; pub mod pull_request_close_command; pub mod pull_request_close_handler; pub mod pull_...
code_fim
medium
{ "lang": "rust", "repo": "gitcare-io/anton", "path": "/src/application/command/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>d; pub mod pull_request_close_handler; pub mod pull_request_open_command; pub mod pull_request_open_handler;<|fim_prefix|>// repo: gitcare-io/anton path: /src/application/command/mod.rs pub mod pull_request_assign_command; pub mod pull_req<|fim_middle|>uest_assign_handler; pub mod pull_request_close_comm...
code_fim
easy
{ "lang": "rust", "repo": "gitcare-io/anton", "path": "/src/application/command/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/modules/collections/vec_deque.rs :rotate_right)?; m.associated_function(Protocol::INDEX_GET, VecDeque::get)?; m.associated_function(Protocol::INDEX_SET, VecDeque::set)?; m.associated_function(Protocol::INTO_ITER, VecDeque::__rune_fn__iter)?; m...
code_fim
hard
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/modules/collections/vec_deque.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for a in &self.inner { let Some(b) = b.next() else { return VmResult::Ok(false); }; if !vm_try!(Value::eq_with(a, b, caller)) { return VmResult::Ok(false); } } if b.next().is_some() { retu...
code_fim
hard
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/modules/collections/vec_deque.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.inner.reserve(index); } /// Returns the number of elements in the deque. /// /// # Examples /// /// ```rune /// use std::collections::VecDeque; /// /// let deque = VecDeque::new(); /// assert_eq!(deque.len(), 0); /// deque.push_back(1); /// ass...
code_fim
hard
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/modules/collections/vec_deque.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>. fn get_paths(s: state::state) -> (fn @() -> option<(state::state, path::path)>); }<|fim_prefix|>// repo: emarhavilicfp/icfp path: /path_find.rs trait path_find { // Should always be the s<|fim_middle|>ame state. Needs knowledge of region ptrs to fix
code_fim
easy
{ "lang": "rust", "repo": "emarhavilicfp/icfp", "path": "/path_find.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emarhavilicfp/icfp path: /path_find.rs trait path_find { // Should always be the s<|fim_suffix|>. fn get_paths(s: state::state) -> (fn @() -> option<(state::state, path::path)>); }<|fim_middle|>ame state. Needs knowledge of region ptrs to fix
code_fim
easy
{ "lang": "rust", "repo": "emarhavilicfp/icfp", "path": "/path_find.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> 0x0a => { bootloader = buffer.read_i32::<LittleEndian>()?; } 0x04 => { firmware = buffer.read_i32::<LittleEndian>()?; } 0x05 => { radio = buffer.read_i32::<LittleEndian>()?; } _ => { buffer.seek(SeekFrom::Current(4))?; } } } Ok(Build { revi...
code_fim
hard
{ "lang": "rust", "repo": "luxtorpeda-dev/steamy", "path": "/src/details.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Copy, PartialEq, Debug)] pub struct Receiver { pub firmware: SystemTime, pub serial: [u8; 10], } impl Receiver { pub fn parse<R: Read + Seek>(mut buffer: R) -> Res<Receiver> { let firmware = buffer.read_i32::<BigEndian>()?; buffer.seek(SeekFrom::Current(10))?; let mut serial =...
code_fim
hard
{ "lang": "rust", "repo": "luxtorpeda-dev/steamy", "path": "/src/details.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luxtorpeda-dev/steamy path: /src/details.rs use std::io::{Read, Seek, SeekFrom}; use std::time::{UNIX_EPOCH, Duration, SystemTime}; use byteorder::{ReadBytesExt, LittleEndian, BigEndian}; use {Result as Res}; #[derive(Clone, Copy, PartialEq, Debug)] pub struct Details { pub build: Build, p...
code_fim
hard
{ "lang": "rust", "repo": "luxtorpeda-dev/steamy", "path": "/src/details.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..learnings.len(){ toErr += learnings[i].error; } error = toErr / learnings.len() as f64; for _i in 0..1{ for i in 0..cstart.neurones.len(){ let mut val = 2.; cstart.neurones[i].value = val; ...
code_fim
hard
{ "lang": "rust", "repo": "tarnauld/lib-linear-learning", "path": "/src/perceptron/perceptron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tarnauld/lib-linear-learning path: /src/perceptron/perceptron.rs use perceptron::couche::*; use perceptron::neurone::*; use perceptron::learning::*; use rand::{Rng}; use rand; pub fn perceptron(neurone_nb : i32, couche_nb: i32, neurones_output: i32){ let mut cstart = Couche::new(); let...
code_fim
hard
{ "lang": "rust", "repo": "tarnauld/lib-linear-learning", "path": "/src/perceptron/perceptron.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /*for i in 0..cend.neurones.len(){ let mut pot = 0.; for j in 0..cinter.neurones.len(){ pot += cinter.neurones[i].sigmoide * cinter.neurones[j].weights[i] } cend.neurones[i].potential = pot; ce...
code_fim
hard
{ "lang": "rust", "repo": "tarnauld/lib-linear-learning", "path": "/src/perceptron/perceptron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use std::io::Cursor; use varuint::*; use std::collections::*; pub fn vb_encode(v:HashSet<u32>) -> std::io::Cursor<std::vec::Vec<u8>> { let mut v:Vec<&u32> = v.iter().collect(); let mut cursor = Cursor::new(vec![]); v.sort(); cursor.write_varint(v[0].clone()).unwrap(); for i in 1..v.l...
code_fim
medium
{ "lang": "rust", "repo": "b-voilov/info_retrieval", "path": "/lib/src/main/collections/ondisk_index/vec_utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }