text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> fmt.write_str(&self.to_rfc3339()) } } impl<'x> MessageStream<'x> { pub fn parse_date(&mut self) -> HeaderValue<'x> { let mut pos = 0; let mut parts = [0u32; 7]; let mut parts_sizes = [ 2u32, // Day (0) 2u32, // Month (1) 4u32, //...
code_fim
hard
{ "lang": "rust", "repo": "stalwartlabs/mail-parser", "path": "/src/parsers/fields/date.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rhysormond/vcrs path: /src/subcommand/log.rs use crate::object::Object; use crate::reference::Reference; use crate::repository::Repository; pub fn log(object: Option<String>) { let head = object.unwrap_or("HEAD".to_string()); let reference = Reference::from_name(head.as_str()); let ...
code_fim
hard
{ "lang": "rust", "repo": "rhysormond/vcrs", "path": "/src/subcommand/log.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>; commit_obj.parent } _ => panic!("Commit parent was not a commit."), } } None => return (), }; } }<|fim_prefix|>// repo: rhysormond/vcrs path: /src/subcommand/log.rs use crate::object::Obj...
code_fim
hard
{ "lang": "rust", "repo": "rhysormond/vcrs", "path": "/src/subcommand/log.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[export] fn _entered_stellar_object(&mut self, _owner: OwnerNode, _entered: Area2D) { godot_print!("over stellar object"); } }<|fim_prefix|>// repo: mockersf/testactionsclangdll path: /game/src/stellar_object.rs use gdnative::*; use helpers::stringify_fn; type OwnerNode = Area2D; ...
code_fim
hard
{ "lang": "rust", "repo": "mockersf/testactionsclangdll", "path": "/game/src/stellar_object.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let target = owner; owner .connect( helpers::Signal::AreaEntered.into(), Some(target.to_object()), stringify_fn!(Self, _entered_stellar_object), VariantArray::new(), ...
code_fim
hard
{ "lang": "rust", "repo": "mockersf/testactionsclangdll", "path": "/game/src/stellar_object.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mockersf/testactionsclangdll path: /game/src/stellar_object.rs use gdnative::*; use helpers::stringify_fn; type OwnerNode = Area2D; #[derive(NativeClass)] #[inherit(OwnerNode)] pub struct StellarObject {} unsafe impl Send for StellarObject {} <|fim_suffix|> #[export] fn _entered_stel...
code_fim
hard
{ "lang": "rust", "repo": "mockersf/testactionsclangdll", "path": "/game/src/stellar_object.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Make the camera follow the player if let Some(ref player) = game_state.player { self.camera_position = player.position; // TODO: Make the camera movable around the player self.camera_position[2] -= 1f32; self.camera_rotation = player.rotation; } self.view = fps_view_matrix(sel...
code_fim
hard
{ "lang": "rust", "repo": "VictorKoenders/rust_game", "path": "/client/src/render.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VictorKoenders/rust_game path: /client/src/render.rs use glium::{DisplayBuild, Program, DrawParameters, Depth}; use glium::draw_parameters::DepthTest; use glium::backend::glutin_backend::{GlutinFacade, WinRef}; use glium::glutin::{ WindowBuilder, CursorState }; use std::f32::consts; use game_sta...
code_fim
hard
{ "lang": "rust", "repo": "VictorKoenders/rust_game", "path": "/client/src/render.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aajtodd/tokio-more path: /tests/length_delimited.rs extern crate futures; extern crate tokio_more; extern crate bytes; extern crate fixture_io; use tokio_more::codec::length_delimited::*; use futures::{Stream, Sink, Future}; use bytes::BytesMut; use fixture_io::FixtureIo; use std::io; use std::...
code_fim
hard
{ "lang": "rust", "repo": "aajtodd/tokio-more", "path": "/tests/length_delimited.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let chunks = collect(io).unwrap(); assert_eq!(chunks, bytes(&[b"abcdefghi", b"123", b"hello world"])); } #[test] pub fn single_frame_multi_packet() { let io = FixtureIo::empty() .then_read(&b"\x00\x00"[..]) .then_read(&b"\x00\x09abc"[..]) .then_read(&b"defghi"[..]) ...
code_fim
hard
{ "lang": "rust", "repo": "aajtodd/tokio-more", "path": "/tests/length_delimited.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ju6ge/atsame70q21 path: /src/pioa/pio_driver.rs IGH_DRIVE } } #[doc = "Write proxy for field `LINE18`"] pub struct LINE18_W<'a> { w: &'a mut W, } impl<'a> LINE18_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: LINE18_A) -> &'a...
code_fim
hard
{ "lang": "rust", "repo": "ju6ge/atsame70q21", "path": "/src/pioa/pio_driver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ju6ge/atsame70q21 path: /src/pioa/pio_driver.rs Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> LINE3_A { match self.bits { false => LINE3_A::LOW_DRIVE, true => LINE3_A::HIGH_DRIVE, } } #[doc = "Checks if the valu...
code_fim
hard
{ "lang": "rust", "repo": "ju6ge/atsame70q21", "path": "/src/pioa/pio_driver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match variant { LINE20_A::LOW_DRIVE => false, LINE20_A::HIGH_DRIVE => true, } } } #[doc = "Reader of field `LINE20`"] pub type LINE20_R = crate::R<bool, LINE20_A>; impl LINE20_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn var...
code_fim
hard
{ "lang": "rust", "repo": "ju6ge/atsame70q21", "path": "/src/pioa/pio_driver.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: allthatjazzleo/ibc-solo-machine path: /solo-machine-core/src/cosmos/crypto/secp256k1.rs use std::convert::TryFrom; use anyhow::{Context, Error}; use k256::ecdsa::VerifyingKey; use crate::proto::cosmos::crypto::secp256k1::PubKey as Secp256k1PubKey; <|fim_suffix|> fn try_from(value: &Secp256...
code_fim
hard
{ "lang": "rust", "repo": "allthatjazzleo/ibc-solo-machine", "path": "/solo-machine-core/src/cosmos/crypto/secp256k1.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /* returns winning token */ pub fn play(&mut self) -> usize { if game_is_over(&self.board) { return get_winner(&self.board) } else { let space = self.player_one.get_move(self.board.clone()); self.board.set_space(space, self.player_one.get_token()...
code_fim
hard
{ "lang": "rust", "repo": "davetttt/ttt_rust", "path": "/src/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davetttt/ttt_rust path: /src/game.rs use super::player::*; use super::board::*; use super::rules::*; pub struct Game<P1: Player, P2: Player> { board: Board, player_one: P1, player_two: P2, } <|fim_suffix|> /* returns winning token */ pub fn play(&mut self) -> usize { ...
code_fim
hard
{ "lang": "rust", "repo": "davetttt/ttt_rust", "path": "/src/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mglunafh/hello-rust path: /src/sorts/bubble-sort.rs fn bubble_sort(arr: &mut[i32]) { for i in 0..arr.len() { for j in i..arr.len() - 1 { if arr[j] > arr[j + 1] { let t = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = t; ...
code_fim
medium
{ "lang": "rust", "repo": "mglunafh/hello-rust", "path": "/src/sorts/bubble-sort.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..arr.len() { let mut ind = i; for j in i+1..arr.len() { if arr[ind] > arr[j] { ind = j; } } let t = arr[i]; arr[i] = arr[ind]; arr[ind] = t } } fn main() { let mut arr = [3, 14, 92, 9, 59, 14, 8...
code_fim
medium
{ "lang": "rust", "repo": "mglunafh/hello-rust", "path": "/src/sorts/bubble-sort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakobwesthoff/twitter_comic_streamer path: /server/src/layout.rs use std::sync::Arc; use cassowary::strength::{MEDIUM, REQUIRED, STRONG}; use cassowary::WeightedRelation::*; use cassowary::{Solver, Variable}; use crate::comic_image::ComicImage; const MAX_WIDTH: f64 = 1200.0; const MAX_HEIGHT:...
code_fim
hard
{ "lang": "rust", "repo": "jakobwesthoff/twitter_comic_streamer", "path": "/server/src/layout.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Horizontal end of primary and secondary is identical let last_secondary = secondary_boxes.last().unwrap(); solver .add_constraint( primary_box.x + primary_box.w | EQ(REQUIRED) | last_secondary.x + last_secondary.w, ) .unwrap(); // Vertical margin between prima...
code_fim
hard
{ "lang": "rust", "repo": "jakobwesthoff/twitter_comic_streamer", "path": "/server/src/layout.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("I take ownership of {}", s); } fn make_copy(n: i32) { println!("I simply made a copy of {}", n); } // returning functions give their ownership // or bring ownership to another thread fn give_ownership() -> String { let s = String::from("I give myself to you"); return s; } fn ...
code_fim
hard
{ "lang": "rust", "repo": "Xerenz/learning-rust", "path": "/ownership/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn return_string_and_length(s: String) -> (String, usize) { let len: usize = s.len(); // should always be usize return (s, len); } // using referencing fn get_length(s: &String) -> usize { s.len() } // mutable referencing fn modify_string(s: &mut String) { s.push_str(", this new string g...
code_fim
hard
{ "lang": "rust", "repo": "Xerenz/learning-rust", "path": "/ownership/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xerenz/learning-rust path: /ownership/src/main.rs fn main() { // immutable data types reside in stack let x = 5; let y = x; // incase of stack allocation full data is copied let s1 = "hello"; let s2 = s1; // using String let s3 = String::from("hello again"); /...
code_fim
hard
{ "lang": "rust", "repo": "Xerenz/learning-rust", "path": "/ownership/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ncoif/advent-2017 path: /src/day12.rs use nom::types::CompleteStr; use nom::{do_parse, map_res, named, separated_nonempty_list, tag}; use std::collections::HashSet; pub fn title() -> &'static str { "Day 12: Digital Plumber" } named!( id_parser<CompleteStr, u32>, map_res!(nom::digit...
code_fim
hard
{ "lang": "rust", "repo": "ncoif/advent-2017", "path": "/src/day12.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> neighbours } pub fn answer1(input: &str) -> usize { let pipes = parse_input(&input); let neighbours = neighbours(&pipes); // https://docs.rs/pathfinding/1.1.10/pathfinding/undirected/connected_components/fn.components.html let groups = pathfinding::undirected::connected_components::c...
code_fim
hard
{ "lang": "rust", "repo": "ncoif/advent-2017", "path": "/src/day12.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn tt_ownership0(s : String) { println!("holded here: {}", s); } fn take_and_give_back(s : String) -> String { return s; }<|fim_prefix|>// repo: julian0zzx/rpl path: /chapter4_ownership/main.rs mod bnr; mod slc; /// drop, copy, clone, fn main() { tt_scope0(); tt_scope1(); tt_scope...
code_fim
hard
{ "lang": "rust", "repo": "julian0zzx/rpl", "path": "/chapter4_ownership/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: julian0zzx/rpl path: /chapter4_ownership/main.rs mod bnr; mod slc; /// drop, copy, clone, fn main() { tt_scope0(); tt_scope1(); tt_scope2(); let s = String::from("helloo"); tt_ownership0(s); // take s // println!("here: {} ?", s); // s is moved let s = String::fr...
code_fim
hard
{ "lang": "rust", "repo": "julian0zzx/rpl", "path": "/chapter4_ownership/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn create_schema() -> Schema { Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()) }<|fim_prefix|>// repo: dtrain157/rust-graphql-example path: /src/graphql/schema/mod.rs mod member; mod query; use crate::Context; use juniper::{EmptyMutation, EmptySubscription, RootNode}; pub use ...
code_fim
medium
{ "lang": "rust", "repo": "dtrain157/rust-graphql-example", "path": "/src/graphql/schema/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtrain157/rust-graphql-example path: /src/graphql/schema/mod.rs mod member; mod query; use crate::Context; use juniper::{EmptyMutation, EmptySubscription, RootNode}; pub use member::*; use query::*; <|fim_suffix|>pub fn create_schema() -> Schema { Schema::new(Query, EmptyMutation::new(), E...
code_fim
medium
{ "lang": "rust", "repo": "dtrain157/rust-graphql-example", "path": "/src/graphql/schema/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 'services: loop { let next_check = SteadyTime::now() + TimeDuration::milliseconds(1000); // Check for incoming signals. // // This takes signals passed to `hab-sup` and either shuts down all the services, or // passes the signals through....
code_fim
hard
{ "lang": "rust", "repo": "seth/habitat", "path": "/components/sup/src/manager/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Write out any service configuration we received via butterfly let mut service_config_updated = false; if let Some((incarnation, config)) = self.state .butterfly .service_config_for(&servi...
code_fim
hard
{ "lang": "rust", "repo": "seth/habitat", "path": "/components/sup/src/manager/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seth/habitat path: /components/sup/src/manager/mod.rs .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.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in wr...
code_fim
hard
{ "lang": "rust", "repo": "seth/habitat", "path": "/components/sup/src/manager/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sjbeskur/snmplib path: /src/snmp.rs #![allow(dead_code)] //, identity_op, eq_op)] use super::asn1; use super::varbinds::*; use super::asnreader::AsnReader; use super::{ SnmpResult, SnmpError} ; pub const VERSION_2: i64 = 1; pub const MSG_GET: u8 = asn1::CLASS_CONTEXTSPECIFIC | asn1::C...
code_fim
hard
{ "lang": "rust", "repo": "sjbeskur/snmplib", "path": "/src/snmp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct SnmpPdu<'a> { version: i64, pub community: &'a [u8], pub message_type: SnmpMessageType, pub req_id: i32, pub error_status: u32, pub error_index: u32, pub varbinds: Varbinds<'a>, } impl<'a> SnmpPdu<'a> { pub fn from_bytes(bytes: &'a [u8]) -> Snmp...
code_fim
hard
{ "lang": "rust", "repo": "sjbeskur/snmplib", "path": "/src/snmp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut response_pdu = AsnReader::from_bytes(rdr.read_raw(ident)?); let req_id = response_pdu.read_asn_integer()?; if req_id < i32::min_value() as i64 || req_id > i32::max_value() as i64 { return Err(SnmpError::ValueOutOfRange); } let error_status = re...
code_fim
hard
{ "lang": "rust", "repo": "sjbeskur/snmplib", "path": "/src/snmp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ktossell/rust-sdp path: /src/lib.rs #![feature(box_syntax, unboxed_closures, ip_addr)] use std::fmt; use std::str::FromStr; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; #[derive(Clone, Debug)] pub struct Origin { pub username: String, pub session_id: String, pub session_version: i64,...
code_fim
hard
{ "lang": "rust", "repo": "ktossell/rust-sdp", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.protocol_version { Some(ref v) => try!(write!(f, "v={}\n", v)), None => {} }; match self.origin { Some(ref o) => { try!(write!(f, "o={} {} {} ", o.username, o.session_id, o.session_version)); match o.ip...
code_fim
hard
{ "lang": "rust", "repo": "ktossell/rust-sdp", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charpercyr/chos path: /lib/chos-lib/src/pod.rs /// This trait is implemented for types with no destructor, and for which all bit patterns are valid. /// Implementing this trait also means that MaybeUninit<T> and T are equivalent types. pub unsafe trait Pod: Copy {} macro pod($($ty:ident),* $(,...
code_fim
medium
{ "lang": "rust", "repo": "charpercyr/chos", "path": "/lib/chos-lib/src/pod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pod!( u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, char, bool, ); unsafe impl<T: ?Sized> Pod for *const T {} unsafe impl<T: ?Sized> Pod for *mut T {} macro pod_tuple($([$($name:ident),* $(,)?]),* $(,)?) { $( unsafe impl<$($name: Pod,)*> Pod for ($($name,)*) {} ...
code_fim
medium
{ "lang": "rust", "repo": "charpercyr/chos", "path": "/lib/chos-lib/src/pod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut level = 0; let direction: Vec<i32> = vec![-1, 0, 1, 0, -1]; while points.len() > 0 { level += 1; let mut cur_level_size = points.len(); while cur_level_size > 0 { cur_level_size -= 1; let (x, y) = points.remove(0); for i in 0....
code_fim
hard
{ "lang": "rust", "repo": "suclogger/leetcode-rust", "path": "/chapter_6/shortest-bridge/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suclogger/leetcode-rust path: /chapter_6/shortest-bridge/src/main.rs fn main() { assert_eq!(1, shortest_bridge(vec![vec![0,1],vec![1,0]])); assert_eq!(2, shortest_bridge(vec![vec![0,1,0],vec![0,0,0],vec![0,0,1]])); assert_eq!(1, shortest_bridge(vec![vec![1,1,1,1,1],vec![1,0,0,0,1],ve...
code_fim
hard
{ "lang": "rust", "repo": "suclogger/leetcode-rust", "path": "/chapter_6/shortest-bridge/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if i >= m || j >= n || a[i][j] == 2 { return; } if a[i][j] == 0 { point.push((i, j)); return; } a[i][j] = 2; if i > 0 { dfs(point, a, m, n, i-1, j); } dfs(point, a, m, n, i, j+1); dfs(point, a, m, n, i+1, j); if j > 0 { dfs(po...
code_fim
hard
{ "lang": "rust", "repo": "suclogger/leetcode-rust", "path": "/chapter_6/shortest-bridge/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn match_example_enums(coin: Coin) -> u32 { match coin { Coin::Penny => { println!("Coin is: {:?}", coin); 1 }, Coin::Nickel => 5, Coin::Dime => 10, Coin::Quarter => 25, } } fn match_example_enums_with_value(coin: CoinInStates) -> u3...
code_fim
hard
{ "lang": "rust", "repo": "siddharth-kulshrestha/learn-rust", "path": "/programs/match_enum_example/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: siddharth-kulshrestha/learn-rust path: /programs/match_enum_example/src/main.rs // Match example // // match is a replacement for switch, but is powerful than switch. // A match works on integers, ranges of integers, bools, enums, tuples, arrays and structs. // It will destructure tuples, array...
code_fim
hard
{ "lang": "rust", "repo": "siddharth-kulshrestha/learn-rust", "path": "/programs/match_enum_example/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { // Example 1: Match with numbers let option_number = 13; match_example_one(option_number); match_example_one(19); match_example_one(2); match_example_one(1); match_example_one(6); match_example_one(7); match_example_one(100); match_example_one(200); ...
code_fim
hard
{ "lang": "rust", "repo": "siddharth-kulshrestha/learn-rust", "path": "/programs/match_enum_example/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maco/unused path: /crates/cli/src/analyzed_token.rs use std::collections::HashSet; use std::path::PathBuf; use token_analysis::{TokenUsage, UsageLikelihoodStatus}; pub struct AnalyzedToken { pub token: String, pub first_path: PathBuf, pub likelihood_status: UsageLikelihoodStatus, ...
code_fim
medium
{ "lang": "rust", "repo": "maco/unused", "path": "/crates/cli/src/analyzed_token.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> AnalyzedToken { token: usage.result.token.token.to_string(), first_path: usage.result.token.first_path().to_path_buf(), likelihood_status: usage.usage_likelihood.status, likelihood_reason: usage.usage_likelihood.reason.clone(), files: usa...
code_fim
medium
{ "lang": "rust", "repo": "maco/unused", "path": "/crates/cli/src/analyzed_token.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// #[test] fn bench_ser_small() { let mut buf = [0u8; 64]; let num_runs = 1_000_000; let varint = AllVarInt {x:21, y:7}; let fixint: NoVarInt = varint.into(); let (t_varint, t_fixint) = ( bench!(num_runs, || { bincode::serialize_into(&mut buf[..], &varint).unwrap(); }), bench!(num_runs, || ...
code_fim
hard
{ "lang": "rust", "repo": "sirkibsirkib/serde_varint", "path": "/src/benching.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sirkibsirkib/serde_varint path: /src/benching.rs // THIS CODE IS CURRENTLy UNUSED fn dur_conv(a: time::Duration) -> u64 { a.as_secs() as u64 * (1000*1000*1000) + a.subsec_nanos() as u64 } fn dur_proportion(a: time::Duration, b: time::Duration) -> f32 { dur_conv(a) as f32 / dur_conv(b) as f...
code_fim
hard
{ "lang": "rust", "repo": "sirkibsirkib/serde_varint", "path": "/src/benching.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Creatiwity/siren path: /src/connectors/insee/types/unite_legale.rs use super::{Header, InseeResponse}; use crate::models::unite_legale::common::UniteLegale; use chrono::{NaiveDate, NaiveDateTime}; use serde::Deserialize; #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struc...
code_fim
hard
{ "lang": "rust", "repo": "Creatiwity/siren", "path": "/src/connectors/insee/types/unite_legale.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[serde(deserialize_with = "super::from_str_optional")] pub annee_effectifs_unite_legale: Option<i32>, pub date_dernier_traitement_unite_legale: Option<NaiveDateTime>, pub nombre_periodes_unite_legale: Option<i32>, pub categorie_entreprise: Option<String>, #[serde(deserialize_wit...
code_fim
hard
{ "lang": "rust", "repo": "Creatiwity/siren", "path": "/src/connectors/insee/types/unite_legale.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Aimnos/Dcoder-Challenges path: /Easy/Rust/Tracy's Love..rs use std::io; fn main() { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); <|fim_suffix|> b: i8 = integers.next().unwrap().parse().unwrap(); match a + b { 6 => print!("Love"), _ => ma...
code_fim
medium
{ "lang": "rust", "repo": "Aimnos/Dcoder-Challenges", "path": "/Easy/Rust/Tracy's Love..rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>=> match (a - b).abs() { 6 => print!("Love"), _ => print!("Hate"), }, } }<|fim_prefix|>// repo: Aimnos/Dcoder-Challenges path: /Easy/Rust/Tracy's Love..rs use std::io; fn main() { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); let m...
code_fim
medium
{ "lang": "rust", "repo": "Aimnos/Dcoder-Challenges", "path": "/Easy/Rust/Tracy's Love..rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let response = rq_client .send_to_address(address, amount_result.unwrap()) .await; if let Err(error) = response { return Message::SetTransaction(error.to_string()); } let result = response.unwrap(); if let Some(error) = result.error { Message::SetTran...
code_fim
hard
{ "lang": "rust", "repo": "dancespiele/okspiel", "path": "/src/node/send_amount.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dancespiele/okspiel path: /src/node/send_amount.rs use crate::connect::ConnectNodeDto; use crate::ok_client::RqClient; use crate::styles::ButtonStyles; use iced::{button, text_input, Align, Button, Column, Command, Element, Row, Text, TextInput}; pub struct SendAmount { node: ConnectNodeDto...
code_fim
hard
{ "lang": "rust", "repo": "dancespiele/okspiel", "path": "/src/node/send_amount.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kariya-mitsuru/wain path: /wain-syntax-text/src/lexer.rs ); assert_lex_error!(r#""\u{}""#, LexErrorKind::InvalidStringFormat); assert_lex_error!(r#""\u{hello!}""#, LexErrorKind::InvalidStringFormat); assert_lex_error!(r#""\u{d800}""#, LexErrorKind::InvalidStringFormat); ...
code_fim
hard
{ "lang": "rust", "repo": "kariya-mitsuru/wain", "path": "/wain-syntax-text/src/lexer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // https://webassembly.github.io/spec/core/text/lexical.html#text-reserved self.fail(LexErrorKind::ReservedName(idchars), start) } fn is_num<F: Fn(&char) -> bool>(s: &str, pred: F) -> bool { if s.is_empty() { return false; } let mut prev_undersc...
code_fim
hard
{ "lang": "rust", "repo": "kariya-mitsuru/wain", "path": "/wain-syntax-text/src/lexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kariya-mitsuru/wain path: /wain-syntax-text/src/lexer.rs e let Some((_, c)) = chars.next() { prev_char = match c { '.' if saw_dot || prev_char != PrevChar::Digit => return None, '.' => { saw_dot = true; ...
code_fim
hard
{ "lang": "rust", "repo": "kariya-mitsuru/wain", "path": "/wain-syntax-text/src/lexer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum Value<I> { Reg(Register), AtReg(Register), AtRegPlus(Register, I), Push, Peek, Pick(I), SP, PC, EX, AtAddr(I), Litteral(I) } enum_from_primitive! { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pu...
code_fim
hard
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/types/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yamakaky/dcpu path: /src/types/mod.rs pub mod decode; mod encode; mod fmt; mod fromstr; mod misc; pub const MASK_OP: u16 = 0b11111; pub const SHIFT_A: u16 = 10; pub const SHIFT_B: u16 = 5; pub const MASK_B: u16 = 0b11111; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum Instruction<...
code_fim
hard
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/types/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>enum_from_primitive! { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum BasicOp { SET = 0x01, ADD = 0x02, SUB = 0x03, MUL = 0x04, MLI = 0x05, DIV = 0x06, DVI = 0x07, MOD = 0x08, MDI = 0x09, AND = 0x0a, BOR = 0x0b, XOR = 0x0c, SHR = 0x0d, A...
code_fim
hard
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/types/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jrmoulton/svls path: /src/backend.rs use crate::config::Config; use log::debug; use std::collections::HashMap; use std::default::Default; use std::env; use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock}; use sv_parser::{parse_sv_str, Define, DefineText}; use svlint::config::Config as L...
code_fim
hard
{ "lang": "rust", "repo": "jrmoulton/svls", "path": "/src/backend.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let linter = match generate_linter(config_svlint) { Ok(x) => x, Err(x) => { self.client.show_message(MessageType::Warning, &x).await; Linter::new(LintConfig::new().enable_all()) } }; ...
code_fim
hard
{ "lang": "rust", "repo": "jrmoulton/svls", "path": "/src/backend.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lxq2537664558/NoProto path: /bench/src/run_bench_flatbuffers.rs use crate::LOOPS; use crate::bench_fb::benchfb::get_root_as_foo_bar_container; use crate::bench_fb::benchfb::FooBarContainerArgs as FooBarContainerArgsFB; use crate::bench_fb::benchfb::FooBarContainer as FooBarContainerFB; use crate...
code_fim
hard
{ "lang": "rust", "repo": "lxq2537664558/NoProto", "path": "/bench/src/run_bench_flatbuffers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(foobar.name(), Some("Hello, World!")); assert_eq!(foobar.rating(), 3.1415432432445543543 + (x as f64)); assert_eq!(foobar.postfix(), "!".as_bytes()[0]); }); assert!(loops == 3); assert_eq!(container.location()...
code_fim
hard
{ "lang": "rust", "repo": "lxq2537664558/NoProto", "path": "/bench/src/run_bench_flatbuffers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spica314/cuda-tools-examples path: /ray-tracing-kernel/src/object.rs use crate::vec3::*; use crate::ray::*; use crate::hit_record::*; use crate::xorshift::*; #[derive(Clone,Copy)] pub struct Object { pub shape: ObjectShape, pub material: ObjectMaterial, } #[derive(Clone,Copy)] pub enum...
code_fim
hard
{ "lang": "rust", "repo": "spica314/cuda-tools-examples", "path": "/ray-tracing-kernel/src/object.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Object { #[inline(always)] pub fn hit(&self, object_id: usize, ray: Ray, t_min: f32, t_max: f32) -> Option<HitRecord> { match self.shape { ObjectShape::Sphere{center,radius} => { let oc = ray.origin() - center; let a = Vec3::dot(ray.directio...
code_fim
hard
{ "lang": "rust", "repo": "spica314/cuda-tools-examples", "path": "/ray-tracing-kernel/src/object.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn computer() { println!("Computer syllabus is about PowerPoint"); }<|fim_prefix|>// repo: Zain1298/Module path: /syllabus.rs pub fn maths() { println!("Maths syllabus is about Fraction"); } pub fn chemistry() { println!("Chemistry syllabus is about Air and Water"); }<|f...
code_fim
medium
{ "lang": "rust", "repo": "Zain1298/Module", "path": "/syllabus.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Zain1298/Module path: /syllabus.rs pub fn maths() { println!("Maths syllabus is about Fraction"); } pub <|fim_suffix|> pub fn physics() { println!("Physics syllabus is about Force"); } pub fn computer() { println!("Computer syllabus is about PowerPoint"); }<|f...
code_fim
medium
{ "lang": "rust", "repo": "Zain1298/Module", "path": "/syllabus.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frehberg/test-generator path: /test-generator/src/lib.rs // └── mytests.rs /// ``` /// Output from `cargo +nightly bench` for 3 bench-input-files matching the pattern, for this example: /// /// ```ignore /// running 3 tests /// test bench::measure_resource_res_set1_input_txt ... bench: ...
code_fim
hard
{ "lang": "rust", "repo": "frehberg/test-generator", "path": "/test-generator/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// **Experimental** Executing a 3-phase unit-test: setup, test, teardown /// /// ## Usage /// ``` /// extern crate test_generator; /// /// #[cfg(test)] /// mod testsuite { /// use test_generator::utest; /// use std::fs::File; /// /// struct Context { file: File } /// /// fn setup() -> Context...
code_fim
hard
{ "lang": "rust", "repo": "frehberg/test-generator", "path": "/test-generator/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let func_ident = func_ast.ident; let paths: Paths = glob(&pattern).expect(&format!("No such file or directory {}", &pattern)); // for each path generate a test-function and fold them to single tokenstream let result = paths .map(|path| { let path_as_str = path ...
code_fim
hard
{ "lang": "rust", "repo": "frehberg/test-generator", "path": "/test-generator/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wg/diesel path: /diesel/src/expression/functions/aggregate_ordering.rs use backend::Backend; use expression::Expression; use query_builder::*; use result::QueryResult; use sql_types::{IntoNullable, SqlOrd}; macro_rules! ord_function { ($fn_name:ident, $type_name:ident, $operator:expr, $docs...
code_fim
hard
{ "lang": "rust", "repo": "wg/diesel", "path": "/diesel/src/expression/functions/aggregate_ordering.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl_selectable_expression!($type_name<T>); } } ord_function!( max, Max, "MAX", "Represents a SQL `MAX` function. This function can only take types which are ordered. # Examples ```rust # #[macro_use] extern crate diesel; # include!(\"../../doctest_setup.rs\"); # use diesel:...
code_fim
hard
{ "lang": "rust", "repo": "wg/diesel", "path": "/diesel/src/expression/functions/aggregate_ordering.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Examples ```rust # #[macro_use] extern crate diesel; # include!(\"../../doctest_setup.rs\"); # use diesel::dsl::*; # # fn main() { # use schema::animals::dsl::*; # let connection = establish_connection(); assert_eq!(Ok(Some(8)), animals.select(max(legs)).first(&connection)); # } " ); ord_funct...
code_fim
hard
{ "lang": "rust", "repo": "wg/diesel", "path": "/diesel/src/expression/functions/aggregate_ordering.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { GenesisAccount::System => TAG_LENGTH, GenesisAccount::Account { public_key, balance, validator, } => { public_key.serialized_length() + balance.value().serialized_le...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/execution_engine/src/core/engine_state/genesis.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /execution_engine/src/core/engine_state/genesis.rs ckingCopy<<S as StateProvider>::Reader>>>, system_module: Module, ) -> Self { let executor = Executor::new(engine_config); let phase = Phase::System; let genesis_confi...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/execution_engine/src/core/engine_state/genesis.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let virtual_system_account = { let named_keys = NamedKeys::new(); let purse = URef::new(Default::default(), AccessRights::READ_ADD_WRITE); Account::create(system_account_addr, named_keys, purse) }; let key = Key::Account(system_account_addr); ...
code_fim
hard
{ "lang": "rust", "repo": "nguyenminhhieu12041996/casper-node", "path": "/execution_engine/src/core/engine_state/genesis.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/brawllib_rs path: /src/wii_texture_formats.rs #[derive(Serialize, Clone, Debug, PartialEq)] pub enum WiiPixelFormat { I4, I8, IA4, IA8, RGB565, RGB5A3, RGBA8, CI4, CI8, CMPR4, Unknown(u32), } impl WiiPixelFormat { pub(crate) fn _new(value: u...
code_fim
hard
{ "lang": "rust", "repo": "rukai/brawllib_rs", "path": "/src/wii_texture_formats.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> WiiPixelFormat2::Unknown (value) => *value, } } } #[derive(Serialize, Clone, Debug, PartialEq)] pub enum WiiPaletteFormat { IA8, RGB565, RGB5A3, Unknown(u32), } impl WiiPaletteFormat { pub(crate) fn new(value: u32) -> Self { match value { 0...
code_fim
hard
{ "lang": "rust", "repo": "rukai/brawllib_rs", "path": "/src/wii_texture_formats.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bitonic/puzzlescript-rs path: /render-gl/src/texture.rs use failure::{Error, Fail}; use gleam::gl; use image::{DynamicImage, GenericImageView}; #[derive(Debug, Clone, Copy)] pub enum TextureWrap { #[allow(dead_code)] Repeat, ClampToEdge, } impl TextureWrap { fn param(self) -> i32 { ...
code_fim
hard
{ "lang": "rust", "repo": "bitonic/puzzlescript-rs", "path": "/render-gl/src/texture.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let tex: u32 = gl.gen_textures(1)[0]; gl.bind_texture(gl::TEXTURE_2D, tex); for param in params.iter() { param.apply(gl); } gl.tex_image_2d( gl::TEXTURE_2D, 0, format as i32, width, height, 0, format, gl::UNSIGNED_BYTE, // s...
code_fim
hard
{ "lang": "rust", "repo": "bitonic/puzzlescript-rs", "path": "/render-gl/src/texture.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> gl.tex_image_2d( gl::TEXTURE_2D, 0, format as i32, width, height, 0, format, gl::UNSIGNED_BYTE, // space character has no length if img_bytes.is_empty() { None } else { Some(&img_bytes) }, ); if generate_mi...
code_fim
hard
{ "lang": "rust", "repo": "bitonic/puzzlescript-rs", "path": "/render-gl/src/texture.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hsjoihs/heightmap_valley path: /src/valley.rs use lab::Lab; use std::error; use std::fmt; type Result<T> = std::result::Result<T, Box<dyn error::Error>>; fn dist_sq(a: usize, b: usize, width: usize) -> Option<usize> { let (y1, x1) = ((a / width) as isize, (a % width) as isize); let (y...
code_fim
hard
{ "lang": "rust", "repo": "hsjoihs/heightmap_valley", "path": "/src/valley.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let x = self.x() as isize + dx; if x < 0 { return None; } let x = x as usize; if x >= self.width { return None; } let y = self.y() as isize + dy; if y < 0 { return None; } let y = y as usize...
code_fim
hard
{ "lang": "rust", "repo": "hsjoihs/heightmap_valley", "path": "/src/valley.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match op.parse() { Ok(imm) => Some(Operand::Imm(imm)), Err(_) => parse_reg(op).map(|x| Operand::Reg(x)) } } struct Machine<'a> { code: &'a [Inst], regs: &'a mut [isize], pc: usize, } enum StepResult { Ok, Send(isize), Receive(u8), } impl<'a> Machine<'a> {...
code_fim
hard
{ "lang": "rust", "repo": "darksv/AdventOfCode2017", "path": "/18/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn step(&mut self) -> StepResult { let mut result = StepResult::Ok; match &self.code[self.pc] { &Inst::Set(x, y) => { let val = self.get_value(y); if let Some(r) = self.get_reg(x) { *r = val; } ...
code_fim
hard
{ "lang": "rust", "repo": "darksv/AdventOfCode2017", "path": "/18/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darksv/AdventOfCode2017 path: /18/src/main.rs fn main() { let code = read_instructions(); println!("1: {}", execute_simple(&code)); println!("2: {}", execute_advanced(&code)); } fn execute_simple(code: &[Inst]) -> isize { let mut regs = init_regs(0); let mut machine = Machin...
code_fim
hard
{ "lang": "rust", "repo": "darksv/AdventOfCode2017", "path": "/18/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: najamelan/runng path: /runng-sys/build.rs use cmake::Config; use std::{env, path::PathBuf}; fn main() { // Compile-time features let generator = if cfg!(feature = "ninja") { "Ninja" } else if cfg!(feature = "vs2017") { "Visual Studio 15 2017 Win64" } else { ...
code_fim
hard
{ "lang": "rust", "repo": "najamelan/runng", "path": "/runng-sys/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Check output of `cargo build --verbose`, should see something like: // -L native=/path/runng/target/debug/build/runng-sys-abc1234/out // That contains output from cmake println!( "cargo:rustc-link-search=native={}", dst.join("lib").display() ); // Tell rustc to u...
code_fim
hard
{ "lang": "rust", "repo": "najamelan/runng", "path": "/runng-sys/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tul1/avalon-rs path: /src/datamodel/characters/test/test_loyal_servant_of_arthur.rs use crate::datamodel::characters::*; #[test] fn test_loyal_servant_of_arthur_constructor_is_correct() { let m = LoyalServantOfArthur::new(); assert_eq!(LoyalServantOfArthur {}, m); } #[test] fn test_loy...
code_fim
hard
{ "lang": "rust", "repo": "tul1/avalon-rs", "path": "/src/datamodel/characters/test/test_loyal_servant_of_arthur.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_loyal_servant_of_arthur_cannot_see_merlin() { let m1 = LoyalServantOfArthur {}; let m2 = Merlin {}; assert_eq!(false, m1.can_see(&m2.get_name())); } #[test] fn test_loyal_servant_of_arthur_cannot_see_percival() { let m1 = LoyalServantOfArthur {}; let m2 = Percival {}; ...
code_fim
hard
{ "lang": "rust", "repo": "tul1/avalon-rs", "path": "/src/datamodel/characters/test/test_loyal_servant_of_arthur.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( b.clone().extend(a.clone()), ui::Style { fg: Some(Color::Red), bg: Some(Color::Blue), add_modifier: Some(Modifier::BOLD), sub_modifier: Some(Modifier::DIM), } ); assert_eq!( a.clone().extend(c.clone())...
code_fim
hard
{ "lang": "rust", "repo": "alebcay/xplr", "path": "/tests/unit/ui.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( c.clone().extend(a.clone()), ui::Style { fg: Some(Color::Red), bg: Some(Color::Magenta), add_modifier: Some(Modifier::BOLD), sub_modifier: Some(Modifier::ITALIC), } ); }<|fim_prefix|>// repo: alebcay/xplr path: /t...
code_fim
hard
{ "lang": "rust", "repo": "alebcay/xplr", "path": "/tests/unit/ui.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alebcay/xplr path: /tests/unit/ui.rs use tui::style::Color; use tui::style::Modifier; use xplr::*; #[test] fn test_extend_style() { let a = ui::Style { fg: Some(Color::Red), bg: None, add_modifier: Some(Modifier::BOLD), sub_modifier: None, }; let b =...
code_fim
hard
{ "lang": "rust", "repo": "alebcay/xplr", "path": "/tests/unit/ui.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> Button<'a, PC27<'a>> { pub fn init(pin: &'a PC27) -> Self { pin.clear_dir(); pin.pincfg().set_inen(); pin.pincfg().set_pullen(); Self { pin } } } impl<'a> Button<'a, PC28<'a>> { pub fn init(pin: &'a PC28) -> Self { pin.clear_dir(); pin....
code_fim
hard
{ "lang": "rust", "repo": "garasubo/erkos", "path": "/devices/wio_terminal/src/button.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: garasubo/erkos path: /devices/wio_terminal/src/button.rs use crate::pin::Pin; use crate::port::PortC; pub struct Button<'a, P> { pin: &'a P } type PC26<'a> = Pin<'a, PortC, 26>; type PC27<'a> = Pin<'a, PortC, 27>; type PC28<'a> = Pin<'a, PortC, 28>; <|fim_suffix|> pub fn is_released(&s...
code_fim
hard
{ "lang": "rust", "repo": "garasubo/erkos", "path": "/devices/wio_terminal/src/button.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apophys/kv-store path: /src/backend/redis_adapter.rs // SPDX-License-Identifier: MIT use super::*; use std::str; use std::string::String; use crate::config::Config; use redis::Commands; <|fim_suffix|> let mut conn = self.client.get_connection()?; conn.set(key, value)?; ...
code_fim
hard
{ "lang": "rust", "repo": "apophys/kv-store", "path": "/src/backend/redis_adapter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut conn = self.client.get_connection()?; Ok(conn.get(key)?) } fn clear(&mut self, key: &str) -> BackendAdapterResult<()> { let mut conn = self.client.get_connection()?; conn.del(key)?; Ok(()) } }<|fim_prefix|>// repo: apophys/kv-store path: /src...
code_fim
medium
{ "lang": "rust", "repo": "apophys/kv-store", "path": "/src/backend/redis_adapter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn http_handler(&mut self, conn_id:usize, event:&Event, poll:&Poll, response:&mut Vec<u8>) -> Result<(), Error>{ let stream = self.connections.get_mut(&conn_id).ok_or_else(|| failure::err_msg("Failed to get connection."))?; if event.is_readable(){ dbg!("readable conn_id:...
code_fim
hard
{ "lang": "rust", "repo": "hsmtkk/psychic-octo-giggle", "path": "/src/server.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }