text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let ws = WebSocket::new(&format!("ws://{}/ws",url)); match ws{ Ok(ws)=>{ let wss= ws.clone(); let updatecallback = self.updatecallback.clone(); let onopen_callback = Closure::wrap(B...
code_fim
hard
{ "lang": "rust", "repo": "deep-gaurav/dcodefront", "path": "/crate/src/socket_agent.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deep-gaurav/dcodefront path: /crate/src/socket_agent.rs use std::rc::Rc; use std::cell::RefCell; use web_sys::MessageEvent; use web_sys::WebSocket; use yew::agent::HandlerId; use yew::agent::Context; use yew::agent::Agent; use yew::worker::AgentLink; use yew::prelude::*; use wasm_bindgen::prelud...
code_fim
hard
{ "lang": "rust", "repo": "deep-gaurav/dcodefront", "path": "/crate/src/socket_agent.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>2, to: i32) -> String { let mut lyrics = String::new(); let mut n = from; while n >= to { if n != from { lyrics.push('\n'); } lyrics.push_str(&verse(n)); n -= 1; } lyrics }<|fim_prefix|>// repo: peap/exercism-rust path: /beer-song/src/lib.rs...
code_fim
hard
{ "lang": "rust", "repo": "peap/exercism-rust", "path": "/beer-song/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peap/exercism-rust path: /beer-song/src/lib.rs pub fn verse(num: i32) -> String { if num > 1 { let plural = if num == 2 { "bottle" } else { "bottles" }; format!("{} bottles of beer on the wall, {} bottles of beer.\n\ Take one down and pass it arou<|fim_suffix|...
code_fim
hard
{ "lang": "rust", "repo": "peap/exercism-rust", "path": "/beer-song/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: second-state/rust_native_storage_library path: /legacy_code/src/lib.rs extern crate libc; use cmake; use libc::c_char; use rocksdb::{Options, DB}; use std::ffi::{CStr, CString}; #[no_mangle] pub extern "C" fn store_data(_key: *const c_char, _value: *const c_char) { println!("Storing data, ple...
code_fim
medium
{ "lang": "rust", "repo": "second-state/rust_native_storage_library", "path": "/legacy_code/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> CStr::from_ptr(_key) }; let _key_as_string = c_str_key.to_str().unwrap(); let path = "/media/nvme/ssvm_database"; //println!("Database path: {:?}", path); let db = DB::open_default(path).unwrap(); //println!("Database instance: {:?}", db); let mut opts = Options::defaul...
code_fim
hard
{ "lang": "rust", "repo": "second-state/rust_native_storage_library", "path": "/legacy_code/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> 'events: loop { let end = Instant::now(); let delta = end.duration_since(start); let delta_ms = delta.as_secs() as f32 * 1000_f32 + (delta.subsec_nanos() as f32)/1000000 as f32; start = Instant::now(); // println!("{:?} ms", delta_ms); //update...
code_fim
hard
{ "lang": "rust", "repo": "pythoneer/tachyonic", "path": "/examples/mock.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pythoneer/tachyonic path: /examples/mock.rs #![feature(step_by)] extern crate orbclient; extern crate tachyonic; extern crate nalgebra as na; use orbclient::Color; use tachyonic::{ RenderContext, Mesh, Texture, Vertex }; use na::{ Vector3, Point3, Point4, Point2, Matrix4, Perspective3, Perspect...
code_fim
hard
{ "lang": "rust", "repo": "pythoneer/tachyonic", "path": "/examples/mock.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone)] pub enum Pattern<T> { Wildcard, Terminal(T), Tuple(Vec<Pattern<T>>), } impl<T> Pattern<T> { /// Mutates all terminals of the pattern. pub fn apply<F, E>(&mut self, function: &mut F) -> Result<(), E> where F: FnMut(&mut T) -> Result<(), E> { match self { Pattern::Wildca...
code_fim
hard
{ "lang": "rust", "repo": "Techno-coder/lexica", "path": "/src/node/variable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Techno-coder/lexica path: /src/node/variable.rs use std::fmt; use std::sync::Arc; use crate::declaration::StructurePath; use crate::node::ExpressionKey; use crate::span::Spanned; pub type VariablePattern = Pattern<Spanned<Variable>>; pub type BindingPattern = Pattern<Spanned<BindingVariable>>;...
code_fim
hard
{ "lang": "rust", "repo": "Techno-coder/lexica", "path": "/src/node/variable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lunacookies/syntax-rust path: /src/grammar/stmt.rs use crate::grammar::parse_expr; use crate::Parser; use dialect::HighlightGroup; pub(crate) fn parse_stmt(p: &mut Parser) { match p.peek() { Some(crate::Token { kind: crate::TokenKind::Let, .. }) => { ...
code_fim
hard
{ "lang": "rust", "repo": "lunacookies/syntax-rust", "path": "/src/grammar/stmt.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( parser.output, vec![ HighlightedSpan { range: 0..3, group: HighlightGroup::OtherKeyword, }, HighlightedSpan { range: 4..5, group: High...
code_fim
hard
{ "lang": "rust", "repo": "lunacookies/syntax-rust", "path": "/src/grammar/stmt.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbnair/tezedge path: /tezos/interop/tests/test_bytes_roundtrips.rs onfiguration { log_enabled: is_ocaml_log_enabled(), no_of_ffi_calls_treshold_for_gc: no_of_ffi_calls_treshold_for_gc(), } ).unwrap().unwrap(); } #[test] #[serial] fn test_chain_id_roundtrip_on...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/tezedge", "path": "/tezos/interop/tests/test_bytes_roundtrips.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbnair/tezedge path: /tezos/interop/tests/test_bytes_roundtrips.rs old_for_gc: no_of_ffi_calls_treshold_for_gc(), } ).unwrap().unwrap(); } #[test] #[serial] fn test_chain_id_roundtrip_one() { init_test_runtime(); assert!(test_chain_id_roundtrip(1).is_ok()) } fn test_chain_...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/tezedge", "path": "/tezos/interop/tests/test_bytes_roundtrips.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // check operations assert_eq_operations(List::from(result.get(4).unwrap()), 5, 1); () }) } #[test] #[serial] fn test_context_callback() { init_test_runtime(); let expected_count = 10000; let expected_context_hash = hex::decode(CONTEXT_HASH).unwrap(); let exp...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/tezedge", "path": "/tezos/interop/tests/test_bytes_roundtrips.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jsvennevid/adventofcode path: /2016/01/puzzle1/src/main.rs extern crate regex; use regex::Regex; use std::fs::File; use std::path::Path; use std::io::BufRead; use std::io::BufReader; use std::io; static LEFT : i32 = -1; static RIGHT : i32 = 1; struct Direction { dx: i32, dz: i32 } <|...
code_fim
hard
{ "lang": "rust", "repo": "jsvennevid/adventofcode", "path": "/2016/01/puzzle1/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } fn main() { let ops = load("../input.txt").unwrap_or(Vec::new()); let mut state = State{x: 0, z: 0,dir: 0}; for op in ops { state = state.turn(op.turn).walk(op.dist); } println!("{}", state.x.abs() + state.z.abs()); }<|fim_prefix|>// repo: jsvennevid/adventofcode p...
code_fim
hard
{ "lang": "rust", "repo": "jsvennevid/adventofcode", "path": "/2016/01/puzzle1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nagyistoce/collaborative-fiction path: /src/oauth.rs //! OAuth2 authentication providers. extern crate router; extern crate persistent; use std::collections::HashSet; use std::sync::{Mutex, Arc}; use iron::prelude::*; use iron::status; use iron::Url as IronUrl; use iron::Handler; use iron::mo...
code_fim
hard
{ "lang": "rust", "repo": "nagyistoce/collaborative-fiction", "path": "/src/oauth.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mutex = self.shared_mutex(req); let mut shared = mutex.lock().unwrap(); let state = shared.generate_state(); let mut u = o.request_uri.clone(); u.query = Some(format!( "client_id={}&redirect_uri={}&scope={}&state={}", &o.client_id, self....
code_fim
hard
{ "lang": "rust", "repo": "nagyistoce/collaborative-fiction", "path": "/src/oauth.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: domWalters/neuralnet path: /src/tdata.rs use vektor::Vektor; #[derive(Clone, Debug)] pub struct TData { pub data: Vec<(Vektor, Vektor)>, } impl TData { <|fim_suffix|> pub fn new_from_funct(n: usize, depth: usize, lb: f64, ub: f64, f: Box<Fn(&f64) -> f64>) -> Vec<(Vektor, Vektor)> { ...
code_fim
hard
{ "lang": "rust", "repo": "domWalters/neuralnet", "path": "/src/tdata.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_from_funct(n: usize, depth: usize, lb: f64, ub: f64, f: Box<Fn(&f64) -> f64>) -> Vec<(Vektor, Vektor)> { let mut result = Vec::new(); for _ in 0..n { let mut x = Vektor::new_random_f64(depth, lb, ub); let mut y = x.map(&*f); result.push((x...
code_fim
hard
{ "lang": "rust", "repo": "domWalters/neuralnet", "path": "/src/tdata.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>obe".to_string()) .add_empty_child("closet".to_string()) .add_empty_child("shelves".to_string()) .add_empty_child("clothes".to_string()) .end_child() .add_empty_child("bed".to_string()) .end_child() .build(); let config = { let mut confi...
code_fim
hard
{ "lang": "rust", "repo": "matthiasbeyer/ptree", "path": "/examples/basic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matthiasbeyer/ptree path: /examples/basic.rs extern crate ptree; use ptree::{print_tree_with, Color, PrintConfig, Style, TreeBuilder, print_config::UTF_CHARS_BOLD}; fn main() { let tree = TreeBuilder::new("house".to_string()) .begin_child("living room".to_string()) .add_emp...
code_fim
hard
{ "lang": "rust", "repo": "matthiasbeyer/ptree", "path": "/examples/basic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn str_as_case_unchecked(source: &'a str) -> Self { KebabCase(CaseValue::Joined(source)) } } impl<'a> internals::Case<'a> for KebabCase<'a> { #[inline] fn from_cased_words(words: Vec<Word<'a>>) -> Self { KebabCase(CaseValue::Words(words)) } #[inline]...
code_fim
medium
{ "lang": "rust", "repo": "peterjoel/camel-kebab", "path": "/src/kebab.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peterjoel/camel-kebab path: /src/kebab.rs use crate::internals::{is_lower_case_delimited, self, write_lower_delimited, CaseValue, Word}; use crate::Case; use std::fmt; #[derive(Debug, Clone)] pub struct KebabCase<'a>(pub(crate) CaseValue<'a>); impl<'a> Case<'a> for KebabCase<'a> { #[inline...
code_fim
medium
{ "lang": "rust", "repo": "peterjoel/camel-kebab", "path": "/src/kebab.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> fmt::Display for KebabCase<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match &self.0 { CaseValue::Joined(string) => write!(f, "{}", string), CaseValue::Words(words) => write_lower_delimited(words.iter(), f, '-'), } } } i...
code_fim
hard
{ "lang": "rust", "repo": "peterjoel/camel-kebab", "path": "/src/kebab.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] /// Asynchronous requests for internal actions. pub enum InternalRequest { Timeout(TimeoutRequest), JumpToRound(Height, Round), Shutdown, /// Async request to verify a message in the thread pool. VerifyMessage(Vec<u8>), } #[derive(Debug, PartialEq, Eq)] pub struct Tim...
code_fim
hard
{ "lang": "rust", "repo": "g4m3fr34k/timestamp_app", "path": "/exonum/src/events/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: g4m3fr34k/timestamp_app path: /exonum/src/events/mod.rs // Copyright 2018 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache...
code_fim
hard
{ "lang": "rust", "repo": "g4m3fr34k/timestamp_app", "path": "/exonum/src/events/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Some(self.cmp(other)) } } impl Ord for TimeoutRequest { fn cmp(&self, other: &Self) -> Ordering { (&self.0, &self.1).cmp(&(&other.0, &other.1)).reverse() } } impl Into<Event> for NetworkEvent { fn into(self) -> Event { Event::Network(self) } } impl Into<Event...
code_fim
hard
{ "lang": "rust", "repo": "g4m3fr34k/timestamp_app", "path": "/exonum/src/events/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(super) fn combine_login_uri(url: &str, api_code_data: &ApiCodeRspData, config: &Config) -> String { let ref mut params = HashMap::new(); let ref nonce = api_code_data.nonce().to_string(); let ref timestamp = api_code_data.timestamp().to_string(); params.insert(K_APP_PASSWORD, config.pa...
code_fim
medium
{ "lang": "rust", "repo": "Paulswith/pengcheng_driving", "path": "/src/handler/uri_combine.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Paulswith/pengcheng_driving path: /src/handler/uri_combine.rs /* create at 2019/12/4 by 'itachy' */ use std::collections::HashMap; use crate::convenience::{time::*, tools::*}; use crate::pre_define::const_define::network::param_keys::*; use crate::data_model::{api_code...
code_fim
hard
{ "lang": "rust", "repo": "Paulswith/pengcheng_driving", "path": "/src/handler/uri_combine.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: noonebtw/coral-screenshot path: /src/fb.rs use std::io::{Error, ErrorKind}; use framebuffer::{Framebuffer, FramebufferError}; use image::{DynamicImage, GenericImage, GenericImageView, ImageError, Pixel, Rgb}; use crate::traits::ScreenshotBackend; /// Framebuffer backend. #[derive(Debug)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "noonebtw/coral-screenshot", "path": "/src/fb.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ScreenshotBackend for FrameBufferBackend { fn global_screenshot(&self) -> image::ImageResult<image::DynamicImage> { Ok(DynamicImage::ImageRgb8( self.view(0, 0, self.width(), self.height()).to_image(), )) } fn window_screenshot(&self, _: &str) -> image::ImageRe...
code_fim
hard
{ "lang": "rust", "repo": "noonebtw/coral-screenshot", "path": "/src/fb.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mur6/learning-algorithms path: /Rust/abc164_b/src/main.rs /// # 問題 /// 2020/07/16 /// https://atcoder.jp/contests/abc164/tasks/abc164_b /// /// # 提出 /// https://atcoder.jp/contests/abc164/submissions/18074132 <|fim_suffix|> let mut s = String::new(); std::io::stdin().read_line(&mut s).un...
code_fim
medium
{ "lang": "rust", "repo": "mur6/learning-algorithms", "path": "/Rust/abc164_b/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let s = read(); let numbers: Vec<i32> = s.split_whitespace() .map(|s| s.parse().unwrap()) .collect(); //println!("{:?}", numbers); if let &[a_point, a_offence, b_point, b_offence] = numbers.as_slice() { let j = (b_point as f64 / a_offence as f64).ceil()...
code_fim
medium
{ "lang": "rust", "repo": "mur6/learning-algorithms", "path": "/Rust/abc164_b/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub const SNARK_IN_G6_30_ACRITICAL_1: &str = "]D@W@UGGG?GA_A?__???@?A??@_?@??G@?????A???D???J???o???K_OA????O@?AC????C?W"; pub const SNARK_IN_G6_30_ACRITICAL_2: &str = "]C?G?SGG??G@_AO_g_?CP_??C?@_????[O?C?GAGA????_@G????G???A??_???F?C??O???IG"; pub const SNARK_IN_G6_36_STABLE...
code_fim
hard
{ "lang": "rust", "repo": "jkbstrmen/snark-tool", "path": "/src/tests/test_data.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jkbstrmen/snark-tool path: /src/tests/test_data.rs #[cfg(test)] pub mod test_data { use crate::graph::edge::EdgeConstructor; use crate::graph::graph::{Graph, GraphConstructor}; use crate::graph::undirected::edge::UndirectedEdge; use crate::graph::undirected::simple_graph::graph::...
code_fim
hard
{ "lang": "rust", "repo": "jkbstrmen/snark-tool", "path": "/src/tests/test_data.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub const SNARK_IN_G6_26_CRITICAL_1: &str = "Y?gY@eOGGC?B???@__??D??@??k?????C??@??aG?O_??GHO??G??A__"; pub const SNARK_IN_G6_26_CRITICAL_2: &str = "Y?gY@eOGGC?B????__??D??@??k??O??D??@??aG?O???GH?@O???CA_"; pub const SNARK_IN_G6_26_SCOCRITICAL_1: &str = "Y?HI@eO?????_...
code_fim
hard
{ "lang": "rust", "repo": "jkbstrmen/snark-tool", "path": "/src/tests/test_data.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] #[should_panic] fn test_aggregation_min_should_panic() { let nv = NullVec::new(vec!["a".to_string(), "b".to_string(), "c".to_string()]); let arr = Array::StringArray(nv); arr.min(); }<|fim_prefix|>// repo: sinhrks/rust-nullvec path: /tests/array_aggregation.rs extern crate nullvec; us...
code_fim
hard
{ "lang": "rust", "repo": "sinhrks/rust-nullvec", "path": "/tests/array_aggregation.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sinhrks/rust-nullvec path: /tests/array_aggregation.rs extern crate nullvec; use nullvec::prelude::*; #[test] fn test_aggregation_int64() { let arr = Array::Int64Array(NullVec::new(vec![1, 2, 3])); assert_eq!(arr.sum(), Scalar::i64(6)); assert_eq!(arr.count(), 3); assert_eq!(arr...
code_fim
hard
{ "lang": "rust", "repo": "sinhrks/rust-nullvec", "path": "/tests/array_aggregation.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sclolus/Turbofish path: /rust_kernel/dependencies/ext2/src/lib.rs atch s { // SeekFrom::Start(n) => { // self.curr_offset = n as u64; // } // _ => unimplemented!(), // } // } // } type OffsetDirEntry = u32; type InodeAddr = u64; ty...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/rust_kernel/dependencies/ext2/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sclolus/Turbofish path: /rust_kernel/dependencies/ext2/src/lib.rs dr: u64) -> IoResult<()> { let pointer = self.disk.read_struct(pointer_addr)?; if pointer == Block(0) { panic!("free pointer null"); } else { self.disk.write_struct(pointer_addr, &Bl...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/rust_kernel/dependencies/ext2/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> block_dtr.nbr_free_blocks -= 1; self.disk.write_struct(block_dtr_addr, &block_dtr).ok()?; self.superblock.nbr_free_blocks -= 1; self.disk .write_struct(self.superblock_addr, &self.superblock) .ok()?; ...
code_fim
hard
{ "lang": "rust", "repo": "sclolus/Turbofish", "path": "/rust_kernel/dependencies/ext2/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xpepermint/httlib-rs path: /protos/src/typ.rs use core::convert::TryFrom; /// Provides available wire types supported by proto3. #[derive(Clone, Copy, Debug, PartialEq)] pub enum Typ { /// Represents the wire type `0` which allows for encoding of data formats /// `int32`, `int64`, `uint...
code_fim
hard
{ "lang": "rust", "repo": "xpepermint/httlib-rs", "path": "/protos/src/typ.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn try_from(value: u64) -> Result<Self, Self::Error> { match value { 0 => Ok(Typ::Varint), 1 => Ok(Typ::Bit64), 2 => Ok(Typ::LengthDelimited), 5 => Ok(Typ::Bit32), _ => Ok(Typ::Unknown), } } }<|fim_prefix|>// repo: xpeperm...
code_fim
hard
{ "lang": "rust", "repo": "xpepermint/httlib-rs", "path": "/protos/src/typ.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Represents un unknown wire type. Unknown = -1, } impl TryFrom<u64> for Typ { type Error = std::io::Error; fn try_from(value: u64) -> Result<Self, Self::Error> { match value { 0 => Ok(Typ::Varint), 1 => Ok(Typ::Bit64), 2 => Ok(Typ::LengthDel...
code_fim
hard
{ "lang": "rust", "repo": "xpepermint/httlib-rs", "path": "/protos/src/typ.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_get_model_id_valid() { // Valid scenario: Length == 3 let uuid: u16 = 0x1234; let data = vec![0xAA, 0xBB, 0xCC]; let service_data = ServiceData::new(uuid, data.clone()); let result = FpDecoder::get_model_id_from_service_data(&service_data); ...
code_fim
hard
{ "lang": "rust", "repo": "google/nearby", "path": "/fastpair/rust/demo/rust/src/decoder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: google/nearby path: /fastpair/rust/demo/rust/src/decoder.rs // Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apac...
code_fim
hard
{ "lang": "rust", "repo": "google/nearby", "path": "/fastpair/rust/demo/rust/src/decoder.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Valid scenario: Length == 3 let uuid: u16 = 0x1234; let data = vec![0xAA, 0xBB, 0xCC]; let service_data = ServiceData::new(uuid, data.clone()); let result = FpDecoder::get_model_id_from_service_data(&service_data); assert!(result.is_ok()); assert_...
code_fim
hard
{ "lang": "rust", "repo": "google/nearby", "path": "/fastpair/rust/demo/rust/src/decoder.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let opts = Opts::parse(); let fade_range = opts.fade_range.unwrap_or(0.1); let r_multiplier = opts.r_multiplier.unwrap_or(1.0); let tessellation_resolution = opts.tessellation_resolution.unwrap_or(0.12); let tessellation_error = opts.tessellation_error.unwrap_or(0.2); let bytes =...
code_fim
hard
{ "lang": "rust", "repo": "dvc94ch/moosecad", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dvc94ch/moosecad path: /src/main.rs use anyhow::Error; use clap::Clap; use mesh::{BoundedElement, Element1, SideSet}; use nalgebra as na; use std::path::PathBuf; #[derive(Clap)] struct Opts { #[clap(short = 'i', long = "input")] input: PathBuf, #[clap(short = 'o', long = "output")] ...
code_fim
hard
{ "lang": "rust", "repo": "dvc94ch/moosecad", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let surface = mesh.boundary(); for (name, boundary) in boundaries { println!("adding boundary {}", name); let mut side_set = SideSet::new(); side_set.set_name(name); for (elem, side) in surface.sides() { let mut add = true; for node in mesh.e...
code_fim
hard
{ "lang": "rust", "repo": "dvc94ch/moosecad", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // TODO do i want the combined mvprint et al.? window.mv(rows / 2, (cols - str::len(mesg))/2); window.write(mesg); window.mv(rows - 2, 0); window.write(fmt!("This screen has %u rows and %u columns\n", rows, cols)); window.write("Try resizing your window (if...
code_fim
medium
{ "lang": "rust", "repo": "doy/amulet", "path": "/demos/howto-03-printw.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mesg = "Just a string"; let term = amulet::ll::Terminal(); do term.fullscreen |window| { let (rows, cols) = window.size(); // TODO seems like centering should be easier? //mvprintw(row/2,(col-strlen(mesg))/2,"%s",mesg); //mvprintw(row-2,0,"This screen has ...
code_fim
medium
{ "lang": "rust", "repo": "doy/amulet", "path": "/demos/howto-03-printw.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doy/amulet path: /demos/howto-03-printw.rs /** A simple printw example * * Taken from the ncurses programming howto, section 6.3: * http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/printw.html */ <|fim_suffix|> // TODO do i want the combined mvprint et al.? window.mv(rows / 2,...
code_fim
hard
{ "lang": "rust", "repo": "doy/amulet", "path": "/demos/howto-03-printw.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gurutu/rust_tutorial path: /hello_world/src/sh.rs #![allow(dead_code)] use std::mem; struct Point{ x:f64, y:f64 } <|fim_suffix|>pub fn stack_and_heap(){ let p1=origin(); let p2 = Box::new(origin()); println!("Hello p1 {} bytes",mem::size_of_val(&p1)); println!("Hello p...
code_fim
easy
{ "lang": "rust", "repo": "gurutu/rust_tutorial", "path": "/hello_world/src/sh.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn stack_and_heap(){ let p1=origin(); let p2 = Box::new(origin()); println!("Hello p1 {} bytes",mem::size_of_val(&p1)); println!("Hello p2 {} bytes",mem::size_of_val(&p2)); let p3=*p2; println!("{}",p3.x ); }<|fim_prefix|>// repo: gurutu/rust_tutorial path: /hello_world/src/...
code_fim
easy
{ "lang": "rust", "repo": "gurutu/rust_tutorial", "path": "/hello_world/src/sh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let stmt = Parser::new(&dialect) .try_with_sql(definition) .and_then(|mut p| p.parse_statement()); let definition = match stmt { // SQL Server stores the definition as `CREATE VIEW`, // but we only want the query part in the definition ...
code_fim
medium
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/schema-engine/connectors/sql-schema-connector/src/introspection/datamodel_calculator/context/flavour/sqlserver.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flier/rust-cfile path: /src/lock.rs use std::ops::{Deref, DerefMut}; use foreign_types::ForeignTypeRef; use crate::cfile::CFileRef; /// A locked reference to the `CFile` stream. pub struct FileLock<'a>(&'a mut CFileRef); impl<'a> Drop for FileLock<'a> { fn drop(&mut self) { unsaf...
code_fim
hard
{ "lang": "rust", "repo": "flier/rust-cfile", "path": "/src/lock.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// a non-blocking version of `lock()`; /// /// if the lock cannot be acquired immediately, /// `try_lock()` returns `None` instead of blocking. /// /// # Examples /// ``` /// use std::io::{Read, Write, BufRead, BufReader, Seek, SeekFrom}; /// use cfile::tmpfile; //...
code_fim
hard
{ "lang": "rust", "repo": "flier/rust-cfile", "path": "/src/lock.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn fire(path: &Path, chambers: usize) -> bool { let mut rng = thread_rng(); if rng.gen_range(0, chambers) == 0 { if fs::metadata(path) .expect("failed to read file meta") .is_dir() { std::fs::remove_dir_all(path).expect("failed to delete dir"...
code_fim
hard
{ "lang": "rust", "repo": "jackyzhen/rustian-roulette", "path": "/src/lib.rs", "mode": "spm", "license": "GLWTPL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jackyzhen/rustian-roulette path: /src/lib.rs extern crate rand; use rand::prelude::*; use std::fs; use std::path::{Path, PathBuf}; use std::process::exit; <|fim_suffix|> contents[unlucky].clone() } pub fn fire(path: &Path, chambers: usize) -> bool { let mut rng = thread_rng(); if r...
code_fim
hard
{ "lang": "rust", "repo": "jackyzhen/rustian-roulette", "path": "/src/lib.rs", "mode": "psm", "license": "GLWTPL", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!() } fn serialize_str(self, val: &str) -> Result<Self::Ok, Self::Error> { write_String(&val, &mut self.writer) } fn serialize_bytes(self, value: &[u8]) -> Result<Self::Ok, Self::Error> { self.writer.write(value); Ok(())//TODO handle } ...
code_fim
hard
{ "lang": "rust", "repo": "DarkWeird/mcproto-rs", "path": "/serde-mcproto/src/ser/ser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DarkWeird/mcproto-rs path: /serde-mcproto/src/ser/ser.rs use std::io::prelude::*; use serde::{Serialize, ser, serde_if_integer128}; use std::fmt::Display; use super::write::*; pub struct MCProtoSerializer<W: Write> { pub writer: W } impl<W: Write> MCProtoSerializer<W> { /// Creates a ...
code_fim
hard
{ "lang": "rust", "repo": "DarkWeird/mcproto-rs", "path": "/serde-mcproto/src/ser/ser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unimplemented!() } fn serialize_struct(self, name: &'static str, len: usize) -> Result<Self::SerializeStruct, Self::Error> { Ok(Compound { ser: self }) } fn serialize_struct_variant(self, name: &'static str, variant_index: u32, variant: &'static str, len: usize) -> Result...
code_fim
hard
{ "lang": "rust", "repo": "DarkWeird/mcproto-rs", "path": "/serde-mcproto/src/ser/ser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> position: 0.5, color: Color::new(0xff, 0xff, 0xff, 0x0), }, GradientStop { position: 1., color: Color::new(0xff, 0, 0, 0x0), }, ], }, Point::new(150., 200.), 45., 180.+45., Spread::Rep...
code_fim
medium
{ "lang": "rust", "repo": "jrmuizel/raqote", "path": "/examples/sweep-gradient.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jrmuizel/raqote path: /examples/sweep-gradient.rs fn main() { use raqote::*; let mut dt = DrawTarget::new(400, 400); let mut pb = PathBuilder::new(); pb.rect(0., 0., 400., 400.); let path = pb.finish(); let gradient = Source::new_sweep_grad<|fim_suffix|> 0, 0x0), }, ],...
code_fim
hard
{ "lang": "rust", "repo": "jrmuizel/raqote", "path": "/examples/sweep-gradient.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magurotuna/leetcode-rust path: /src/bin/6.rs struct Solution; impl Solution { pub fn convert(s: String, num_rows: i32) -> String { if num_rows == 1 { return s; } let chars: Vec<_> = s.chars().collect(); let room_in_block = 2 * (num_rows - 1); ...
code_fim
hard
{ "lang": "rust", "repo": "magurotuna/leetcode-rust", "path": "/src/bin/6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for &(arg1, arg2, expected) in test_cases.iter() { assert_eq!( Solution::convert(arg1.to_string(), arg2), expected.to_string() ); } } }<|fim_prefix|>// repo: magurotuna/leetcode-rust path: /src/bin/6.rs struct Solution; impl Sol...
code_fim
hard
{ "lang": "rust", "repo": "magurotuna/leetcode-rust", "path": "/src/bin/6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aurorastation/rust-g path: /src/redis_pubsub.rs use redis::{Client, Commands, RedisError}; use std::cell::RefCell; use std::collections::HashMap; use std::thread; use std::time::Duration; const ERROR_CHANNEL: &str = "RUSTG_REDIS_ERROR_CHANNEL"; thread_local! { static REQUEST_SENDER: RefCel...
code_fim
hard
{ "lang": "rust", "repo": "Aurorastation/rust-g", "path": "/src/redis_pubsub.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Dropping the sender and receiver will cause the other thread to exit REQUEST_SENDER.with(|cell| { cell.replace(None); }); RESPONSE_RECEIVER.with(|cell| { cell.replace(None); }); } // It's lame as hell to use strings as errors, but I don't feel like // making a whole...
code_fim
hard
{ "lang": "rust", "repo": "Aurorastation/rust-g", "path": "/src/redis_pubsub.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn parse(input: String) { let cclone = input.clone(); // cmd_parse collect the cmd in a vec let mut cmd_parse: Vec<&str> = cclone.trim().split(" ").collect(); // split the first cmd off and leave vec of args let ct: CommandTable = if cmd_parse.len() == 1 { ...
code_fim
hard
{ "lang": "rust", "repo": "william20111/wash", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: william20111/wash path: /src/parser.rs use std::process::Command; use std::fs; use std::env; use std::path::Path; use std::io; use std::io::Write; use prompt::Prompt; use commands; #[derive(Debug, Clone)] pub struct CommandTable { cmd: String, args: Option<Vec<String>>, } impl Command...
code_fim
hard
{ "lang": "rust", "repo": "william20111/wash", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eij/rs-convert path: /src/convert/mod.rs use std::path::PathBuf; use std::sync::mpsc::channel; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use walkdir::WalkDir; use threadpool::ThreadPool; use gtk::{ContainerExt, BoxExt, LabelExt, WidgetExt}; use crate::structs::{GLOBAL...
code_fim
hard
{ "lang": "rust", "repo": "eij/rs-convert", "path": "/src/convert/mod.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> for entry in iterator.into_iter().filter_entry(|e| folders::folder_disalloweds(e)).filter_map(|e| e.ok()) { settings.path = entry.path().to_path_buf(); settings.destination = path.join("JPG").join(entry.file_name()); GLOBAL.with(|global| { if let Some((ref c, ref _s, ref _rx)) = *global.bo...
code_fim
hard
{ "lang": "rust", "repo": "eij/rs-convert", "path": "/src/convert/mod.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/wasi-0.9.0+wasi-snapshot-preview1/src/lib_generated.rs TOOPT: Errno = 50; /// No space left on device. pub const ERRNO_NOSPC: Errno = 51; /// Function not supported. pub const ERRNO_NOSYS: Errno = 52; /// The socket is not connected. pub const ERRNO_NOTCONN...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/wasi-0.9.0+wasi-snapshot-preview1/src/lib_generated.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Open a file or directory. /// The returned file descriptor is not guaranteed to be the lowest-numbered /// file descriptor not currently open; it is randomized to prevent /// applications from depending on making assumptions about indexes, since this /// is error-prone in multi-threaded contexts. The ...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/wasi-0.9.0+wasi-snapshot-preview1/src/lib_generated.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/wasi-0.9.0+wasi-snapshot-preview1/src/lib_generated.rs RNO_NOMEM: Errno = 48; /// No message of the desired type. pub const ERRNO_NOMSG: Errno = 49; /// Protocol not available. pub const ERRNO_NOPROTOOPT: Errno = 50; /// No space left on device. pub const E...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/wasi-0.9.0+wasi-snapshot-preview1/src/lib_generated.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("{:?}", color); } fn main() { let shirt_color = ShirtColor::new(Color::Gray).unwrap(); let shoes_color = ShoesColor::new(Color::Blue); let pants_color = PantsColor::new(Color::White); print_shirt_color(shirt_color); print_shoes_color(shoes_color); print_pants_color(p...
code_fim
medium
{ "lang": "rust", "repo": "octoi/rust-activities", "path": "/src/bin/a28.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: octoi/rust-activities path: /src/bin/a28.rs // Topic: New type pattern // // Requirements: // * Display the selected color of shoes, a shirt, and pants // * Create and display at least one of each type of clothes and color // // Notes: // * Create a new type for each clothing item that wraps the...
code_fim
medium
{ "lang": "rust", "repo": "octoi/rust-activities", "path": "/src/bin/a28.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hashmismatch/periphery.rs path: /periphery_devices/ms5611/lib.rs #[macro_use] extern crate periphery_core; extern crate packed_struct; <|fim_suffix|>mod sensor; pub use self::sensor::*;<|fim_middle|>#[macro_use] extern crate packed_struct_codegen;
code_fim
easy
{ "lang": "rust", "repo": "hashmismatch/periphery.rs", "path": "/periphery_devices/ms5611/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod sensor; pub use self::sensor::*;<|fim_prefix|>// repo: hashmismatch/periphery.rs path: /periphery_devices/ms5611/lib.rs #[macro_use] extern crate periphery_core; <|fim_middle|>extern crate packed_struct; #[macro_use] extern crate packed_struct_codegen;
code_fim
medium
{ "lang": "rust", "repo": "hashmismatch/periphery.rs", "path": "/periphery_devices/ms5611/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_all(client: &Client) -> Vec<Asset> { let _client = reqwest::blocking::Client::new(); let mut url = client.get_url(); url.push_str("assets"); let _result: Vec<Asset> = _client.get(&url) .header("APCA-API-KEY-ID", &client.auth.access_key) ...
code_fim
medium
{ "lang": "rust", "repo": "ultimaengineering/alpaca-client", "path": "/src/asset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get(client: &Client, symbol: String) -> Asset { let _client = reqwest::blocking::Client::new(); let mut url = client.get_url(); url.push_str("assets/"); url.push_str(symbol.to_string().as_ref()); let _result: Asset = _client.get(&url) .header(...
code_fim
hard
{ "lang": "rust", "repo": "ultimaengineering/alpaca-client", "path": "/src/asset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ultimaengineering/alpaca-client path: /src/asset.rs use serde::{Serialize, Deserialize}; use crate::client::Client; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Asset { pub id: uuid::Uuid, //Asset ID. pub class: String, //“us_equity” pub exchange: String, //AMEX, ARCA,...
code_fim
hard
{ "lang": "rust", "repo": "ultimaengineering/alpaca-client", "path": "/src/asset.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Make a closure that will later be called. pub fn new<F: FnOnce() + Send + 'static>(f: F) -> Self { Garbage::Fn { f: Some(SendBoxFnOnce::from(f)) } } } impl Drop for Garbage { fn drop(&mut self) { match *self { Garbage::Destroy { destroy, ...
code_fim
hard
{ "lang": "rust", "repo": "Vtec234/crossbeam-epoch", "path": "/src/garbage.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vtec234/crossbeam-epoch path: /src/garbage.rs //! Garbage collection. //! //! # Garbages //! //! Objects that get unlinked from concurrent data structures must be stashed away until the global //! epoch sufficiently advances so that they become safe for destruction. We call these objects //! ga...
code_fim
hard
{ "lang": "rust", "repo": "Vtec234/crossbeam-epoch", "path": "/src/garbage.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Bag of garbages. #[derive(Default)] pub struct Bag { /// Removed objects. objects: ArrayVec<[Garbage; MAX_OBJECTS]>, } impl Bag { /// Returns a new, empty bag. pub fn new() -> Self { Self::default() } /// Returns `true` if the bag is empty. pub fn is_empty(&self) ...
code_fim
hard
{ "lang": "rust", "repo": "Vtec234/crossbeam-epoch", "path": "/src/garbage.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] #[test] #[should_panic] fn login_fail_test() { let ( _, email ) = register_jacob(); login_jacob( email, JACOB_PASSWORD.to_string() + "!" ); } #[cfg(test)] #[test] fn profile_unlogged_test() { let client = Client::new(); let ( user_name, _ ) = register_jacob(); let url = ...
code_fim
hard
{ "lang": "rust", "repo": "tutorialstarters/rust-realworld-example-app", "path": "/src/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(res.status, hyper::Ok); (user_name, email, jwt) } #[cfg(test)] #[test] fn registration_test() { register_jacob(); } #[cfg(test)] #[test] fn login_test() { let ( _, email ) = register_jacob(); login_jacob( email, JACOB_PASSWORD.to_string() ); } #[cfg(test)] #[test] fn get...
code_fim
hard
{ "lang": "rust", "repo": "tutorialstarters/rust-realworld-example-app", "path": "/src/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tutorialstarters/rust-realworld-example-app path: /src/user.rs pub fn login(token: &str) -> Option<i32> { let token = Token::<Header, Registered>::parse(token).unwrap(); if token.verify(b"secret_key", Sha256::new()) { match token.claims.sub { Some(token) => ...
code_fim
hard
{ "lang": "rust", "repo": "tutorialstarters/rust-realworld-example-app", "path": "/src/user.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codahale/sketchy path: /src/lib.rs //! Sketchy is a Rust library of probabilistic data structures, useful for measuring large or //! unbounded streams of data by trading some accuracy for a whole lot of efficiency. <|fim_suffix|>pub use bloomfilter::BloomFilter; pub use countmin::CountMinSketch...
code_fim
medium
{ "lang": "rust", "repo": "codahale/sketchy", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use bloomfilter::BloomFilter; pub use countmin::CountMinSketch; pub use hyperloglog::HyperLogLog; pub use reservoir::ReservoirSample; pub use topk::TopK;<|fim_prefix|>// repo: codahale/sketchy path: /src/lib.rs //! Sketchy is a Rust library of probabilistic data structures, useful for measuring large...
code_fim
medium
{ "lang": "rust", "repo": "codahale/sketchy", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_3() { assert_eq!(Solution::search(vec![1], 0), -1); } #[test] fn test_4() { assert_eq!(Solution::search(vec![3, 5, 1], 3), 0); } }<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /survive-the-course-rs/src/problems/neetcode/binary_search/S...
code_fim
hard
{ "lang": "rust", "repo": "y-usuzumi/survive-the-course", "path": "/survive-the-course-rs/src/problems/neetcode/binary_search/Search_in_Rotated_Sorted_Array.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_2() { assert_eq!(Solution::search(vec![4, 5, 6, 7, 0, 1, 2], 3), -1); } #[test] fn test_3() { assert_eq!(Solution::search(vec![1], 0), -1); } #[test] fn test_4() { assert_eq!(Solution::search(vec![3, 5, 1], 3), 0); } }<|fim_pref...
code_fim
hard
{ "lang": "rust", "repo": "y-usuzumi/survive-the-course", "path": "/survive-the-course-rs/src/problems/neetcode/binary_search/Search_in_Rotated_Sorted_Array.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /survive-the-course-rs/src/problems/neetcode/binary_search/Search_in_Rotated_Sorted_Array.rs // https://leetcode.com/problems/search-in-rotated-sorted-array/ pub struct Solution; impl Solution { pub fn search(nums: Vec<i32>, target: i32) -> i32 { ...
code_fim
hard
{ "lang": "rust", "repo": "y-usuzumi/survive-the-course", "path": "/survive-the-course-rs/src/problems/neetcode/binary_search/Search_in_Rotated_Sorted_Array.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FlrnFrmm/AoC2019 path: /day7/src/intcode.rs use std::collections::VecDeque; pub type IntCode = Vec<i32>; #[derive(Debug)] enum OpCode{ Add, Mul, In, Out, JumpIfTrue, JumpIfFalse, LessThan, Equals, Halt, Err(i32) } #[derive(Debug)] enum ParameterMode { ...
code_fim
hard
{ "lang": "rust", "repo": "FlrnFrmm/AoC2019", "path": "/day7/src/intcode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn process(&mut self) { while self.state == State::Idle { let instruction = get_instruction(self.code[self.index].to_string()); let (pm1, pm2, pm3) = instruction.parameter_modes; match instruction.op_code { OpCode::Add => { ...
code_fim
hard
{ "lang": "rust", "repo": "FlrnFrmm/AoC2019", "path": "/day7/src/intcode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dovahcrow/julia-sys path: /src/lib.rs #![feature(untagged_unions)] extern crate libc; <|fim_suffix|>use std::process::Command; use std::path::PathBuf; use std::str; pub fn julia_home() -> PathBuf { let julia_home = Command::new("julia") .arg("-e") .arg(format!("print(JULIA...
code_fim
easy
{ "lang": "rust", "repo": "dovahcrow/julia-sys", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn julia_home() -> PathBuf { let julia_home = Command::new("julia") .arg("-e") .arg(format!("print(JULIA_HOME)")) .output() .unwrap_or_else(|e| panic!("julia not found: {}", e)); PathBuf::from(&str::from_utf8(&julia_home.stdout).unwrap()).to_path_buf() }<|fim_p...
code_fim
medium
{ "lang": "rust", "repo": "dovahcrow/julia-sys", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }