text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>#[cfg(all(not(feature = "isahc"), not(target_arch = "wasm32")))] impl GitHubRequestBuilder for http::Request<Vec<u8>> { fn build(_req: GitHubRequest, _auth: &Auth) -> Result<Self, AdapterError> { unimplemented!("Use a client adapter feature, or target wasm"); } } #[cfg(all(not(feature = ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/roctogen", "path": "/src/adapters/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn walk<F>(t : Tree, repo: &Repository, mut visitor: F) where F: FnMut(&str, &TreeEntry) { walk_recursor(t, "", repo, &mut visitor) }<|fim_prefix|>// repo: steveklabnik/libgit-rust-playground path: /src/tree.rs extern crate git2; use git2::*; pub fn prefix(root: &str, end: &str) -> String {...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/libgit-rust-playground", "path": "/src/tree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steveklabnik/libgit-rust-playground path: /src/tree.rs extern crate git2; use git2::*; pub fn prefix(root: &str, end: &str) -> String { if root.is_empty() { end.to_string() } else { [root, end].join("/").to_string() } } fn walk_recursor<F>(t: Tree, root: &str, repo: &Repository, visi...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/libgit-rust-playground", "path": "/src/tree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if te.kind().unwrap() == ObjectType::Tree { let subtree = match te.to_object(repo) .unwrap() .into_tree() { Ok(t) => t, Err(_) => panic!("Couldn't unwrap TreeEntry to Tree") }; walk_recursor(subtr...
code_fim
hard
{ "lang": "rust", "repo": "steveklabnik/libgit-rust-playground", "path": "/src/tree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: U007D/rayt path: /src/primitives/vec3/unit_tests/add.rs #![allow(non_snake_case, clippy::unwrap_used)] <|fim_suffix|>#[allow(clippy::float_cmp)] #[test] fn returns_expected_result() { // Given let expected = Vec3::new(5.0, 7.0, 9.0); let a = Vec3::new(1.0, 2.0, 3.0); let b = Vec...
code_fim
easy
{ "lang": "rust", "repo": "U007D/rayt", "path": "/src/primitives/vec3/unit_tests/add.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Then assert!(result == expected); }<|fim_prefix|>// repo: U007D/rayt path: /src/primitives/vec3/unit_tests/add.rs #![allow(non_snake_case, clippy::unwrap_used)] use super::*; use assert2::assert; #[allow(clippy::float_cmp)] #[test] fn returns_expected_result() { // Given let expected...
code_fim
easy
{ "lang": "rust", "repo": "U007D/rayt", "path": "/src/primitives/vec3/unit_tests/add.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return serde_json::to_string(&ret).unwrap(); } let reply = self.servers[self.leader_id] .commit(&req) .unwrap_or_else(|e| { let msg = format!("{:?}", e); error!("{:?}", msg); ...
code_fim
hard
{ "lang": "rust", "repo": "kenoss/bayard", "path": "/src/client/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kenoss/bayard path: /src/client/client.rs utResp, CommitReq, CommitResp, ConfChangeReq, DeleteReq, DeleteResp, GetReq, GetResp, MergeReq, MergeResp, MetricsReq, MetricsResp, PeersReq, PeersResp, ProbeReq, ProbeResp, PutReq, PutResp, RaftDone, RespErr, RollbackReq, RollbackResp, Schem...
code_fim
hard
{ "lang": "rust", "repo": "kenoss/bayard", "path": "/src/client/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn invalid<T: AsRef<str>>(desc: T) -> io::Error { io::Error::new(io::ErrorKind::InvalidData, desc.as_ref()) }<|fim_prefix|>// repo: dkeehl/chunfen path: /chunfen-socks/src/utils.rs use std::io; use futures::Future; <|fim_middle|>pub fn boxup<T: Future + Send + 'static>(x: T) -> Box<Fut...
code_fim
medium
{ "lang": "rust", "repo": "dkeehl/chunfen", "path": "/chunfen-socks/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dkeehl/chunfen path: /chunfen-socks/src/utils.rs use std::io; use futures::Future; <|fim_suffix|>pub fn invalid<T: AsRef<str>>(desc: T) -> io::Error { io::Error::new(io::ErrorKind::InvalidData, desc.as_ref()) }<|fim_middle|>pub fn boxup<T: Future + Send + 'static>(x: T) -> Box<Fut...
code_fim
medium
{ "lang": "rust", "repo": "dkeehl/chunfen", "path": "/chunfen-socks/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adeschamps/lsm303 path: /examples/read.rs #![allow(unused_doc_comment)] extern crate dimensioned; use dimensioned::si; use dimensioned::f64prefixes::MILLI; #[macro_use] extern crate error_chain; extern crate lsm303; error_chain!{} quick_main!(run); <|fim_suffix|> loop { let acce...
code_fim
hard
{ "lang": "rust", "repo": "adeschamps/lsm303", "path": "/examples/read.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let device = "/dev/i2c-1"; let mut accelerometer = lsm303::Accelerometer::new(device).chain_err(|| "Failed to initialize the accelerometer")?; let mut magnetometer = lsm303::Magnetometer::new(device).chain_err(|| "Failed to initialize the magnetometer")?; loop { l...
code_fim
medium
{ "lang": "rust", "repo": "adeschamps/lsm303", "path": "/examples/read.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattmezza/neovide path: /src/editor/mod.rs mod cursor; mod style; use std::collections::HashMap; use std::sync::{Arc, Mutex}; use skulpin::skia_safe::colors; use unicode_segmentation::UnicodeSegmentation; pub use cursor::{Cursor, CursorShape, CursorMode}; pub use style::{Colors, Style}; use c...
code_fim
hard
{ "lang": "rust", "repo": "mattmezza/neovide", "path": "/src/editor/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn command_matches(command: &Option<DrawCommand>, style: &Option<Style>) -> bool { match command { Some(command) => &command.style == style, None => true } } fn add_character(command: &mut Option<D...
code_fim
hard
{ "lang": "rust", "repo": "mattmezza/neovide", "path": "/src/editor/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //are these points closer horizontally or vertically? if self.selected.len() < 2 { return; } let sels = self.selected.clone(); let minx = sels.values().fold(std::f64::MAX, |acc, p| p.x.min(acc)); let maxx = sels.values().fold(std::f64::MIN, |acc, p| p.x.max(acc)...
code_fim
hard
{ "lang": "rust", "repo": "cakrawalakpc/runebender", "path": "/src/widgets/editor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cakrawalakpc/runebender path: /src/widgets/editor.rs use std::collections::HashMap; use kurbo::{Affine, BezPath, Circle, Line, Rect, Shape, Vec2}; use norad::glyph::{Glyph, PointType}; use piet::{FillRule, RenderContext}; use druid::{ BoxConstraints, Geometry, HandlerCtx, Id, KeyEvent, Key...
code_fim
hard
{ "lang": "rust", "repo": "cakrawalakpc/runebender", "path": "/src/widgets/editor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] #[path = "../unit_tests/type_prop_tests.rs"] mod type_prop_tests; /// Resolved form of runtime types. #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] pub enum Type { Bool, U64, String, ByteArray, Address, Struct(StructDef), Reference(Box<Type>), ...
code_fim
medium
{ "lang": "rust", "repo": "vasblock/libra", "path": "/language/vm/vm-runtime/vm-runtime-types/src/loaded_data/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Resolved form of runtime types. #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] pub enum Type { Bool, U64, String, ByteArray, Address, Struct(StructDef), Reference(Box<Type>), MutableReference(Box<Type>), TypeVariable(u16), }<|fim_prefix|>// repo: vas...
code_fim
medium
{ "lang": "rust", "repo": "vasblock/libra", "path": "/language/vm/vm-runtime/vm-runtime-types/src/loaded_data/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vasblock/libra path: /language/vm/vm-runtime/vm-runtime-types/src/loaded_data/types.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Loaded representation for runtime types. <|fim_suffix|>#[cfg(test)] #[path = "../unit_tests/type_prop_tests.rs"] mod typ...
code_fim
medium
{ "lang": "rust", "repo": "vasblock/libra", "path": "/language/vm/vm-runtime/vm-runtime-types/src/loaded_data/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ari23/NetBricks path: /framework/src/packets/icmp/v6/ndp/neighbor_advert.rs use crate::packets::icmp::v6::ndp::NdpPayload; use crate::packets::icmp::v6::{Icmpv6, Icmpv6Packet, Icmpv6Payload, Icmpv6Type, Icmpv6Types}; use crate::packets::ip::v6::Ipv6Packet; use std::fmt; use std::net::Ipv6Addr; ...
code_fim
hard
{ "lang": "rust", "repo": "ari23/NetBricks", "path": "/framework/src/packets/icmp/v6/ndp/neighbor_advert.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>const R_FLAG: u8 = 0b1000_0000; const S_FLAG: u8 = 0b0100_0000; const O_FLAG: u8 = 0b0010_0000; /// NDP neighbor advertisement message #[derive(Clone, Copy, Debug)] #[repr(C)] pub struct NeighborAdvertisement { flags: u8, reserved1: u8, reserved2: u16, target_addr: Ipv6Addr, } impl Defau...
code_fim
hard
{ "lang": "rust", "repo": "ari23/NetBricks", "path": "/framework/src/packets/icmp/v6/ndp/neighbor_advert.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luojia65/librv4rs-example path: /build.rs use std::env; use std::fs; use std::path::PathBuf; <|fim_suffix|> let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); fs::copy( "bin/librv4rs.a", out_dir.join("librv4rs.a"), ).unwrap(); println!("cargo:rustc-link-...
code_fim
easy
{ "lang": "rust", "repo": "luojia65/librv4rs-example", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("cargo:rustc-link-lib=static=rv4rs"); println!("cargo:rustc-link-search={}", out_dir.display()); println!("cargo:rerun-if-changed=build.rs"); }<|fim_prefix|>// repo: luojia65/librv4rs-example path: /build.rs use std::env; use std::fs; use std::path::PathBuf; fn main() { let out...
code_fim
medium
{ "lang": "rust", "repo": "luojia65/librv4rs-example", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dpogretskiy/pcars2-power-graphs path: /src/app.rs use cars::*; use definitions::*; use ggez::graphics::*; use ggez::*; use graphs::nets::*; use graphs::*; use std; use std::f32; use std::time::Instant; use util::*; const MAGIC_GEAR_RATIO: f32 = 9.534739389568648; const _MAGIC_SPEED: f32 = 0.004...
code_fim
hard
{ "lang": "rust", "repo": "dpogretskiy/pcars2-power-graphs", "path": "/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tyre_rps = tyre_rps_arr.rear_avg().abs(); let ratio = current_rpm_f32 / tyre_rps; let gear_ratio = ratio / MAGIC_GEAR_RATIO; self.stupid_graphs.update( self.current_gear, current_rpm_f32, ...
code_fim
hard
{ "lang": "rust", "repo": "dpogretskiy/pcars2-power-graphs", "path": "/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qxzhou1010/global-data-in-rust path: /build.rs extern crate phf_codegen; extern crate skeptic; use std::env; use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; // Normally you would want to load an external data file instead of defining the map in Rust code fn build_phf()...
code_fim
hard
{ "lang": "rust", "repo": "qxzhou1010/global-data-in-rust", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // generates doc tests for `README.md`. skeptic::generate_doc_tests(&["README.md"]); build_phf(); }<|fim_prefix|>// repo: qxzhou1010/global-data-in-rust path: /build.rs extern crate phf_codegen; extern crate skeptic; use std::env; use std::fs::File; use std::io::{BufWriter, Write}; use std:...
code_fim
hard
{ "lang": "rust", "repo": "qxzhou1010/global-data-in-rust", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { // generates doc tests for `README.md`. skeptic::generate_doc_tests(&["README.md"]); build_phf(); }<|fim_prefix|>// repo: qxzhou1010/global-data-in-rust path: /build.rs extern crate phf_codegen; extern crate skeptic; use std::env; use std::fs::File; use std::io::{BufWriter, Writ...
code_fim
hard
{ "lang": "rust", "repo": "qxzhou1010/global-data-in-rust", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: firstprince/league_of_steel path: /lol-lib/build.rs fn main() { let src_files = std::fs::read_dir("cpp/src") .unwrap() <|fim_suffix|> .include("cpp/inc") .files(src_files) .compile("lollib"); }<|fim_middle|> .map(|f| f.unwrap().path()) .fi...
code_fim
medium
{ "lang": "rust", "repo": "firstprince/league_of_steel", "path": "/lol-lib/build.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>; cc::Build::new() .cpp(true) //.warnings_into_errors(true) .include("cpp/inc") .files(src_files) .compile("lollib"); }<|fim_prefix|>// repo: firstprince/league_of_steel path: /lol-lib/build.rs fn main() { let src_files = std::fs::read_dir("cpp/sr...
code_fim
medium
{ "lang": "rust", "repo": "firstprince/league_of_steel", "path": "/lol-lib/build.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn iter_product() { // Iterates over the entire iterator, multiplying all the elements type Factorial = fn(u32) -> u32; let factorial: Factorial = |n| (1..=n).product(); assert_eq!(factorial(0), 1); assert_eq!(factorial(1), 1); assert_eq!(factorial(5), 120); } #[te...
code_fim
hard
{ "lang": "rust", "repo": "iykekings/rust-iterators", "path": "/src/iter2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iykekings/rust-iterators path: /src/iter2.rs #[cfg(test)] mod test { #[test] fn iter_max_by_key() { // Returns the element that gives the maximum value from the specified function. let a = [-3_i32, 0, 1, 5, -10]; assert_eq!(*a.iter().max_by_key(|x| x.abs()).unwrap(), -10); } ...
code_fim
hard
{ "lang": "rust", "repo": "iykekings/rust-iterators", "path": "/src/iter2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(ref s) = self.super_type() { s.bind_to_tree(tree_in_doc); } self.upcast::<Element>().check_ancestors_disabled_state_for_form_control(); } fn unbind_from_tree(&self, context: &UnbindContext) { self.super_type().unwrap().unbind_from_tree(cont...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/style-servo/components/script/dom/htmllegendelement.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/style-servo/components/script/dom/htmllegendelement.rs // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozi...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/style-servo/components/script/dom/htmllegendelement.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl HTMLLegendElementMethods for HTMLLegendElement { // https://html.spec.whatwg.org/multipage/#dom-legend-form fn GetForm(&self) -> Option<DomRoot<HTMLFormElement>> { let parent = match self.upcast::<Node>().GetParentElement() { Some(parent) => parent, None => re...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/style-servo/components/script/dom/htmllegendelement.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let new_noise = noise.get([1.0, radius_noise as f64]) as f32; let cust_noise = custom_noise(radius_noise); let to_add = cust_noise * 10.0; radius_noise += 0.1; let rad = deg_to_rad(p as f32); let x = radius * rad.sin(); let y = radius * rad.cos(); pt2(x,y) ...
code_fim
hard
{ "lang": "rust", "repo": "sethboyles/nannou_sketches", "path": "/circle_lines_large.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sethboyles/nannou_sketches path: /circle_lines_large.rs use nannou::prelude::*; use nannou::app::Draw; use nannou::geom::*; use core::iter::Map; use std::cell::RefCell; use nannou::noise::*; fn main() { nannou::app(model).update(update).run(); } struct Model { circle_steps: usize, incr...
code_fim
hard
{ "lang": "rust", "repo": "sethboyles/nannou_sketches", "path": "/circle_lines_large.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-embedded/cortex-m path: /cortex-m-rt/examples/pre_init.rs //! `cortex-m-rt` based program with a function run before RAM is initialized. <|fim_suffix|>#[pre_init] unsafe fn disable_watchdog() { // Do what you need to disable the watchdog. } #[entry] fn main() -> ! { loop {} }<|fim...
code_fim
medium
{ "lang": "rust", "repo": "rust-embedded/cortex-m", "path": "/cortex-m-rt/examples/pre_init.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[entry] fn main() -> ! { loop {} }<|fim_prefix|>// repo: rust-embedded/cortex-m path: /cortex-m-rt/examples/pre_init.rs //! `cortex-m-rt` based program with a function run before RAM is initialized. #![deny(warnings)] #![no_main] #![no_std] extern crate cortex_m_rt as rt; extern crate panic_halt; ...
code_fim
medium
{ "lang": "rust", "repo": "rust-embedded/cortex-m", "path": "/cortex-m-rt/examples/pre_init.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanWizard/rust-practice path: /string-methods/src/main.rs fn main() { // replace { let my_string = String::from("Rust is fantastic"); println!("{}", my_string.replace("fantastic", "great")) } // lines { let my_string = String::from("Rust is fantastic\<...
code_fim
hard
{ "lang": "rust", "repo": "DanWizard/rust-practice", "path": "/string-methods/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // char { let my_string = String::from("this is good"); match my_string.chars().nth(3) { Some(c) => println!("at index 4: {}", c), None => println!("not character at 4"), } } }<|fim_prefix|>// repo: DanWizard/rust-practice path: /string-method...
code_fim
hard
{ "lang": "rust", "repo": "DanWizard/rust-practice", "path": "/string-methods/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bascht/binichonline path: /src/lib.rs pub mod ui { extern crate term; use net; pub fn update(state: net::State) { match state { net::State::Online => redraw("Online", term::color::GREEN), net::State::Offline => redraw("Offline", term::color::RED) ...
code_fim
hard
{ "lang": "rust", "repo": "bascht/binichonline", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut t = term::stdout().unwrap(); t.fg(color).unwrap(); writeln!(t, "{:?}", text).unwrap(); let _ = t.reset(); }; } pub fn clear_screen() { println!("\x1b[2J\x1b[1;1H"); } } pub mod net { extern crate curl; extern cra...
code_fim
medium
{ "lang": "rust", "repo": "bascht/binichonline", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut easy = Easy::new(); easy.url(check_target.as_str()).unwrap(); let resp = easy.perform(); match resp { Ok(r) => State::Online, Err(e) => State::Offline } } }<|fim_prefix|>// repo: bascht/binichonline path: /src/lib.rs pub mod ...
code_fim
hard
{ "lang": "rust", "repo": "bascht/binichonline", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: golmman/crawlbot path: /src/model/game_state/message_handler/map_handler/itests/update_map0_test.rs use crate::model::cws::msg::CwsMsg; use crate::model::game_state::GameState; use crate::model::game_state::message_handler::map_handler::itests::utils::*; const RAT_ID: i64 = 2; fn assert_map0(g...
code_fim
medium
{ "lang": "rust", "repo": "golmman/crawlbot", "path": "/src/model/game_state/message_handler/map_handler/itests/update_map0_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // assert cell updates assert_eq!("@", game_state.map.tiles[get_tile_index(58, 52)].glyph); assert_eq!("r", game_state.map.tiles[get_tile_index(61, 52)].glyph); assert_eq!((57, 53), game_state.map.focus); // assert monster updates assert_eq!(1, game_state.map.monsters_visible.len(...
code_fim
hard
{ "lang": "rust", "repo": "golmman/crawlbot", "path": "/src/model/game_state/message_handler/map_handler/itests/update_map0_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if a > b { println!("A diferença entre A e B é: {}", a - b); } else { println!("A diferença entre B e A é: {}", b - a); } }<|fim_prefix|>// repo: brittos/learning-rust path: /estudos/cap03/ex01-diff-biggeest-than-smallest/src/main.rs /** * Exercício 1 - capitulo 3 * Recebe...
code_fim
hard
{ "lang": "rust", "repo": "brittos/learning-rust", "path": "/estudos/cap03/ex01-diff-biggeest-than-smallest/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brittos/learning-rust path: /estudos/cap03/ex01-diff-biggeest-than-smallest/src/main.rs /** * Exercício 1 - capitulo 3 * Receber dois i64 <a> e <b> e retornar o resultado da diferença do maior pelo menor * */ use std::io; use std::io::prelude::*; fn main() { <|fim_suffix|> println!("Ent...
code_fim
hard
{ "lang": "rust", "repo": "brittos/learning-rust", "path": "/estudos/cap03/ex01-diff-biggeest-than-smallest/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_nstring() { let s = NullTerminatedString::new(b"Test".as_bstr()); assert_eq!(s.data_size(), 5); let mut data = Vec::new(); data.reserve(5); s.write_to(&mut data).unwrap(); assert_eq!(data.dat...
code_fim
hard
{ "lang": "rust", "repo": "MinusGix/Vivec", "path": "/src/records/common/null_terminated_string.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MinusGix/Vivec path: /src/records/common/null_terminated_string.rs use super::BStrw; use crate::{ parse::{tag, take_until, PResult, Parse}, util::{DataSize, Writable}, }; use bstr::{BStr, ByteSlice}; /// Null-terminated-string #[derive(Debug, Clone, Eq, PartialEq)] pub struct NullTermin...
code_fim
hard
{ "lang": "rust", "repo": "MinusGix/Vivec", "path": "/src/records/common/null_terminated_string.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.value.len() + 0x00u8.data_size() } } impl<'data> Writable for NullTerminatedString<'data> { fn write_to<T>(&self, w: &mut T) -> std::io::Result<()> where T: std::io::Write, { self.value.write_to(w)?; 0x00u8.write_to(w) } } #[cfg(test)] mod tests { ...
code_fim
hard
{ "lang": "rust", "repo": "MinusGix/Vivec", "path": "/src/records/common/null_terminated_string.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn bar(_a: &i32, _b: &i32) { let _c = 5; let d = Box::new(5); let e = &d; baz(e); } fn baz(_f: &i32) { let _g = 100; } fn fake_main4() { let h = 3; let _i = Box::new(20); let j = &h; foo4(j); }<|fim_prefix|>// repo: grodwar/Hello_rust path: /src/understand_borrow/h...
code_fim
hard
{ "lang": "rust", "repo": "grodwar/Hello_rust", "path": "/src/understand_borrow/heap_and_stack.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //////// the HEAP //Sometimes, you need to pass some memory between different functions, or keep it alive for longer // than a single function’s execution. For this, we can use the heap. fn fake_main2() { let _x = Box::new(5); let _y = 42; // We allocate space for two variables on the stack. y ...
code_fim
hard
{ "lang": "rust", "repo": "grodwar/Hello_rust", "path": "/src/understand_borrow/heap_and_stack.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: grodwar/Hello_rust path: /src/understand_borrow/heap_and_stack.rs #![allow(dead_code)] //////// the STACK // NB underscored the variable names to get rid of the warnings fn foo(){ let _y = 5; let _z = 100; } fn italic() { let _i = 6; } fn bold() { let _a = 5; let _b = 100;...
code_fim
hard
{ "lang": "rust", "repo": "grodwar/Hello_rust", "path": "/src/understand_borrow/heap_and_stack.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: project-ela/elfen path: /src/reader.rs use header::Header; use rel::Rela; use section::{Section, SectionData}; use segment::ProgramHeader; use strtab::Strtab; use symbol::Symbol; use tse::Tse; use crate::{elf::Elf, section::SectionHeader, *}; use std::fs; impl Elf { pub fn read_from_file(p...
code_fim
hard
{ "lang": "rust", "repo": "project-ela/elfen", "path": "/src/reader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match header.get_type() { section::Type::Null => SectionData::None, section::Type::Rela => { let relas = Self::read_entries::<Rela>(data, header.entry_size as usize); SectionData::Rela(relas) } section::Type::Strtab =>...
code_fim
hard
{ "lang": "rust", "repo": "project-ela/elfen", "path": "/src/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: djallen89/nesapod path: /src/nesapod.rs use sdl2; use sdl2::pixels::{Color, PixelFormatEnum}; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::render::{Canvas, TextureCreator, TextureAccess}; use sdl2::video::Window; use find_folder; use std; use std::time::Duration; use std::thre...
code_fim
hard
{ "lang": "rust", "repo": "djallen89/nesapod", "path": "/src/nesapod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let raw_img = self.core.print_screen(); match texture.update(None, &mut raw_img.as_slice(), 3 * 256) { Ok(_) => {}, Err(f) => panic!(f) } match canvas.with_texture_canvas(&mut texture, |texture_canvas| { //texture_canvas.set_draw_color(C...
code_fim
hard
{ "lang": "rust", "repo": "djallen89/nesapod", "path": "/src/nesapod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/codegen/transmute-optimized.rs // compile-flags: -O -Z merge-functions=disabled // ignore-debug #![crate_type = "lib"] // This tests that LLVM can optimize based on the niches in the source or // destination types for transmutes. #[repr(u32)] pub enum AlwaysZero32 ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/codegen/transmute-optimized.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[repr(i8)] pub enum OneTwoThree { One = 1, Two = 2, Three = 3 } // CHECK-LABEL: i8 @ordering_transmute_onetwothree(i8 #[no_mangle] pub unsafe fn ordering_transmute_onetwothree(x: std::cmp::Ordering) -> OneTwoThree { // CHECK: ret i8 1 std::mem::transmute(x) } // CHECK-LABEL: i8 @onetwothree_tra...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/codegen/transmute-optimized.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// The max number of days per period. #[structopt(long = "days", short = "d", default_value = "90")] max_days: i64, /// The number of days in a period #[structopt(long = "length", short = "l", default_value = "1")] length: i64, }, // TODO: Add `che...
code_fim
hard
{ "lang": "rust", "repo": "liamgriffiths/visits", "path": "/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liamgriffiths/visits path: /src/cli.rs use chrono::{format::ParseError, NaiveDate}; use structopt::StructOpt; #[derive(StructOpt, Debug)] #[structopt(name = "visits", about = "counting days")] pub enum Cli { /// Adds a visit to your log #[structopt(name = "add")] Add { #[str...
code_fim
hard
{ "lang": "rust", "repo": "liamgriffiths/visits", "path": "/src/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn sequential_test() -> Result<(), reqwest::Error> { let mut responses = Vec::new(); for _ in 0..NUM_REQUESTS { responses.push(reqwest::blocking::get(BASE_URL)?); } for resp in responses.into_iter() { assert_eq!(resp.status(), reqwest::StatusCode::OK); } Ok(...
code_fim
hard
{ "lang": "rust", "repo": "fkettelhoit/cf-worker-rust-hanging-promise", "path": "/tests/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fkettelhoit/cf-worker-rust-hanging-promise path: /tests/client.rs //! Test suite for calling the worker from a client #![cfg(not(target_arch = "wasm32"))] use futures::future::try_join_all; // Depends on running `wrangler dev` to start a worker on localhost. // The tests will (usually) fail ...
code_fim
medium
{ "lang": "rust", "repo": "fkettelhoit/cf-worker-rust-hanging-promise", "path": "/tests/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: romatthe/doukutsu-rs path: /src/npc/sue.rs use std::cell::RefCell; use std::collections::HashMap; use crate::common::Direction; use crate::ggez::GameResult; use crate::npc::{NPC, NPCMap}; use crate::player::Player; use crate::shared_game_state::SharedGameState; use num_traits::clamp; impl NPC ...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/doukutsu-rs", "path": "/src/npc/sue.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.direction = npc.direction.opposite(); self.x = npc.x + npc.direction.vector_x() * 6 * 0x200; self.y = npc.y + 4 * 0x200; if npc.anim_num == 2 || npc.anim_num == 4 { self.y -= 0x200; ...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/doukutsu-rs", "path": "/src/npc/sue.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cssivision/envoy-wasm-rust-sdk path: /envoy-sdk/src/host/stream_info/property.rs path: Path { inner: PathKind::Static(&["request", "path"]), }, _type: PhantomData, _proxy_wasm_type: PhantomData, }; /// The path portion of the URL without the ...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/envoy-wasm-rust-sdk", "path": "/envoy-sdk/src/host/stream_info/property.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Upstream connection remote port. pub const PORT: &'static Property<'static, u32, proxy_wasm::types::Int64> = &Property { path: Path { inner: PathKind::Static(&["upstream", "port"]), }, _type: PhantomData, _proxy_wasm_type: PhantomData, }; //...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/envoy-wasm-rust-sdk", "path": "/envoy-sdk/src/host/stream_info/property.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// The first DNS entry in the SAN field of the local certificate in the upstream TLS connection. pub const DNS_SAN_LOCAL_CERTIFICATE: &'static Property< 'static, String, proxy_wasm::types::ByteString, > = &Property { path: Path { inner: PathKind::St...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/envoy-wasm-rust-sdk", "path": "/envoy-sdk/src/host/stream_info/property.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>bits >> 1) & 0x01) != 0) } #[doc = "Bit 2 - P3OUT2"] #[inline(always)] pub fn p3out2(&self) -> P3OUT2_R { P3OUT2_R::new(((self.bits >> 2) & 0x01) != 0) } #[doc = "Bit 3 - P3OUT3"] #[inline(always)] pub fn p3out3(&self) -> P3OUT3_R { P3OUT3_R::new(((self.bits...
code_fim
hard
{ "lang": "rust", "repo": "stianeklund/msp430fr4133", "path": "/src/port_3_4/p3out.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stianeklund/msp430fr4133 path: /src/port_3_4/p3out.rs #[doc = "Reader of register P3OUT"] pub type R = crate::R<u8, super::P3OUT>; #[doc = "Writer for register P3OUT"] pub type W = crate::W<u8, super::P3OUT>; #[doc = "Register P3OUT `reset()`'s with value 0"] impl crate::ResetValue for super::P3...
code_fim
hard
{ "lang": "rust", "repo": "stianeklund/msp430fr4133", "path": "/src/port_3_4/p3out.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let bin = args.value_of("ELFBIN").unwrap(); let target = Path::new(args.value_of("TARGET").unwrap_or("target/docker")); fs::create_dir_all(target).unwrap(); let mut manifest = Manifest::new(); manifest.include(bin.as_ref()); for p in &manifest.paths { let path = Path::new...
code_fim
hard
{ "lang": "rust", "repo": "softprops/elfpack", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: softprops/elfpack path: /src/main.rs extern crate clap; extern crate elfpack; extern crate regex; extern crate users; use std::fs; use std::path::Path; use elfpack::Manifest; use clap::App; fn main() { let args = App::new("elfpack") .version(env!("CARGO_PKG_VERSION")) .abou...
code_fim
hard
{ "lang": "rust", "repo": "softprops/elfpack", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> -> Result<$name, D::Error> { ::rustc_serialize::Decodable::decode(d).map($name) } } } }<|fim_prefix|>// repo: brabadu/vagga path: /src/macros.rs #[macro_export] macro_rules! try_msg { ($op:expr, $message:expr) => ( try!(($op)...
code_fim
medium
{ "lang": "rust", "repo": "brabadu/vagga", "path": "/src/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brabadu/vagga path: /src/macros.rs #[macro_export] macro_rules! try_msg { ($op:expr, $message:expr) => ( try!(($op) .map_err(|e| format!($message, err=e))) ); ($op:expr, $message:expr, $($key:ident=$value:expr),*) => ( try!(($op) .map_err(|e|...
code_fim
medium
{ "lang": "rust", "repo": "brabadu/vagga", "path": "/src/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn test_decrypt( paths: &[&Path], nonfile_args: &[&str], input: Option<String>, add_ext: bool, ) -> String { let mut args = vec![ "run".to_owned(), "--release".to_owned(), "--bin".to_owned(), "filedec".to_owned(), "--".to_owned(), ]; ...
code_fim
hard
{ "lang": "rust", "repo": "mverleg/file_endec", "path": "/src/util/test_cmd.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mverleg/file_endec path: /src/util/test_cmd.rs #![cfg(test)] use ::std::ffi::OsStr; use ::std::io::Write; use ::std::path::Path; use ::std::path::PathBuf; use ::std::process::Command; use ::std::process::Stdio; use ::std::str::from_utf8; pub fn test_cmd<I, S>(args: I, input: Option<String>) ->...
code_fim
hard
{ "lang": "rust", "repo": "mverleg/file_endec", "path": "/src/util/test_cmd.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>001 != 0; let wasm = &data[3..]; if log::log_enabled!(log::Level::Debug) { log::debug!("writing input to `test.wasm`"); std::fs::write("test.wasm", wasm).unwrap(); } if use_maybe_invalid { let mut u = Unstructured::new(wasm); if let Ok(module) = MaybeInvali...
code_fim
hard
{ "lang": "rust", "repo": "Horki/wasm-tools", "path": "/fuzz/fuzz_targets/validate.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Horki/wasm-tools path: /fuzz/fuzz_targets/validate.rs #![no_main] use arbitrary::{Arbitrary, Unstructured}; use libfuzzer_sys::*; use wasm_smith::MaybeInvalidModule; use wasmparser::{Validator, WasmFeatures}; fuzz_target!(|data: &[u8]| { drop(env_logger::try_init()); let byte1 = match ...
code_fim
hard
{ "lang": "rust", "repo": "Horki/wasm-tools", "path": "/fuzz/fuzz_targets/validate.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/css/selector/combinator/trailing.rs //! Tests auto-converted from "sass-spec/spec/css/selector/combinator/trailing.hrx" <|fim_suffix|> assert_eq!(runner().ok("a + ~ {b: c}\n"), ""); } } mod single { #[allow(unused)] use super::runner; #[...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/css/selector/combinator/trailing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn child() { assert_eq!(runner().ok("a > {b: c}\n"), ""); } #[test] fn next_sibling() { assert_eq!(runner().ok("a + {b: c}\n"), ""); } #[test] fn sibling() { assert_eq!(runner().ok("a ~ {b: c}\n"), ""); } }<|fim_prefix|>// repo: kaj/rsass...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/css/selector/combinator/trailing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexmeli100/psychedelic_image_generator path: /src/generator/image_generator.rs use crate::generator::funcs::*; use std::f64; use image::{ImageBuffer, RgbImage}; use std::path::Path; pub struct ImageGenerator { img: RgbImage, dims: (usize, usize), red_exp: Box<dyn EvalFunc>, gr...
code_fim
medium
{ "lang": "rust", "repo": "alexmeli100/psychedelic_image_generator", "path": "/src/generator/image_generator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..w*h { let y_coord = i / w; let x_coord = i % w; let y = (y_coord as isize - ppu as isize) as f64 / ppu as f64; let x = -(x_coord as isize - ppu as isize) as f64 / ppu as f64; let z = exp.eval(x, y); let intensity = (z * 127.5 + 127.5) as u8;...
code_fim
hard
{ "lang": "rust", "repo": "alexmeli100/psychedelic_image_generator", "path": "/src/generator/image_generator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MrJohz/re-redis path: /tests/test_sync_incr_commands.rs #![cfg(feature = "sync-client")] extern crate reredis; mod utils; use reredis::commands::*; use crate::utils::load_redis_instance; use quickcheck_macros::quickcheck; #[quickcheck] fn qc_incr_by_can_increment_a_key_by_an_arbitrary_intege...
code_fim
hard
{ "lang": "rust", "repo": "MrJohz/re-redis", "path": "/tests/test_sync_incr_commands.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(-1, client.issue(decr("my-key")).unwrap()); assert_eq!(Some(-1), client.issue(get("my-key")).unwrap()); } #[quickcheck] fn qc_decr_can_decrement_a_key_by_1_an_arbitrary_number_of_times(n: u32) { let server = load_redis_instance(); let mut client = reredis::SyncClient::new(serve...
code_fim
hard
{ "lang": "rust", "repo": "MrJohz/re-redis", "path": "/tests/test_sync_incr_commands.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: teervo/soi path: /src/traits/path_to_uri.rs use std::path::Path; /// This trait allows for easy conversion of a path to a URI pub trait PathToURI { fn to_uri(&self) -> String; <|fim_suffix|> glib::filename_to_uri(self, None) .expect("Error converting path to URI") ...
code_fim
medium
{ "lang": "rust", "repo": "teervo/soi", "path": "/src/traits/path_to_uri.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> glib::filename_to_uri(self, None) .expect("Error converting path to URI") .to_string() } }<|fim_prefix|>// repo: teervo/soi path: /src/traits/path_to_uri.rs use std::path::Path; /// This trait allows for easy conversion of a path to a URI pub trait PathToURI { fn ...
code_fim
medium
{ "lang": "rust", "repo": "teervo/soi", "path": "/src/traits/path_to_uri.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: irqlevel/echo path: /app/src/client/main.rs use tokio::io::{AsyncWriteExt}; use std::env; use std::error::Error; use log::{error, info, LevelFilter}; extern crate common_lib; use common_lib::frame::frame::{Request, Response, EchoRequest, EchoResponse}; use common_lib::error::error::CommonErr...
code_fim
hard
{ "lang": "rust", "repo": "irqlevel/echo", "path": "/app/src/client/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match log::set_logger(&LOGGER) .map(|()| log::set_max_level(LevelFilter::Info)) { Ok(()) => {}, Err(e) => { println!("set_logger error {}", e); return Err("set_logger error".into()) } } info!("starting"); let mut handles = vec![]; ...
code_fim
hard
{ "lang": "rust", "repo": "irqlevel/echo", "path": "/app/src/client/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Saruniks/yewprint path: /yewprint-doc/src/numeric_input/example.rs use yew::prelude::*; use yewprint::{Button, IconName, NumericInput}; pub struct Example { props: ExampleProps, link: ComponentLink<Self>, value: i32, value_two: i32, } #[derive(Clone, PartialEq, Properties)] pub...
code_fim
hard
{ "lang": "rust", "repo": "Saruniks/yewprint", "path": "/yewprint-doc/src/numeric_input/example.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> html! { <> <NumericInput<i32> disabled=self.props.disabled fill=self.props.large value=self.value_two bounds=i32::MIN..=i32::MAX increment=10 placeholder=String::from("Enter an i...
code_fim
hard
{ "lang": "rust", "repo": "Saruniks/yewprint", "path": "/yewprint-doc/src/numeric_input/example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cecton/gptman path: /src/lib.rs /// An error that occurs when there are partitions with the same GUID in the same array. #[error("conflict of partition GUIDs")] ConflictPartitionGUID, /// An error that occurs when a partition has an invalid boundary. /// /// The end sector mu...
code_fim
hard
{ "lang": "rust", "repo": "cecton/gptman", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cecton/gptman path: /src/lib.rs [0xff; 16]) /// .expect("could not create partition table"); /// /// gpt[1] = gptman::GPTPartitionEntry::empty(); /// /// // NOTE: an empty partition entry is considered as not allocated /// assert!(gpt[1].is_unused()); /// ``` ...
code_fim
hard
{ "lang": "rust", "repo": "cecton/gptman", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut partitions = Vec::with_capacity(header.number_of_partition_entries as usize); for i in 0..header.number_of_partition_entries { reader.seek(SeekFrom::Start( header.partition_entry_lba * sector_size + u64::from(i) * u64::from(header.siz...
code_fim
hard
{ "lang": "rust", "repo": "cecton/gptman", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl JsonStatusResponse { pub fn new(ret_val: Result<String, Error>) -> Result<Json<JsonStatusResponse>, Error> { let res_string = match ret_val { Ok(msg) => msg.clone(), Err(e) => format!("{}", e), }; Ok(Json(JsonStatusResponse { response: ...
code_fim
hard
{ "lang": "rust", "repo": "patchedsoul/althea_rs", "path": "/rita/src/rita_common/network_endpoints/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn hello_response( req: (Json<LocalIdentity>, HttpRequest), ) -> Box<dyn Future<Item = Json<LocalIdentity>, Error = Error>> { let their_id = *req.0; let err_mesg = "Malformed hello tcp packet!"; let socket = match req.1.connection_info().remote() { Some(val) => match val.parse...
code_fim
hard
{ "lang": "rust", "repo": "patchedsoul/althea_rs", "path": "/rita/src/rita_common/network_endpoints/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: patchedsoul/althea_rs path: /rita/src/rita_common/network_endpoints/mod.rs //! Network endptoints for common Rita functionality (such as exchanging hello messages) use althea_types::{LocalIdentity, PaymentTx}; use ::actix::registry::SystemService; use actix_web::http::StatusCode; use actix_web...
code_fim
hard
{ "lang": "rust", "repo": "patchedsoul/althea_rs", "path": "/rita/src/rita_common/network_endpoints/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/twitchchat path: /src/runner/mod.rs //! A set of runners for managing a `event loop` //! //! To use the [`AsyncRunner`][async_runner]: //! 1. choose [`Connector`][connector] from [`connectors`][connectors]. //! 1. create a [`UserConfig`][user_config]. //! 1. create and connect the [`Asyn...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/twitchchat", "path": "/src/runner/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Intreprets this array as a mutable slice. pub fn as_mut_slice(&mut self) -> NibSliceAlignedMut { if self.has_right_lo { NibSliceAlignedMut::Even(unsafe { &mut *(&mut self.inner[..] as *mut [u4x2] as *mut NibSliceFull) }) } else { NibSliceAlignedMut::Odd(...
code_fim
hard
{ "lang": "rust", "repo": "clarfonthey/nibble", "path": "/src/vec.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clarfonthey/nibble path: /src/vec.rs //! Types for arrays of nibbles. use std::{slice as stdslice, mem}; use base::{u4lo, u4}; use pair::u4x2; use slice::{self, NibSliceAligned, NibSliceAlignedMut, NibSliceFull, NibSliceNoR}; use common::{get_nib, set_nib, shift_left, shift_right}; /// A `Vec` ...
code_fim
hard
{ "lang": "rust", "repo": "clarfonthey/nibble", "path": "/src/vec.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }