text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> node .as_ref() .map(|v| { let v = v.borrow(); let (left, right) = (&v.left, &v.right); macro_rules! check { // use 'tt' for single token ($child: ident, $target: ident, $left_op: tt, $right_op: tt) => {{ $child.as_ref().map(|child| { ...
code_fim
hard
{ "lang": "rust", "repo": "dainslef/RustPractice", "path": "/src/leetcode/q98_validate_binary_search_tree.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dainslef/RustPractice path: /src/leetcode/q98_validate_binary_search_tree.rs /*! [98. Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) Given the `root` of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follo...
code_fim
hard
{ "lang": "rust", "repo": "dainslef/RustPractice", "path": "/src/leetcode/q98_validate_binary_search_tree.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>use super::*; /** Runtime: 0 ms, faster than 100.00% of Rust online submissions for Validate Binary Search Tree. Memory Usage: 3 MB, less than 78.05% of Rust online submissions for Validate Binary Search Tree. */ fn is_valid_bst(root: Option<Rc<RefCell<TreeNode>>>) -> bool { /** Check each node by re...
code_fim
hard
{ "lang": "rust", "repo": "dainslef/RustPractice", "path": "/src/leetcode/q98_validate_binary_search_tree.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apache/incubator-teaclave-sgx-sdk path: /samplecode/wasmi/enclave/src/lib.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. T...
code_fim
hard
{ "lang": "rust", "repo": "apache/incubator-teaclave-sgx-sdk", "path": "/samplecode/wasmi/enclave/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> spec_driver.add_module(name, instance.clone()); Ok(()) } fn wasm_register(name: &Option<String>, as_name: String) -> Result<(), InterpreterError> { let ref mut spec_driver = SPECDRIVER.lock().unwrap(); spec_driver.register(name, as_name) } #[no_mangle] pub extern "C"...
code_fim
hard
{ "lang": "rust", "repo": "apache/incubator-teaclave-sgx-sdk", "path": "/samplecode/wasmi/enclave/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn endpoint(&self) -> String { "v2/launchpads/".to_owned() + self.launchpad_id } }<|fim_prefix|>// repo: twilco/space-rx path: /src/v2_api/requests/launchpad.rs use ::ApiRequest; use v2_api::models::launchpad::*; /// Retrieves information about all launchpads. Endpoint is `v2/launchpads...
code_fim
medium
{ "lang": "rust", "repo": "twilco/space-rx", "path": "/src/v2_api/requests/launchpad.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: twilco/space-rx path: /src/v2_api/requests/launchpad.rs use ::ApiRequest; use v2_api::models::launchpad::*; /// Retrieves information about all launchpads. Endpoint is `v2/launchpads`. #[derive(Builder, Debug, Default)] #[builder(default)] pub struct AllLaunchpadsRequest {} <|fim_suffix|>impl...
code_fim
hard
{ "lang": "rust", "repo": "twilco/space-rx", "path": "/src/v2_api/requests/launchpad.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (df, _) = NuDataFrame::try_from_stream(&mut args.input, &tag.span)?; let names = ChunkedArray::<Utf8Type>::new_from_opt_slice( "descriptor", &[ Some("count"), Some("sum"), Some("mean"), Some("median"), Some("std"), ...
code_fim
hard
{ "lang": "rust", "repo": "diversable/nushell", "path": "/crates/nu-command/src/commands/dataframe/describe.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diversable/nushell path: /crates/nu-command/src/commands/dataframe/describe.rs use crate::prelude::*; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{ dataframe::{Column, NuDataFrame}, Signature, UntaggedValue, }; use polars::{ chunked_array::ChunkedAr...
code_fim
hard
{ "lang": "rust", "repo": "diversable/nushell", "path": "/crates/nu-command/src/commands/dataframe/describe.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bryanburgers/advent-of-code-2020 path: /day-18/src/lexer.rs #[derive(Clone, Copy, Debug)] pub struct Lexer<'a> { input: &'a str, idx: usize, state: State, } #[derive(Clone, Copy, Debug, Eq, PartialEq)] enum State { Initial, InNumber { start: usize }, } impl<'a> Lexer<'a> { ...
code_fim
hard
{ "lang": "rust", "repo": "bryanburgers/advent-of-code-2020", "path": "/day-18/src/lexer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(s) => { panic!("Unexpected '{}'", s); } } } } } #[cfg(test)] mod tests { use super::*; #[test] fn lexer() { let lexer = Lexer::new("5 + 23 * ((19 + 2) * 73)"); let lexemes: Vec<&str> = lexer.coll...
code_fim
hard
{ "lang": "rust", "repo": "bryanburgers/advent-of-code-2020", "path": "/day-18/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn encrypt() { let mut locker = Locker::new(); let to_encrypt = "encrypt me!"; let encrypted = locker.encrypt(to_encrypt); let formated = format!( "{}${}${}", locker.dat.hex(), &locker.iv.hex()[2..], &locker.ke...
code_fim
hard
{ "lang": "rust", "repo": "dsbrgg/rk", "path": "/src/locker/locker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new() -> Locker { let dat = Bytes::new(E); let iv = Bytes::new(U16); let key = Bytes::new(U16); Locker { iv, key, dat } } pub fn from(iv: String, key: String, dat: String) -> Locker { let iv = Bytes::f...
code_fim
hard
{ "lang": "rust", "repo": "dsbrgg/rk", "path": "/src/locker/locker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dsbrgg/rk path: /src/locker/locker.rs /* Dependencies */ use std::hash::{Hash, Hasher}; use aes_soft as aes; use aes::Aes128; use regex::Regex; use block_modes::{BlockMode, Cbc}; use block_modes::block_padding::Pkcs7; use crypto_hash::{Algorithm, hex_digest}; use crate::locker::{Bytes, Byte...
code_fim
hard
{ "lang": "rust", "repo": "dsbrgg/rk", "path": "/src/locker/locker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SYP-DHIF17/ProjectManager path: /backend/pm_backend/pm_server/src/data/response_data.rs use pm_database::models::user::User; use serde::{Deserialize, Serialize}; use std::collections::HashSet; use tokio_pg_mapper_derive::PostgresMapper; use uuid::Uuid; use tokio_pg_mapper::{Error, FromTokioPost...
code_fim
hard
{ "lang": "rust", "repo": "SYP-DHIF17/ProjectManager", "path": "/backend/pm_backend/pm_server/src/data/response_data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> String::new() } } #[derive(PartialEq, Debug, Serialize, Deserialize, Clone)] pub struct ResponseID { id: Uuid, } impl ResponseID { pub fn new(id: Uuid) -> Self { Self {id} } } #[derive(PartialEq, Debug, Serialize, Deserialize, Clone)] pub struct ResponseProjectPart { ...
code_fim
hard
{ "lang": "rust", "repo": "SYP-DHIF17/ProjectManager", "path": "/backend/pm_backend/pm_server/src/data/response_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let command = self.find_matching_command(&message); if command.is_some() { let command = command.unwrap(); command.execute(self, &message); return Ok(()); } }, ServerMessage...
code_fim
hard
{ "lang": "rust", "repo": "Smertos/develbot", "path": "/src/messages/processor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ChatLogMessage::insert(&db_pool, chat_log_message).await }.await?; let command = self.find_matching_command(&message); if command.is_some() { let command = command.unwrap(); command.execute(self, &...
code_fim
hard
{ "lang": "rust", "repo": "Smertos/develbot", "path": "/src/messages/processor.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Smertos/develbot path: /src/messages/processor.rs use std::sync::Arc; use tokio::sync::RwLock; use twitch_irc::message::{PrivmsgMessage, ServerMessage}; use crate::bot::TwitchChatClient; use super::COMMAND_PREFIX; use super::core::Command; use super::commands::hello_command::HelloCommand; use...
code_fim
hard
{ "lang": "rust", "repo": "Smertos/develbot", "path": "/src/messages/processor.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tsionyx/nonogrid path: /src/render.rs use std::fmt::{self, Display}; #[cfg(feature = "colored")] use colored::{self, ColoredString, Colorize}; use hashbrown::HashMap; use crate::{ block::{base::color::ColorDesc, binary::BinaryColor, Block, Color, Description}, board::{Board, LineDirect...
code_fim
hard
{ "lang": "rust", "repo": "tsionyx/nonogrid", "path": "/src/render.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn header_lines(&self) -> Vec<Vec<String>> { transpose(&Self::descriptions_to_matrix( self.board().descriptions(LineDirection::Column), )) .unwrap() } } #[cfg(not(feature = "colored"))] type ColoredString = String; impl From<ColorDesc> for ColoredString { ...
code_fim
hard
{ "lang": "rust", "repo": "tsionyx/nonogrid", "path": "/src/render.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: google/tock-on-titan path: /shared-lib/spiutils/src/driver/firmware.rs // Copyright 2021 lowRISC contributors. // // 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 // /...
code_fim
hard
{ "lang": "rust", "repo": "google/tock-on-titan", "path": "/shared-lib/spiutils/src/driver/firmware.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> w.write_be(self.identifier.to_wire_value())?; w.write_be(self.address)?; w.write_be(self.size)?; w.write_be(self.start_page)?; w.write_be(self.page_count)?; Ok(()) } } // ---------------------------------------------------------------------------- /// ...
code_fim
hard
{ "lang": "rust", "repo": "google/tock-on-titan", "path": "/shared-lib/spiutils/src/driver/firmware.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_route_true() { let inputs = vec![json!(42), json!(true)]; let (output, run_again) = _route(&inputs).expect("_route() failed"); assert_eq!(run_again, RUN_AGAIN); assert!(output.is_some()); let value = output.expect("Could not get the Value fr...
code_fim
medium
{ "lang": "rust", "repo": "andrewdavidmackenzie/flow", "path": "/flowstdlib/src/control/route/route.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let inputs = vec![json!(42), json!(false)]; let (output, run_again) = _route(&inputs).expect("_route() failed"); assert_eq!(run_again, RUN_AGAIN); assert!(output.is_some()); let value = output.expect("Could not get the Value from the output"); let map = val...
code_fim
hard
{ "lang": "rust", "repo": "andrewdavidmackenzie/flow", "path": "/flowstdlib/src/control/route/route.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrewdavidmackenzie/flow path: /flowstdlib/src/control/route/route.rs use serde_json::Value; use flowcore::{RUN_AGAIN, RunAgain}; use flowcore::errors::*; use flowmacro::flow_function; #[flow_function] fn _route(inputs: &[Value]) -> Result<(Option<Value>, RunAgain)> { let data = &inputs[0...
code_fim
medium
{ "lang": "rust", "repo": "andrewdavidmackenzie/flow", "path": "/flowstdlib/src/control/route/route.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let output = quote!{ fn main() -> #fn_output { fn inner_main() -> #inner_fn_output { #inner_fn_body } std::process::exit(inner_main()?); } }; output.into() }<|fim_prefix|>// repo: ducaale/exit_status path: /src/lib.rs exter...
code_fim
hard
{ "lang": "rust", "repo": "ducaale/exit_status", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ducaale/exit_status path: /src/lib.rs extern crate proc_macro; use proc_macro::TokenStream; use quote::quote; use syn::parse_macro_input; #[proc_macro_attribute] pub fn main(_metadata: TokenStream, input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as syn::Item); l...
code_fim
medium
{ "lang": "rust", "repo": "ducaale/exit_status", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libonomy/libo-wasmer path: /lib/vm/src/vmoffsets.rs /// The number of imported memories in the module. pub num_imported_memories: u32, /// The number of imported globals in the module. pub num_imported_globals: u32, /// The number of defined tables in the module. pub num...
code_fim
hard
{ "lang": "rust", "repo": "libonomy/libo-wasmer", "path": "/lib/vm/src/vmoffsets.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Return the size of [`VMMemoryDefinition`]. /// /// [`VMMemoryDefinition`]: crate::vmcontext::VMMemoryDefinition pub const fn size_of_vmmemory_definition(&self) -> u8 { 2 * self.pointer_size } } /// Offsets for [`VMGlobalImport`]. /// /// [`VMGlobalImport`]: crate::vmcontex...
code_fim
hard
{ "lang": "rust", "repo": "libonomy/libo-wasmer", "path": "/lib/vm/src/vmoffsets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libonomy/libo-wasmer path: /lib/vm/src/vmoffsets.rs 1 * self.pointer_size } /// Return the size of [`VMMemoryImport`]. /// /// [`VMMemoryImport`]: crate::vmcontext::VMMemoryImport pub const fn size_of_vmmemory_import(&self) -> u8 { 3 * self.pointer_size ...
code_fim
hard
{ "lang": "rust", "repo": "libonomy/libo-wasmer", "path": "/lib/vm/src/vmoffsets.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libpasta/serde_mcf path: /src/de.rs use data_encoding::BASE64_NOPAD; use serde::de::{self, Deserialize, Deserializer, IntoDeserializer, Visitor}; use std::fmt::Display; use std::str::Split; use errors::*; impl de::Error for Error { fn custom<T>(msg: T) -> Self where T: Display ...
code_fim
hard
{ "lang": "rust", "repo": "libpasta/serde_mcf", "path": "/src/de.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where V: Visitor<'de> { if let Some(k) = self.0.next() { visitor.visit_borrowed_str(k) } else { Err("No field to deserialize".into()) } } // Deserialize a byte buf by first converting the field from base64. fn deserialize_byte_buf<V>...
code_fim
hard
{ "lang": "rust", "repo": "libpasta/serde_mcf", "path": "/src/de.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FreeReacts/fantoccini path: /examples/extensions/src/main.rs /// This example is only work with geckodriver extern crate fantoccini; extern crate tokio; extern crate serde; extern crate serde_json; use fantoccini::{Client, ExtensionCommand, Method, WebDriverExtensionCommand}; use serde::Seriali...
code_fim
hard
{ "lang": "rust", "repo": "FreeReacts/fantoccini", "path": "/examples/extensions/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] async fn main()-> Result<(), Error> { let mut client = Client::new("http://localhost:4444").await.unwrap(); let install_command = GeckoExtensionCommand::InstallAddon(AddonInstallParameters { path: String::from("/path/to/addon.xpi"), temporary: Some(true) }); ...
code_fim
hard
{ "lang": "rust", "repo": "FreeReacts/fantoccini", "path": "/examples/extensions/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn visit_while<'a>(&mut self, _: &'a While) -> T; } pub struct AstPrinter; impl AstPrinter { pub fn print(&mut self, expr: &Expr) -> String { expr.accept(self) } fn parenthesize<'a>(&mut self, name: &'a str, exprs: Vec<&Expr>) -> String { let mut string = String::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "yjv/rlox1", "path": "/src/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn visit_block<'a>(&mut self, _: &'a Block) -> T; fn visit_if<'a>(&mut self, _: &'a If) -> T; fn visit_while<'a>(&mut self, _: &'a While) -> T; } pub struct AstPrinter; impl AstPrinter { pub fn print(&mut self, expr: &Expr) -> String { expr.accept(self) } fn parenthesize...
code_fim
hard
{ "lang": "rust", "repo": "yjv/rlox1", "path": "/src/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yjv/rlox1 path: /src/ast.rs use scanner; use std::rc::Rc; #[derive(Clone, Debug)] pub struct Binary { pub left: Box<Expr>, pub operator: scanner::Token, pub right: Box<Expr> } #[derive(Clone, Debug)] pub struct Call { pub callee: Box<Expr>, pub paren: scanner::Token, pu...
code_fim
hard
{ "lang": "rust", "repo": "yjv/rlox1", "path": "/src/ast.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let data = b"\x01\0\0\0"; let test: Test = Cursor::new(data).read_be().unwrap(); let mut x = Cursor::new(Vec::new()); test.write_to(&mut x).unwrap(); assert_eq!(&x.into_inner()[..], data); }<|fim_prefix|>// repo: ShabbirHasan1/binrw path: /binrw/tests/derive/write/top_level_map.rs u...
code_fim
hard
{ "lang": "rust", "repo": "ShabbirHasan1/binrw", "path": "/binrw/tests/derive/write/top_level_map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { x: bytes[0] == 1 } } } let data = b"\x01\0\0\0"; let test: Test = Cursor::new(data).read_be().unwrap(); let mut x = Cursor::new(Vec::new()); test.write_to(&mut x).unwrap(); assert_eq!(&x.into_inner()[..], data); }<|fim_prefix|>// repo: ShabbirHasan1/bi...
code_fim
medium
{ "lang": "rust", "repo": "ShabbirHasan1/binrw", "path": "/binrw/tests/derive/write/top_level_map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ShabbirHasan1/binrw path: /binrw/tests/derive/write/top_level_map.rs use binrw::{binrw, io::Cursor, BinReaderExt, BinWrite}; #[test] fn round_trip_top_level_map() { #[binrw] #[br(map = Test::from_bytes)] #[bw(map = Test::to_bytes)] struct Test { x: bool, } <|fim_suf...
code_fim
medium
{ "lang": "rust", "repo": "ShabbirHasan1/binrw", "path": "/binrw/tests/derive/write/top_level_map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GraphiteEditor/Graphite path: /editor/src/messages/input_mapper/utility_types/input_mouse.rs use crate::consts::DRAG_THRESHOLD; use crate::messages::prelude::*; use bitflags::bitflags; use glam::DVec2; use serde::{Deserialize, Serialize}; use std::collections::VecDeque; // Origin is top left p...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/editor/src/messages/input_mapper/utility_types/input_mouse.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn scroll_delta(&self) -> f64 { let (dx, dy) = (self.x, self.y); dy.signum() as f64 * ((dy * dy + i32::min(dy.abs(), dx.abs()).pow(2)) as f64).sqrt() } } #[derive(Debug, Copy, Clone, Default, PartialEq, Serialize, Deserialize)] pub struct MouseState { pub position: ViewportPosition, pub mouse...
code_fim
hard
{ "lang": "rust", "repo": "GraphiteEditor/Graphite", "path": "/editor/src/messages/input_mapper/utility_types/input_mouse.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // game loop while running { // Extract any pending events from from the event pump and process them for event in event_pump.poll_iter() { // pattern match on the type of event match event { Event::Quit {..} => { running =...
code_fim
hard
{ "lang": "rust", "repo": "ysgard/rust-lazy-foo", "path": "/lesson03/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Get a handle to the SDL2 event pump let mut event_pump = match sdl_context.event_pump() { Ok(event_pump) => event_pump, Err(err) => panic!("Could not obtain event pump: {}", err) }; // game loop while running { // Extract any pending events from fr...
code_fim
hard
{ "lang": "rust", "repo": "ysgard/rust-lazy-foo", "path": "/lesson03/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ysgard/rust-lazy-foo path: /lesson03/main.rs extern crate sdl2; use sdl2::Sdl; use sdl2::video::Window; use sdl2::render::{Renderer, Texture}; use sdl2::event::Event; use sdl2::surface::{Surface}; const WIDTH: u32 = 640; const HEIGHT: u32 = 480; const X_IMAGE: &'static str = "resources/x.bmp...
code_fim
hard
{ "lang": "rust", "repo": "ysgard/rust-lazy-foo", "path": "/lesson03/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raphamorim/rio path: /corcovado/test/test_tcp.rs // } // let l = TcpListener::bind(&"127.0.0.1:0".parse().unwrap()).unwrap(); // let addr = l.local_addr().unwrap(); // let t = thread::spawn(move || { // net::TcpStream::connect(&addr).unwrap(); // }); // let po...
code_fim
hard
{ "lang": "rust", "repo": "raphamorim/rio", "path": "/corcovado/test/test_tcp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// #[test] // fn connect_then_close() { // struct H { // listener: TcpListener, // shutdown: bool, // } // let poll = Poll::new().unwrap(); // let l = TcpListener::bind(&"127.0.0.1:0".parse().unwrap()).unwrap(); // let s = TcpStream::connect(&l.local_addr().unwrap()).u...
code_fim
hard
{ "lang": "rust", "repo": "raphamorim/rio", "path": "/corcovado/test/test_tcp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raphamorim/rio path: /corcovado/test/test_tcp.rs let addr = l.local_addr().unwrap(); // let t = thread::spawn(move || { // let mut s = l.accept().unwrap().0; // let b = [0; 1024]; // let mut amt = 0; // while amt < N { // amt += s.write(&b).unwrap...
code_fim
hard
{ "lang": "rust", "repo": "raphamorim/rio", "path": "/corcovado/test/test_tcp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>unsafe fn mid_of_range<T>( mut start: NonNull<Node<T>>, end: NonNull<Node<T>>, ) -> (NonNull<Node<T>>, usize) { let mut mid = start; let mut len = 0; while start != end { len += 1; start = start.as_ref().next; if start != end { len += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/cyclic_list", "path": "/src/list/algorithms.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/cyclic_list path: /src/list/algorithms.rs use crate::list::{connect, List, Node}; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use std::ptr::NonNull; impl<T: PartialEq> PartialEq for List<T> { fn eq(&self, other: &Self) -> bool { self.iter().eq(other) } } impl...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/cyclic_list", "path": "/src/list/algorithms.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nilsmartel/solar path: /src/parse/signature/types.rs use crate::parse::{terminals::Identifier, traits::Parse, util::char_ws}; use nom::{combinator::map, sequence::separated_pair, IResult}; #[derive(Clone, Debug, Eq, PartialEq)] pub struct Type { // TODO include generics and proper modules ...
code_fim
hard
{ "lang": "rust", "repo": "nilsmartel/solar", "path": "/src/parse/signature/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Parse for Parameter { fn parse(input: &str) -> nom::IResult<&str, Self> { map( separated_pair(Identifier::parse, char_ws(':'), Type::parse_ws), |(name, kind)| Parameter { name, kind }, )(input) } } #[cfg(test)] mod test_paramter { use super::*; ...
code_fim
medium
{ "lang": "rust", "repo": "nilsmartel/solar", "path": "/src/parse/signature/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( result, Parameter { name: "myvar".into(), kind: Type { name: "string".into() } } ); assert_eq!(rest, ""); } }<|fim_prefix|>// repo: nilsmartel/solar path: /src/...
code_fim
hard
{ "lang": "rust", "repo": "nilsmartel/solar", "path": "/src/parse/signature/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.rpc_addr.hash(state); } } #[cached(time = 60)] pub fn get_blockchain_info(rpcclient: Client) -> json::GetBlockchainInfoResult { let out = rpcclient.core_client().get_blockchain_info().unwrap(); tracing::info!("get_blockchain_info: {:?}", out); out } #[cached(time = 60)] pub ...
code_fim
hard
{ "lang": "rust", "repo": "EnormousCloud/bitcoin-explorer", "path": "/server/src/rpc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EnormousCloud/bitcoin-explorer path: /server/src/rpc.rs use crate::pager; use crate::types::response; use crate::types::{Block, BlockStatsInfo, BlockStatsResponse, BlocksList}; use bitcoin::hashes::hex::FromHex; use bitcoincore_rpc::RpcApi; use bitcoincore_rpc_json as json; use cached::proc_macr...
code_fim
hard
{ "lang": "rust", "repo": "EnormousCloud/bitcoin-explorer", "path": "/server/src/rpc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AliAryanTech/rust-tg-bot path: /src/types/user_profile_photos.rs use crate::types::{PhotoSize, User}; <|fim_suffix|>#[derive(Debug, Deserialize, Serialize, Clone)] pub struct UserProfilePhotos { /// Total number of profile pictures the target user has pub total_count: i32, /// Reque...
code_fim
easy
{ "lang": "rust", "repo": "AliAryanTech/rust-tg-bot", "path": "/src/types/user_profile_photos.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize, Serialize, Clone)] pub struct UserProfilePhotos { /// Total number of profile pictures the target user has pub total_count: i32, /// Requested profile pictures (in up to 4 sizes each) pub photos: Vec<Vec<PhotoSize>>, }<|fim_prefix|>// repo: AliAryanTech/rust-tg...
code_fim
easy
{ "lang": "rust", "repo": "AliAryanTech/rust-tg-bot", "path": "/src/types/user_profile_photos.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut indices_ref = vec![ 268391, 286878, 720286, 828689, 144749, 268391, 286878, 790269, ]; indices_ref.sort(); indices_ref.dedup(); let mut indices = X.indices().to_vec(); indices.sort(); indices.dedup(); assert_eq!(indices_ref.len(), indices.len()); let X2...
code_fim
hard
{ "lang": "rust", "repo": "joshlk/vtext", "path": "/src/vectorize/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_count_vectorizer_fit_transform() { for documents in &[vec!["cat dog cat".to_string()]] { let mut vect = CountVectorizer::<RegexpTokenizer>::default(); vect.fit(&documents); let X = vect.transform(&documents); let mut vect2 = CountVectorizer::<RegexpToke...
code_fim
hard
{ "lang": "rust", "repo": "joshlk/vtext", "path": "/src/vectorize/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joshlk/vtext path: /src/vectorize/tests.rs // Copyright 2019 vtext developers // // Licensed under the Apache License, Version 2.0, // <http://apache.org/licenses/LICENSE-2.0>. This file may not be copied, // modified, or distributed except according to those terms. use crate::tokenize::*; use ...
code_fim
hard
{ "lang": "rust", "repo": "joshlk/vtext", "path": "/src/vectorize/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> where Self: PySequenceInplaceConcatProtocol<'p>, { unimplemented!() } fn __inplace_repeat__(&'p mut self, count: Self::Index) -> Self::Result where Self: PySequenceInplaceRepeatProtocol<'p>, { unimplemented!() } } // The following are a bunch o...
code_fim
hard
{ "lang": "rust", "repo": "syrusakbary/pyo3", "path": "/src/class/sequence.rs", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: syrusakbary/pyo3 path: /src/class/sequence.rs // Copyright (c) 2017-present PyO3 Project and Contributors //! Python Sequence Interface //! Trait and support implementation for implementing sequence use crate::callback::IntoPyCallbackOutput; use crate::conversion::{FromPyObject, IntoPy}; use c...
code_fim
hard
{ "lang": "rust", "repo": "syrusakbary/pyo3", "path": "/src/class/sequence.rs", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub(super) fn del_item<T>() -> Option<ffi::ssizeobjargproc> where T: for<'p> PySequenceDelItemProtocol<'p>, { unsafe extern "C" fn wrap<T>( slf: *mut ffi::PyObject, key: ffi::Py_ssize_t, value: *mut ffi::PyObject, ) -> c_int w...
code_fim
hard
{ "lang": "rust", "repo": "syrusakbary/pyo3", "path": "/src/class/sequence.rs", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itsrainingmani/monkeylang path: /tests/lexer_test.rs use monkey::{lexer::Lexer, token, token::TokenType}; #[test] fn test_next_token() { let mut lex = Lexer::new(String::from("=+(){},;")); let expected_tokens = vec![ token::Token { kind: TokenType::ASSIGN, ...
code_fim
hard
{ "lang": "rust", "repo": "itsrainingmani/monkeylang", "path": "/tests/lexer_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut lex = Lexer::new(String::from("let five = 5;\nlet ten = 10;")); let expected_tokens = vec![ token::Token { kind: TokenType::LET, literal: "let".to_string(), }, token::Token { kind: TokenType::IDENT, literal: "five".to...
code_fim
hard
{ "lang": "rust", "repo": "itsrainingmani/monkeylang", "path": "/tests/lexer_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Set terminal into raw mode if not already in raw mode, and save // previous state so that it can be restored fn termios_set_raw(&mut self) -> bool { if self.saved.is_some() { return false; } if 0 == unsafe { libc::isatty(STDIN_FD) } { let err...
code_fim
hard
{ "lang": "rust", "repo": "uazu/stakker_tui", "path": "/src/os_mio_unix.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut tbuf = mem::MaybeUninit::uninit(); if 0 > unsafe { libc::tcgetattr(STDIN_FD, tbuf.as_mut_ptr()) } { let err = Error::new(Error::last_os_error().kind(), "Unable to get terminal mode"); call!([self.term], handle_error_in(err)); return false; ...
code_fim
hard
{ "lang": "rust", "repo": "uazu/stakker_tui", "path": "/src/os_mio_unix.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uazu/stakker_tui path: /src/os_mio_unix.rs //! Handle WINCH through a UNIX signal forwarded through a pipe to //! MIO. Dump output data straight to stdout FD, with a blocking //! call. This will block the whole thread if the TTY is in XOFF. use crate::terminal::Terminal; use libc::{c_int, c_u...
code_fim
hard
{ "lang": "rust", "repo": "uazu/stakker_tui", "path": "/src/os_mio_unix.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kellboy9/homemade path: /src/stats.rs use std::collections::HashMap; use world::{GameState, Entity, Component}; use world::storage::VecStorage; pub use self::Stat::*; //just so nobody has to type 'Stat' again for the enum #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[allow(dead_code)] pu...
code_fim
hard
{ "lang": "rust", "repo": "kellboy9/homemade", "path": "/src/stats.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn prepare_world() -> GameState { let mut w = GameState::new(); init(&mut w); w } #[test] fn base_stats() { let mut w = prepare_world(); let stats_test_entity = w.create_entity(); set_base(&w, stats_test_entity, VITALITY, 32); assert...
code_fim
hard
{ "lang": "rust", "repo": "kellboy9/homemade", "path": "/src/stats.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn base_stats() { let mut w = prepare_world(); let stats_test_entity = w.create_entity(); set_base(&w, stats_test_entity, VITALITY, 32); assert_eq!(get_base(&w, stats_test_entity, VITALITY), 32); w.delete_entity(stats_test_entity); } #[test]...
code_fim
hard
{ "lang": "rust", "repo": "kellboy9/homemade", "path": "/src/stats.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} pub trait Sortable { type Order; } macro_rules! create_mapping { ( $from:ty; $to:ty => { $($new:ident <- $($old:ident).+),+ } ) => { impl ::utils::FromQueryable for $from { type To = $to; fn from_queryable( self ) -> Self::To { Self::To { ...
code_fim
hard
{ "lang": "rust", "repo": "MarWit/University", "path": "/DatabaseApplications/project/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarWit/University path: /DatabaseApplications/project/src/utils.rs macro_rules! new_table { ( $name:ident; $new_name:ident; $table:expr => { $( $attr:ident : $type:ty ),+ }) => { #[derive(Identifiable, Queryable, Clone, Debug)] #[table_name=$table] pub...
code_fim
hard
{ "lang": "rust", "repo": "MarWit/University", "path": "/DatabaseApplications/project/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Sortable { type Order; } macro_rules! create_mapping { ( $from:ty; $to:ty => { $($new:ident <- $($old:ident).+),+ } ) => { impl ::utils::FromQueryable for $from { type To = $to; fn from_queryable( self ) -> Self::To { Self::To { ...
code_fim
hard
{ "lang": "rust", "repo": "MarWit/University", "path": "/DatabaseApplications/project/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> stream: impl 'static + Send + Stream<Item = I, Error = ()>, mut acc: Vec<I>, k: K, ) -> impl Send + Future<Item = R, Error = ()> { k(&acc).map_or_else( || { Box::new(stream.into_future().then(|result| match result { Ok((x,...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/paxos", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/paxos path: /src/util.rs use { futures::{ future::{err, ok}, prelude::Future, stream::{self, Stream}, Poll, }, hyper::{client::HttpConnector, Body, Client, Method, Request}, serde::{de::DeserializeOwned, Serialize}, std::net::SocketAddr...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/paxos", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>UCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000, VK_STRUCTURE_TYPE_PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATIO...
code_fim
hard
{ "lang": "rust", "repo": "nikitablack/rust_vulkan_bindings_test", "path": "/src/vk/vk_enums.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>OPERTIES_NV = 1000249002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV = 1000250000, VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV = 1000250001, VK_STRUCTURE_TYPE_FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV = 1000250002, VK_STRUCTURE_TYPE_PHYSICAL...
code_fim
hard
{ "lang": "rust", "repo": "nikitablack/rust_vulkan_bindings_test", "path": "/src/vk/vk_enums.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nikitablack/rust_vulkan_bindings_test path: /src/vk/vk_enums.rs VkStructureType::VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; pub const VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR: VkStructureType = VkStructureType::VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_C...
code_fim
hard
{ "lang": "rust", "repo": "nikitablack/rust_vulkan_bindings_test", "path": "/src/vk/vk_enums.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ratel-rust/ratel-core path: /ratel-transformer/src/lib.rs #[cfg(test)] #[macro_use] extern crate pretty_assertions; extern crate ratel; extern crate ratel_visitor; extern crate toolshed; use toolshed::Arena; use toolshed::list::ListBuilder; use ratel::ast::{Loc, Node, NodeList}; use ratel::Modu...
code_fim
hard
{ "lang": "rust", "repo": "ratel-rust/ratel-core", "path": "/ratel-transformer/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn transform<'ast>(module: &'ast mut Module<'ast>) { let arena = module.arena(); let ctx = TransformerCtxt { arena, scope: arena.alloc(Scope::new(ScopeKind::Function, None)), }; module.visit_with(&mut es2015::PresetES2015::new(ctx)); }<|fim_prefix|>// repo: ratel-rust...
code_fim
hard
{ "lang": "rust", "repo": "ratel-rust/ratel-core", "path": "/ratel-transformer/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn swap<T, I>(&self, ptr: Node<'ast, T>, item: I) where T: Copy + 'ast, I: Into<T>, { let new = self.arena.alloc(Loc { start: ptr.start, end: ptr.end, item: item.into() }); ptr.set(new); } } pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "ratel-rust/ratel-core", "path": "/ratel-transformer/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alfex4936/Rust-Studies path: /src/syntax/oop.rs struct Student { org: String, name: String, age: i32 } // struct 메소드 구현 impl Student { fn get_age(&mut self) { // &self나 borrow해서 &mut self.age += 1; } fn find_age(&self) -> i32 { 100 - self.age } } f...
code_fim
medium
{ "lang": "rust", "repo": "Alfex4936/Rust-Studies", "path": "/src/syntax/oop.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} goes to {} university and age is {} years old", student1.org, student1.name, student1.age); student1.get_age(); println!("{} is now {} years old", student1.name, student1.age); println!("{} will have {} years to be 100 years old", student2.name, student2.find_age()); }<|...
code_fim
hard
{ "lang": "rust", "repo": "Alfex4936/Rust-Studies", "path": "/src/syntax/oop.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{} is now {} years old", student1.name, student1.age); println!("{} will have {} years to be 100 years old", student2.name, student2.find_age()); }<|fim_prefix|>// repo: Alfex4936/Rust-Studies path: /src/syntax/oop.rs struct Student { org: String, name: String, age: i32 } /...
code_fim
hard
{ "lang": "rust", "repo": "Alfex4936/Rust-Studies", "path": "/src/syntax/oop.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stjordanis/litentry-juniper-api path: /warp/src/main.rs extern crate failure; #[macro_use] extern crate failure_derive; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; #[macro_use] extern crate juniper; #[macro_use(bson, doc)] extern crate bson; extern cra...
code_fim
hard
{ "lang": "rust", "repo": "stjordanis/litentry-juniper-api", "path": "/warp/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let context_extractor = warp::any().map(move || -> Context { ctx.clone() }); let handle_request = move |context: Context, request: juniper::http::GraphQLRequest| -> Result<Vec<u8>, serde_json::Error> { serde_json::to_vec(&request.execute(&schema, &context)) }; war...
code_fim
hard
{ "lang": "rust", "repo": "stjordanis/litentry-juniper-api", "path": "/warp/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ommandParams::type_script_ify()); println!("{}", ir::InputLanguage::type_script_ify()); println!("{}", ir::Config::type_script_ify()); println!("{}", ir::ConfigDefinition::type_script_ify()); println!("{}", ir::ConfigParams::type_script_ify()); }<|fim_prefix|>// repo: shakyShane/topics-2 ...
code_fim
hard
{ "lang": "rust", "repo": "shakyShane/topics-2", "path": "/ir/src/bin/ts_types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shakyShane/topics-2 path: /ir/src/bin/ts_types.rs use typescript_definitions::TypeScriptifyTrait; fn main() { println!("{}", ir::Ir::type_script_ify()); println!("{}", ir::IrItem::type_script_ify()); println!("{}", ir::Action::type_script_ify()); println!("{}", ir::Instruction::...
code_fim
hard
{ "lang": "rust", "repo": "shakyShane/topics-2", "path": "/ir/src/bin/ts_types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match p_factors { Some(max) => max, None => panic!("This number is already a prime!"), } } fn is_prime(n: &i64) -> bool { let factors = (2..n.sqrt()+1).into_par_iter() .filter(|x| x % 2 != 0) .filter(...
code_fim
hard
{ "lang": "rust", "repo": "timattwell/proj_euler", "path": "/pr_3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} fn is_prime(n: &i64) -> bool { let factors = (2..n.sqrt()+1).into_par_iter() .filter(|x| x % 2 != 0) .filter(|x| n % x == 0) .min(); match factors { Some(_) => false, None => tr...
code_fim
hard
{ "lang": "rust", "repo": "timattwell/proj_euler", "path": "/pr_3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timattwell/proj_euler path: /pr_3/src/main.rs /* pr_3 - Tim Attwell * * Description - The prime factors of 13195 are 5, 7, 13 and 29. * What is the largest prime factor of the number 600851475143 * * Notes - Two functions this time to make things slightly easier to follow. * ...
code_fim
hard
{ "lang": "rust", "repo": "timattwell/proj_euler", "path": "/pr_3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bilelmoussaoui/wallabag-api path: /src/errors.rs //! Client error types. use std::error::Error; use std::fmt; use reqwest::StatusCode; use serde::Deserialize; pub type ClientResult<T> = std::result::Result<T, ClientError>; /// Type for the JSON error data returned on error from the HTTP API ...
code_fim
hard
{ "lang": "rust", "repo": "bilelmoussaoui/wallabag-api", "path": "/src/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ClientError::ReqwestError(err) } } impl From<serde_json::error::Error> for ClientError { fn from(err: serde_json::error::Error) -> Self { ClientError::SerdeJsonError(err) } } /// Represents possible errors building a `TagString`. #[derive(Debug)] pub enum TagStringError { ...
code_fim
hard
{ "lang": "rust", "repo": "bilelmoussaoui/wallabag-api", "path": "/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pt2121/scion path: /src/core/systems/animations_system.rs use legion::{systems::CommandBuffer, *}; use crate::core::{ components::{ animations::{ AnimationModifier, AnimationModifierType, AnimationStatus, Animations, ComputedKeyframeModifier, }, ...
code_fim
hard
{ "lang": "rust", "repo": "pt2121/scion", "path": "/src/core/systems/animations_system.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> animations .animations_mut() .iter_mut() .filter(|(_, v)| v.status == AnimationStatus::STOPPED) .for_each(|(key, animation)| { for modifier in animation.modifiers.iter_mut() { let timer_id = format!("{:?}-{}-{}", *entity, key, modifier.to_str...
code_fim
hard
{ "lang": "rust", "repo": "pt2121/scion", "path": "/src/core/systems/animations_system.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: libp2p/rust-libp2p path: /transports/webrtc/src/tokio/substream/drop_listener.rs // Copyright 2022 Parity Technologies (UK) Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal ...
code_fim
hard
{ "lang": "rust", "repo": "libp2p/rust-libp2p", "path": "/transports/webrtc/src/tokio/substream/drop_listener.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let state = &mut self.get_mut().state; loop { match std::mem::replace(state, State::Poisoned) { State::Idle { stream, substream_id, mut receiver, } => match receiver.poll_unpin(cx) { ...
code_fim
hard
{ "lang": "rust", "repo": "libp2p/rust-libp2p", "path": "/transports/webrtc/src/tokio/substream/drop_listener.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fvhockney/warp-drive path: /src/main.rs use std::env; use std::process::exit; mod cli; use cli::cli; mod waypoint; mod errors; use errors::WarpError; mod config; use config::{Config, ListVerbosity}; fn add_entry(name: String) -> Result<String, WarpError> { let path = env::current_dir()....
code_fim
hard
{ "lang": "rust", "repo": "fvhockney/warp-drive", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }