text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: cht-cloud/aws-sdk-rust path: /sdk/cloudformation/src/operation_ser.rs vert::Infallible> { let mut out = String::new(); #[allow(unused_mut)] let mut writer = smithy_query::QueryWriter::new(&mut out, "DeleteChangeSet", "2010-05-15"); #[allow(unused_mut)] let mut scope_177 = wri...
code_fim
hard
{ "lang": "rust", "repo": "cht-cloud/aws-sdk-rust", "path": "/sdk/cloudformation/src/operation_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cht-cloud/aws-sdk-rust path: /sdk/cloudformation/src/operation_ser.rs tack_set_name { scope_340.string(var_341); } #[allow(unused_mut)] let mut scope_342 = writer.prefix("CallAs"); if let Some(var_343) = &input.call_as { scope_342.string(var_343.as_str()); } ...
code_fim
hard
{ "lang": "rust", "repo": "cht-cloud/aws-sdk-rust", "path": "/sdk/cloudformation/src/operation_ser.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let filenames = args().skip(1); for name in filenames { if !Path::new(&name).exists() { println!("File not found: {}", name); continue; } if let Ok(text) = read_to_string(&name) { println!("{}", text); } else { println...
code_fim
easy
{ "lang": "rust", "repo": "askingalot/MyCommands", "path": "/rust/mycat/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: askingalot/MyCommands path: /rust/mycat/src/main.rs use std::env::{args}; use std::path::Path; use std::fs::{read_to_string}; <|fim_suffix|> let filenames = args().skip(1); for name in filenames { if !Path::new(&name).exists() { println!("File not found: {}", name); ...
code_fim
easy
{ "lang": "rust", "repo": "askingalot/MyCommands", "path": "/rust/mycat/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-50415.rs // run-pass fn main() { // Simplified test case let _ = || 0..=1; <|fim_suffix|> assert_eq!(range, 0..=1023); }<|fim_middle|> // Original test case let full_length = 1024; let range = { // do ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-50415.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(range, 0..=1023); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-50415.rs // run-pass fn main() { // Simplified test case let _ = || 0..=1; <|fim_middle|> // Original test case let full_length = 1024; let range = { // do ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-50415.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" { pub fn csmReadCanvasInfo( model: *const csmModel, outSizeInPixels: *mut csmVector2, outOriginalInPixels: *mut csmVector2, outPixelsPerUnit: *mut c_float, ); } extern "C" { pub fn csmGetDrawableCount(model: *const csmModel) -> c_int; pub fn csmG...
code_fim
medium
{ "lang": "rust", "repo": "meteorsnows/cubism-rs", "path": "/cubism-core-sys/src/draw.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meteorsnows/cubism-rs path: /cubism-core-sys/src/draw.rs use libc::{c_char, c_float, c_int, c_uchar, c_ushort}; use csmVector2; use model::csmModel; pub const csmBlendAdditive: csmFlags = 1 << 0; pub const csmBlendMultiplicative: csmFlags = 1 << 1; pub const csmIsDoubleSided: csmFlags = 1 << 2...
code_fim
hard
{ "lang": "rust", "repo": "meteorsnows/cubism-rs", "path": "/cubism-core-sys/src/draw.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betta-cyber/netease-music-tui path: /src/app.rs // caculate song duration and current progress // if difference less than 1000 means it less than 1s. skip it if (duration_ms - self.song_progress_ms) < 1000 { // log track ...
code_fim
hard
{ "lang": "rust", "repo": "betta-cyber/netease-music-tui", "path": "/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // fm move to trash pub fn fm_trash(&mut self) { match &self.current_playing { Some(track) => match &self.cloud_music { Some(api) => match api.fm_trash(&track.id.unwrap().to_string()) { Ok(_) => { self.msg = format!("m...
code_fim
hard
{ "lang": "rust", "repo": "betta-cyber/netease-music-tui", "path": "/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betta-cyber/netease-music-tui path: /src/app.rs t TrackTable { pub tracks: Vec<Track>, pub selected_index: usize, pub name: String, } #[derive(Clone, Debug, Default)] pub struct DjRadioTable { pub djradios: Vec<DjRadio>, pub selected_index: usize, pub selected_page: usiz...
code_fim
hard
{ "lang": "rust", "repo": "betta-cyber/netease-music-tui", "path": "/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] mod tests { use super::extract_prefix; #[test] fn test_extract_prefix() { assert_eq!(("", None), extract_prefix("")); assert_eq!(("Foo", None), extract_prefix("Foo")); assert_eq!(("Foo", Some(123)), extract_prefix("Foo123")); assert_eq!(("Foo123Ba...
code_fim
hard
{ "lang": "rust", "repo": "dzamlo/svd", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dzamlo/svd path: /src/utils.rs use xmltree; pub fn extract_prefix(name: &str) -> (&str, Option<usize>) { let prefix_end = name.rfind(|c: char| !c.is_digit(10)); match prefix_end { Some(prefix_end) => (&name[..prefix_end + 1], name[prefix_end + 1..].parse().ok()), None =>...
code_fim
medium
{ "lang": "rust", "repo": "dzamlo/svd", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(("", None), extract_prefix("")); assert_eq!(("Foo", None), extract_prefix("Foo")); assert_eq!(("Foo", Some(123)), extract_prefix("Foo123")); assert_eq!(("Foo123Bar", Some(456)), extract_prefix("Foo123Bar456")); assert_eq!(("", Some(456)), extract_prefix("...
code_fim
hard
{ "lang": "rust", "repo": "dzamlo/svd", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } impl DACLSEL_R { #[doc = "Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> Option<DACLSEL_A> { match self.bits { 0 => Some(DACLSEL_A::DACLSEL_0), 2 => Some(DACLSEL_A::DACLSEL_2), 3 => Some(DACLSE...
code_fim
hard
{ "lang": "rust", "repo": "YuhanLiin/msp430fr2355", "path": "/src/sac3/sac3dac.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YuhanLiin/msp430fr2355 path: /src/sac3/sac3dac.rs #[doc = "Register `SAC3DAC` reader"] pub struct R(crate::R<SAC3DAC_SPEC>); impl core::ops::Deref for R { type Target = crate::R<SAC3DAC_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crat...
code_fim
hard
{ "lang": "rust", "repo": "YuhanLiin/msp430fr2355", "path": "/src/sac3/sac3dac.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// This is only here so that the crate will run as a binary crate fn main() { println!("Hello, world!"); }<|fim_prefix|>// repo: dtolnay-contrib/wickerman path: /examples/bees/src/main.rs #![feature(proc_macro)] extern crate wickerman; use wickerman::wickerman; <|fim_middle|>/// This struct should...
code_fim
hard
{ "lang": "rust", "repo": "dtolnay-contrib/wickerman", "path": "/examples/bees/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// This is where the action will happen. #[wickerman] struct Bar<'a> { baz: i32, bees: String, qux: &'a str, spam: &'a Foo, eggs: &'a [u8], } /// This is only here so that the crate will run as a binary crate fn main() { println!("Hello, world!"); }<|fim_prefix|>// repo: dtolnay-...
code_fim
medium
{ "lang": "rust", "repo": "dtolnay-contrib/wickerman", "path": "/examples/bees/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtolnay-contrib/wickerman path: /examples/bees/src/main.rs #![feature(proc_macro)] extern crate wickerman; use wickerman::wickerman; <|fim_suffix|>/// This is where the action will happen. #[wickerman] struct Bar<'a> { baz: i32, bees: String, qux: &'a str, spam: &'a Foo, eg...
code_fim
medium
{ "lang": "rust", "repo": "dtolnay-contrib/wickerman", "path": "/examples/bees/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thequux/qaraoke path: /ogk/src/util.rs //#![feature(collections)] //#![feature(collections_range)] use std::io::prelude::*; use std::io; use std::ops::Index; use std::ops::{Range,RangeTo,RangeFrom,RangeFull}; // A shiftbuffer works like a VecDeque but guarantees that the data // contained is s...
code_fim
hard
{ "lang": "rust", "repo": "thequux/qaraoke", "path": "/ogk/src/util.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn fill_max<R: Read>(&mut self, reader: &mut R) -> io::Result<usize> { let max_block = self.max_block; self.fill_to(reader, max_block) } pub fn consume(&mut self, amount: usize) -> &[u8] { if amount > self.len() { panic!("Consumed more buffer space than...
code_fim
hard
{ "lang": "rust", "repo": "thequux/qaraoke", "path": "/ogk/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn index(&self, idx: RangeTo<usize>) -> &[u8] { self.index(0..idx.end) } } impl Index<RangeFrom<usize>> for ShiftBuffer { type Output = [u8]; fn index(&self, idx: RangeFrom<usize>) -> &[u8] { self.index(idx.start..self.len()) } } impl Index<RangeFull> for ShiftBuf...
code_fim
hard
{ "lang": "rust", "repo": "thequux/qaraoke", "path": "/ogk/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn index(&self, idx: [usize; 2]) -> &f64 { &self.data[idx[0] * self.n + idx[1]] } } impl ops::IndexMut<[usize; 2]> for Matrix { fn index_mut(&mut self, idx: [usize; 2]) -> &mut f64 { &mut self.data[idx[0] * self.n + idx[1]] } } #[cfg(test)] mod tests { use super::*; ...
code_fim
hard
{ "lang": "rust", "repo": "jgrazian/newton-2d", "path": "/src/math/matrix.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..a.m { for j in 0..a.n { mat[[i, j]] = a[[i, j]] + b[[i, j]]; } } mat }); overload!((a: ?Matrix) - (b: ?Matrix) -> Matrix { if a.m != b.m || a.n != b.n { panic!("Unable to subtract matrices"); } let mut mat = Matrix::new(a.m, a.n); ...
code_fim
hard
{ "lang": "rust", "repo": "jgrazian/newton-2d", "path": "/src/math/matrix.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jgrazian/newton-2d path: /src/math/matrix.rs use std::fmt; use std::ops; use super::Vector; extern crate overload; use overload::overload; use wasm_bindgen::prelude::*; /// An nxm Matrix #[wasm_bindgen] #[derive(Clone, Debug, PartialEq, Default)] pub struct Matrix { pub m: usize, // # row...
code_fim
hard
{ "lang": "rust", "repo": "jgrazian/newton-2d", "path": "/src/math/matrix.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suryapandian/rust path: /examples/05.Ownership/8.static_life_time.rs /* Static Lifetimes A static variable is a memory resource created at compile-time that exists through a program start to finish. They must have their types explicitly specified. A static lifetime is a memory resource that la...
code_fim
hard
{ "lang": "rust", "repo": "suryapandian/rust", "path": "/examples/05.Ownership/8.static_life_time.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // You can break some rules, but you must be explicit unsafe { // we can set SECRET to a string literal because it is also `static SECRET = "abracadabra"; println!("{}", SECRET); } }<|fim_prefix|>// repo: suryapandian/rust path: /examples/05.Ownership/8.static_life_tim...
code_fim
hard
{ "lang": "rust", "repo": "suryapandian/rust", "path": "/examples/05.Ownership/8.static_life_time.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: esavier/keynesis path: /src/passport/block/entry/register_master_key.rs use crate::{ key::ed25519::{PublicKey, SecretKey, Signature}, passport::block::{Hash, Time}, }; use std::{ borrow::Cow, convert::{TryFrom, TryInto as _}, fmt::{self, Formatter}, }; use thiserror::Error; ...
code_fim
hard
{ "lang": "rust", "repo": "esavier/keynesis", "path": "/src/passport/block/entry/register_master_key.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// function to make of the given slice the RegisterMasterKey /// /// this function does not check the content is valid for a given /// Header. However in debug mode, this function will throw an error /// if the slice if not at least of the appropriate size. /// /// use this fu...
code_fim
hard
{ "lang": "rust", "repo": "esavier/keynesis", "path": "/src/passport/block/entry/register_master_key.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> macro_rules! impl_from_int { ($T:ty) => { impl From<$T> for Int256 { #[inline] fn from(n: $T) -> Self { Int256(BigInt::from(n)) } } } } impl_from_int!(i8); impl_from_int!(i16); impl_from_int!(i32); impl_from_int!(i64); impl_from...
code_fim
hard
{ "lang": "rust", "repo": "mrubacky/althea_rs", "path": "/num256/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrubacky/althea_rs path: /num256/src/lib.rs extern crate num; extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; use num::bigint::{BigInt, BigUint}; use std::ops::{Add, Deref, Sub}; use num::traits::ops::checked::{CheckedAdd, CheckedSub}; use serde::ser::Seri...
code_fim
hard
{ "lang": "rust", "repo": "mrubacky/althea_rs", "path": "/num256/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!( &Uint256::from(1 as u32) .checked_sub(&Uint256::from(1 as u32)) .is_some(), "should return Some if RHS is not larger than LHS" ); let num = &Uint256::from(1 as u32) .checked_sub(&Uint256::from(1 as u32)) .unwrap() .to_u32() .unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "mrubacky/althea_rs", "path": "/num256/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: steamroller-airmash/airmash-server path: /server-config/src/config.rs use std::collections::HashMap; use std::convert::TryFrom; use std::fmt; use std::mem::ManuallyDrop; use std::ops::{Deref, DerefMut}; use std::ptr::NonNull; use crate::util::{DropPtr, MaybeDrop}; use crate::{ GameConfigCommo...
code_fim
hard
{ "lang": "rust", "repo": "steamroller-airmash/airmash-server", "path": "/server-config/src/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> MaybeDrop::cancel_drop(&mobs); MaybeDrop::cancel_drop(&missiles); MaybeDrop::cancel_drop(&effects); MaybeDrop::cancel_drop(&special_dropper); MaybeDrop::cancel_drop(&planes); Ok(config) } fn into_data(self) -> GameConfigData { self.data } /// Unsafelly reclaim and fr...
code_fim
hard
{ "lang": "rust", "repo": "steamroller-airmash/airmash-server", "path": "/server-config/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for GameConfig { fn default() -> Self { Self::new(GamePrototype::default()).unwrap() } } impl TryFrom<GamePrototype<'_, StringRef>> for GameConfig { type Error = ValidationError; fn try_from(value: GamePrototype<'_, StringRef>) -> Result<Self, Self::Error> { Self::new(value)...
code_fim
hard
{ "lang": "rust", "repo": "steamroller-airmash/airmash-server", "path": "/server-config/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // TODO report errors instead of flat_mapping. for (position, task) in self.tasks.sorted().enumerate() { let task = task.map_err(|_| fmt::Error)?; let marker = if position == self.position { ">" } else { " " }; strings.push(format!("{} {}", marker, task....
code_fim
hard
{ "lang": "rust", "repo": "nedp/ado", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nedp/ado path: /src/main.rs extern crate ncurses; extern crate ado; use ncurses::CURSOR_VISIBILITY; use std::fmt; use std::fmt::{Display, Formatter}; use std::cmp; use std::collections::HashMap; use std::fs::File; use std::fs; use std::ffi::OsString; use std::io::prelude::*; use ado::{BasicT...
code_fim
hard
{ "lang": "rust", "repo": "nedp/ado", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // The mock signatures are equivalent to the ones produced by the BEEFY keystore fn mock_signatures() -> (crypto::Signature, crypto::Signature) { let store: SyncCryptoStorePtr = KeyStore::new().into(); let alice = sp_core::ecdsa::Pair::from_string("//Alice", None).unwrap(); let _ = SyncCryptoS...
code_fim
hard
{ "lang": "rust", "repo": "en/substrate", "path": "/primitives/beefy/src/commitment.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: en/substrate path: /primitives/beefy/src/commitment.rs // This file is part of Substrate. // Copyright (C) 2021 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complia...
code_fim
hard
{ "lang": "rust", "repo": "en/substrate", "path": "/primitives/beefy/src/commitment.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // given let commitment: TestCommitment = Commitment { payload: "Hello World!".into(), block_number: 5, validator_set_id: 0 }; let sigs = mock_signatures(); let signed = SignedCommitment { commitment, signatures: vec![None, None, Some(sigs.0), Some(sigs.1)], }; // when let encode...
code_fim
hard
{ "lang": "rust", "repo": "en/substrate", "path": "/primitives/beefy/src/commitment.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn t_parse_other_columns() { use std::iter::FromIterator; let other_columns = vec!["মোট বৈধ", "মোট বাতিল", "প্রদত্ত ভোট", "শতকরা হার"].iter().map(|s| s.to_string().clone()).collect::<Vec<String>>(); let symbol_positions: Vec<String> = vec!["নৌকা", "ধানের শীষ", "হাত পাখা", "মিনার"].iter...
code_fim
hard
{ "lang": "rust", "repo": "tmahmood/election_result_prettifier", "path": "/src/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmahmood/election_result_prettifier path: /src/tests.rs use crate::{get_constituency_name, aggregate_result_by_symbols, check_for_new_symbols, is_constituency_row, is_center_information_row, CONSTITUENCY_REG, get_constituencies_translated, get_result, get_other_columns, extract_name}; use std::f...
code_fim
hard
{ "lang": "rust", "repo": "tmahmood/election_result_prettifier", "path": "/src/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EgorkaZ/matlog-lab path: /src/parser/manager.rs use crate::{ast::{ExprNode, ExprProvider, TermProvider}, matcher::Matcher}; use super::{preprocess, terms::{ExprParser, ProvedParser}}; pub struct ExprManager { parser: ExprParser, term_provider: TermProvider, expr_provider: ExprProvi...
code_fim
hard
{ "lang": "rust", "repo": "EgorkaZ/matlog-lab", "path": "/src/parser/manager.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn parse_proved(&self, str: &str) -> ExprNode { ProvedParser::new().parse(&self.term_provider, &self.expr_provider, &preprocess(str.chars())).unwrap() } pub fn matcher_str(&self, matcher: &str) -> Matcher<'_> { self.matcher_node(self.parse(matcher)) } pub ...
code_fim
hard
{ "lang": "rust", "repo": "EgorkaZ/matlog-lab", "path": "/src/parser/manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn matcher_node(&self, matcher: ExprNode) -> Matcher<'_> { Matcher::new(matcher, &self.term_provider) } }<|fim_prefix|>// repo: EgorkaZ/matlog-lab path: /src/parser/manager.rs use crate::{ast::{ExprNode, ExprProvider, TermProvider}, matcher::Matcher}; use super::{preprocess, term...
code_fim
hard
{ "lang": "rust", "repo": "EgorkaZ/matlog-lab", "path": "/src/parser/manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut read = Cursor::new(vec![0xff, 1, 0xff, 2, 2, 0xff, 3, 3, 3]); let munched: Vec<Vec<u8>> = ReadMuncher::new(&mut read, 5, my_parse_function).collect(); assert_eq!(munched.len(), 3); assert_eq!(munched[0], vec![0xff, 1]); assert_eq!(munched[1], vec![0xff, 2,...
code_fim
hard
{ "lang": "rust", "repo": "bodyweightenergy/noodle", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(munched.len(), 3); assert_eq!(munched[0], vec![0xff, 1]); assert_eq!(munched[1], vec![0xff, 2, 2]); assert_eq!(munched[2], vec![0xff, 3, 3, 3]); } /// Tests passing closure as parser function. #[test] pub fn closure() { use std::io::Curso...
code_fim
hard
{ "lang": "rust", "repo": "bodyweightenergy/noodle", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bodyweightenergy/noodle path: /src/lib.rs /*! Provides byte stream parsing utilities. ```rust,ignore let reader = File::open("..."); // reader is anything that implements io::Read let alloc_size = 1000; // Set custom allocation size let muncher = ReadMuncher::<DataItem, _>::new(&reader, allo...
code_fim
hard
{ "lang": "rust", "repo": "bodyweightenergy/noodle", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Winwardo/matasano-crypto-challenges path: /src/byte_utilities.rs fn check_bit(left: &u8, right: &u8, bit: u8) -> u16 { let left_bit = left & ((1 << bit) as u8); let right_bit = right & ((1 << bit) as u8); if (left_bit ^ right_bit) > 0 { 1 } else { 0 } } <|fi...
code_fim
hard
{ "lang": "rust", "repo": "Winwardo/matasano-crypto-challenges", "path": "/src/byte_utilities.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn hamming_distance_example() { use byte_conversion::*; let left = readable_text_to_bytes("this is a test"); let right = readable_text_to_bytes("wokka wokka!!!"); assert_eq!(37, hamming_distance(&left, &right)); } }<|fim_prefix|>// repo: Winwardo/matasa...
code_fim
hard
{ "lang": "rust", "repo": "Winwardo/matasano-crypto-challenges", "path": "/src/byte_utilities.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Copies the `OsStr` into WTF-16 before creating the `Trustee`. #[allow(non_snake_case)] pub fn BuildTrusteeWithNameOsStr(name: &OsStr) -> Trustee<'static> { // Convert name into a static WTF-16 buffer let buffer: &'static [u16] = Box::leak(utilities::buf_from_os(name).into_boxed_slice()); ...
code_fim
medium
{ "lang": "rust", "repo": "danieldulaney/windows-permissions-rs", "path": "/src/wrappers/build_trustee_with_name.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danieldulaney/windows-permissions-rs path: /src/wrappers/build_trustee_with_name.rs use crate::utilities; use crate::Trustee; use std::ffi::OsStr; /// Wraps [`BuildTrusteeWithNameW`](https://docs.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-buildtrusteewithnamew) #[allow(non_snake_cas...
code_fim
medium
{ "lang": "rust", "repo": "danieldulaney/windows-permissions-rs", "path": "/src/wrappers/build_trustee_with_name.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn gen_random_message(time: f64) -> js_sys::Map { log("gen_random_message"); let index = js_sys::Math::floor(js_sys::Math::random() * 7.0); let tup = DEFAULT_MESSAGES[index as usize]; let message = js_sys::Map::new(); message.set(&JsValue::from_str(&"author"), &JsValue::from_str(tup.0)...
code_fim
hard
{ "lang": "rust", "repo": "Sirotyann/rust-wasm-react", "path": "/astate/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// ----------------------------------------------------------------------------- static DEFAULT_MESSAGES: &'static [(&'static str, &'static str)] = &[ ("Yoda", "Truly wonderful, the mind of a child is."), ("Yoda", "Train yourself to let go of everything you fear to lose."), ("Yoda", "That is why you fail....
code_fim
hard
{ "lang": "rust", "repo": "Sirotyann/rust-wasm-react", "path": "/astate/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sirotyann/rust-wasm-react path: /astate/src/lib.rs extern crate wasm_bindgen; extern crate web_sys; extern crate js_sys; use wasm_bindgen::prelude::*; use wasm_bindgen::JsValue; use std::f64; //----------------------------------------------------------------------------- #[wasm_bindgen] extern...
code_fim
hard
{ "lang": "rust", "repo": "Sirotyann/rust-wasm-react", "path": "/astate/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bohdaq/rust-web-server path: /src/header/content_disposition/tests.rs use crate::header::content_disposition::{ContentDisposition, DISPOSITION_TYPE}; #[test] fn not_proper_value() { let raw_content_disposition = "sometext"; let boxed_parse = ContentDisposition::parse(raw_content_dispos...
code_fim
hard
{ "lang": "rust", "repo": "bohdaq/rust-web-server", "path": "/src/header/content_disposition/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let filename = "filename".to_string(); let fieldname = "field".to_string(); let content_disposition = ContentDisposition { disposition_type: DISPOSITION_TYPE.attachment.to_string(), field_name: Some(fieldname), file_name: Some(filename), }; let boxed_content_di...
code_fim
hard
{ "lang": "rust", "repo": "bohdaq/rust-web-server", "path": "/src/header/content_disposition/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(::std::mem::size_of::<_GtkRequisition>() , 8usize); assert_eq!(::std::mem::align_of::<_GtkRequisition>() , 4usize); } impl Clone for _GtkRequisition { fn clone(&self) -> Self { *self } } pub type GtkRequisition = _GtkRequisition; #[repr(C)] #[derive(Debug, Copy)] pub struct _GtkWind...
code_fim
hard
{ "lang": "rust", "repo": "riederm/cefrust", "path": "/src/gtk2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl _GdkScreen { #[inline] pub fn closed(&self) -> guint { unsafe { ::std::mem::transmute(((self._bitfield_1 & (1usize as u8)) >> 0u32) as u32) } } #[inline] pub fn set_closed(&mut self, val: guint) { self._b...
code_fim
hard
{ "lang": "rust", "repo": "riederm/cefrust", "path": "/src/gtk2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: riederm/cefrust path: /src/gtk2.rs eq!(::std::mem::align_of::<_GTypeClass>() , 8usize); } impl Clone for _GTypeClass { fn clone(&self) -> Self { *self } } pub type GTypeClass = _GTypeClass; /** * GTypeInstance: * * An opaque structure used as the base of all type instances. */ #[repr(C)...
code_fim
hard
{ "lang": "rust", "repo": "riederm/cefrust", "path": "/src/gtk2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joliss/rust-brotli path: /corrosion/backward_references_hq.rs 4i32 as (u32), 5i32 as (u32), 6i32 as (u32), 8i32 as (u32), 10i32 as (u32), 14i32 as (u32), 18i32 as (u32), 26i32 as (u32), 34i32 as (u32), ...
code_fim
hard
{ "lang": "rust", "repo": "joliss/rust-brotli", "path": "/corrosion/backward_references_hq.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>unsafe extern fn CleanupZopfliCostModel( mut m : *mut MemoryManager, mut self : *mut ZopfliCostModel ) { BrotliFree( m, (*self).literal_costs_ as (*mut ::std::os::raw::c_void) ); (*self).literal_costs_ = 0i32 as (*mut ::std::os::raw::c_void) as (*mut f32); } unsafe extern ...
code_fim
hard
{ "lang": "rust", "repo": "joliss/rust-brotli", "path": "/corrosion/backward_references_hq.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joliss/rust-brotli path: /corrosion/backward_references_hq.rs (usize) { 21u32 as (u16) } else if insertlen < 22594i32 as (usize) { 22u32 as (u16) } else { 23u32 as (u16) } } unsafe extern fn GetCopyLengthCode(mut copylen : usize) -> u16 { if copylen < 10...
code_fim
hard
{ "lang": "rust", "repo": "joliss/rust-brotli", "path": "/corrosion/backward_references_hq.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/macros/pub-item-inside-macro.rs // run-pass // Issue #14660 // pretty-expanded FIXME #23616 <|fim_suffix|> foo!(); } fn main() { bleh::bar(); }<|fim_middle|>mod bleh { macro_rules! foo { () => { pub fn bar...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/macros/pub-item-inside-macro.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> foo!(); } fn main() { bleh::bar(); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/run-pass/macros/pub-item-inside-macro.rs // run-pass // Issue #14660 <|fim_middle|>// pretty-expanded FIXME #23616 mod bleh { macro_rules! foo { () => { pub fn bar...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/run-pass/macros/pub-item-inside-macro.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let start = cur_pos!(self); self.state.potential_arrow_start = Some(start); let modifier_start = start; let has_modifier = self.eat_any_ts_modifier()?; let pat_start = cur_pos!(self); let mut arg = { if self.input.sy...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_parser/src/parser/expr.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_parser/src/parser/expr.rs ), true, ))) } else if is!(p, '`') { p.parse_tagged_tpl( match mut_obj_opt { ...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_parser/src/parser/expr.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_parser/src/parser/expr.rs :TsAs(TsAsExpr { span: span!(self, start), expr: Box::new(Expr::Ident(id)), type_ann, }))); } // async a =...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_parser/src/parser/expr.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> std::env::set_var("RUST_LOG", log_level_from_num(level).to_string()); } pub fn try_init(level: u8) -> Result<(), self::Error> { apply_env_log_level(level); env_logger::try_init().map(print_intro_message)?; Ok(()) } pub fn init(level: u8) { apply_en...
code_fim
hard
{ "lang": "rust", "repo": "dfinance/move-unscrambler", "path": "/src/cli/logging.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dfinance/move-unscrambler path: /src/cli/logging.rs use clap::Clap; use log::{Level, Level::*}; /// Logging configuration. #[derive(Clap, Debug)] pub struct Opts { /// A level of verbosity, and can be used multiple times. /// Possible valuable maximum are three `v`. #[clap(short, lo...
code_fim
hard
{ "lang": "rust", "repo": "dfinance/move-unscrambler", "path": "/src/cli/logging.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ebraminio/actix-website path: /examples/url-dispatch/src/norm2.rs // <norm> use actix_web::{http::Method, http::NormalizePath, App}; <|fim_suffix|>fn index(req: &HttpRequest) -> String { unimplemented!() }<|fim_middle|>fn main() { let app = App::new() .resource("/resource/", |r|...
code_fim
hard
{ "lang": "rust", "repo": "ebraminio/actix-website", "path": "/examples/url-dispatch/src/norm2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn index(req: &HttpRequest) -> String { unimplemented!() }<|fim_prefix|>// repo: ebraminio/actix-website path: /examples/url-dispatch/src/norm2.rs // <norm> use actix_web::{http::Method, http::NormalizePath, App}; fn main() { <|fim_middle|> let app = App::new() .resource("/resource/", |r|...
code_fim
hard
{ "lang": "rust", "repo": "ebraminio/actix-website", "path": "/examples/url-dispatch/src/norm2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use actix_web::HttpRequest; fn index(req: &HttpRequest) -> String { unimplemented!() }<|fim_prefix|>// repo: ebraminio/actix-website path: /examples/url-dispatch/src/norm2.rs // <norm> use actix_web::{http::Method, http::NormalizePath, App}; fn main() { <|fim_middle|> let app = App::new() ...
code_fim
medium
{ "lang": "rust", "repo": "ebraminio/actix-website", "path": "/examples/url-dispatch/src/norm2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akilegaspi/elba path: /src/bin/cmds/package.rs use std::env::current_dir; use clap::{App, ArgMatches, SubCommand}; use elba::{ cli::{build, index}, util::{ config::{Backend, Config}, error::Result, }, }; use failure::{format_err, ResultExt}; <|fim_suffix|> if !ar...
code_fim
hard
{ "lang": "rust", "repo": "akilegaspi/elba", "path": "/src/bin/cmds/package.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !args.is_present("no-verify") { build::build( &ctx, &project, &(true, false, None, None), true, &Backend::default(), )?; } let (gz_name, _) = index::package(&project)?; Ok(format!( "created compressed ...
code_fim
hard
{ "lang": "rust", "repo": "akilegaspi/elba", "path": "/src/bin/cmds/package.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0702_to_0718.rs //! @ We also need to compute the change in style between mlists and their //! subsidiaries. The following macros define the subsidiary style for //! an overlined nucleus (|cramped_style|), for a subscript or a superscript //! (...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0702_to_0718.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>of fractions as well as for displayed operators and //! their limits above and below. It takes a given box~|b| and //! changes it so that the new box is centered in a box of width~|w|. //! The centering is done by putting \.{\\hss} glue at the left and right //! of the list inside |b|, then packaging the ...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0702_to_0718.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Trait alias for `Sync` /// /// If the `rayon` feature is set, it acts as an alias for `Sync` and is implemented for all types /// which implement `Sync`. If `rayon` is not set, it will be an "empty" trait implemented for all /// types. #[cfg(not(feature = "rayon"))] pub trait SyncAlias {} #[cfg(featu...
code_fim
hard
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/src/core/parallelization.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: argmin-rs/argmin path: /argmin/src/core/parallelization.rs // Copyright 2018-2022 argmin developers // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at you...
code_fim
hard
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/src/core/parallelization.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "rayon")] impl<T> SendAlias for T where T: Send {} #[cfg(not(feature = "rayon"))] impl<T> SendAlias for T {} /// Trait alias for `Sync` /// /// If the `rayon` feature is set, it acts as an alias for `Sync` and is implemented for all types /// which implement `Sync`. If `rayon` is not set...
code_fim
hard
{ "lang": "rust", "repo": "argmin-rs/argmin", "path": "/argmin/src/core/parallelization.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> positives[total as usize] = true; } else { if negatives[-total as usize] { println!("{}", total); do_break = true; break; } negat...
code_fim
hard
{ "lang": "rust", "repo": "RexTremendae/AdventOfCode", "path": "/archive/Source/2018/Day1_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RexTremendae/AdventOfCode path: /archive/Source/2018/Day1_2.rs use std::fs; fn main() { const SIZE:usize = 100000; let mut positives:[bool; SIZE] = [false; SIZE]; let mut negatives:[bool; SIZE] = [false; SIZE]; <|fim_suffix|> if total >= 0 { i...
code_fim
hard
{ "lang": "rust", "repo": "RexTremendae/AdventOfCode", "path": "/archive/Source/2018/Day1_2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let p = Point {x: 12, y: 25}; print(p.clone()); //クローンを作って関数に渡す println!("({}, {})", p.x, p.y);//pの所有権はprint関数に移動せずエラーにはならない } fn print(p: Point) { println!("({}, {})", p.x, p.y); }<|fim_prefix|>// repo: Tsuyoshi-Iwanaga/learning_rust path: /006/trait3.rs struct Point { x: i32, y...
code_fim
medium
{ "lang": "rust", "repo": "Tsuyoshi-Iwanaga/learning_rust", "path": "/006/trait3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tsuyoshi-Iwanaga/learning_rust path: /006/trait3.rs struct Point { x: i32, y: i32, } impl Clone for Point { fn clone(&self) -> Self { <|fim_suffix|>fn main() { let p = Point {x: 12, y: 25}; print(p.clone()); //クローンを作って関数に渡す println!("({}, {})", p.x, p.y);//pの所有権はprint関数に移動せずエラーにはならな...
code_fim
medium
{ "lang": "rust", "repo": "Tsuyoshi-Iwanaga/learning_rust", "path": "/006/trait3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sybila/biodivine-lib-bdd path: /src/_impl_bdd_path_iterator.rs use crate::{Bdd, BddPartialValuation, BddPathIterator, BddPointer}; impl BddPathIterator<'_> { pub fn new(bdd: &Bdd) -> BddPathIterator { if bdd.is_false() { BddPathIterator { bdd, ...
code_fim
hard
{ "lang": "rust", "repo": "sybila/biodivine-lib-bdd", "path": "/src/_impl_bdd_path_iterator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let vars = BddVariableSet::new_anonymous(5); let v = vars.variables(); let c1 = BddPartialValuation::from_values(&[(v[0], true), (v[1], false)]); let c2 = BddPartialValuation::from_values(&[(v[1], true), (v[3], false)]); let c3 = BddPartialValuation::from_values(&[...
code_fim
hard
{ "lang": "rust", "repo": "sybila/biodivine-lib-bdd", "path": "/src/_impl_bdd_path_iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = BddPartialValuation::empty(); for i in 0..(path.len() - 1) { let this_node = path[i]; let next_node = path[i + 1]; let var = bdd.var_of(this_node); if bdd.low_link_of(this_node) == next_node { result.set_value(var, false); } els...
code_fim
hard
{ "lang": "rust", "repo": "sybila/biodivine-lib-bdd", "path": "/src/_impl_bdd_path_iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn make_key_pair(bit: u32) -> Result<PKey<Private>, ErrorStack> { let rsa = Rsa::generate(bit)?; PKey::from_rsa(rsa) }<|fim_prefix|>// repo: ryutah/rust-tutorials path: /rsa/src/main.rs extern crate openssl; use openssl::error::ErrorStack; use openssl::pkey::{PKey, Private}; use openssl::rsa::Rs...
code_fim
hard
{ "lang": "rust", "repo": "ryutah/rust-tutorials", "path": "/rsa/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Public Key"); let pem = key_pair.public_key_to_pem().unwrap(); println!("{}", str::from_utf8(pem.as_slice()).unwrap()); } fn make_key_pair(bit: u32) -> Result<PKey<Private>, ErrorStack> { let rsa = Rsa::generate(bit)?; PKey::from_rsa(rsa) }<|fim_prefix|>// repo: ryutah/rust-...
code_fim
hard
{ "lang": "rust", "repo": "ryutah/rust-tutorials", "path": "/rsa/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryutah/rust-tutorials path: /rsa/src/main.rs extern crate openssl; use openssl::error::ErrorStack; use openssl::pkey::{PKey, Private}; use openssl::rsa::Rsa; use std::str; <|fim_suffix|> println!("Public Key"); let pem = key_pair.public_key_to_pem().unwrap(); println!("{}", str::fr...
code_fim
hard
{ "lang": "rust", "repo": "ryutah/rust-tutorials", "path": "/rsa/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> mem::swap(&mut self.cursor, &mut cursor); yield_value } } impl<'a, 'c> Iterator for IterTokens<'a, 'c> { type Item = Result<BinXMLDeserializedTokens<'a>, Error>; /// yields tokens from the chunk, will return once the chunk is finished. fn next(&mut self) -> Option<<Self a...
code_fim
hard
{ "lang": "rust", "repo": "N4rr34n6/evtx", "path": "/src/binxml/deserializer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: N4rr34n6/evtx path: /src/binxml/deserializer.rs use byteorder::ReadBytesExt; use log::trace; use std::io::{Seek, SeekFrom}; use crate::binxml::tokens::read_open_start_element; use crate::binxml::value_variant::BinXmlValue; use crate::string_cache::CachedString; use crate::template_cache::Cache...
code_fim
hard
{ "lang": "rust", "repo": "N4rr34n6/evtx", "path": "/src/binxml/deserializer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if dots == 0 { match number.parse() { Ok(n) => Token::Int(n), Err(_) => { self.throw_error( (self.current_pos - number.len(), self.current_pos), "Error parsing integer", ); Token::Int(0) } } } else { ma...
code_fim
hard
{ "lang": "rust", "repo": "JuanM04/rust-calc", "path": "/src/calc/lexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JuanM04/rust-calc path: /src/calc/lexer.rs use super::Token; const DIGITS: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; pub struct Lexer { raw_data: String, current_pos: usize, } impl Lexer { pub fn new(raw_data: &String) -> Lexer { Lexer { raw_data: raw_da...
code_fim
hard
{ "lang": "rust", "repo": "JuanM04/rust-calc", "path": "/src/calc/lexer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn tokenize(&mut self) -> Vec<Token> { let mut tokens: Vec<Token> = vec![]; while self.current_pos < self.raw_data.len() { let c = self.get_current(); if DIGITS.contains(&c) || c == '.' { tokens.push(self.tokenize_number()); } else { match c { '+...
code_fim
hard
{ "lang": "rust", "repo": "JuanM04/rust-calc", "path": "/src/calc/lexer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtynn/sigar-rs path: /sigar-sys/src/lib.rs //! Provides low level binding to [`AlexYaruki/sigar`], which is a independent fork version of official [`hyperic/sigar`] //! //! [`AlexYaruki/sigar`]: https://github.com/AlexYaruki/sigar //! [`hyperic/sigar`]: https://github.com/hyperic/sigar <|fim_su...
code_fim
medium
{ "lang": "rust", "repo": "dtynn/sigar-rs", "path": "/sigar-sys/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns an error string from given code pub fn error_string(sigar: *mut ffi::sigar_t, code: c_int) -> String { unsafe { let ptr = ffi::sigar_strerror(sigar, code); let bytes = CStr::from_ptr(ptr).to_bytes(); str::from_utf8(bytes) .ok() .expect("Inval...
code_fim
hard
{ "lang": "rust", "repo": "dtynn/sigar-rs", "path": "/sigar-sys/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rikitau/wasm-bip85 path: /src/lib.rs use wasm_bindgen::prelude::*; use std::str::FromStr; use bip85::bitcoin::secp256k1::Secp256k1; use bip85::bitcoin::util::key::PrivateKey; use bip85::bitcoin::util::bip32::ExtendedPrivKey; use bip85::bitcoin::network::constants::Network; use bip85::bip39::Mn...
code_fim
hard
{ "lang": "rust", "repo": "rikitau/wasm-bip85", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen] pub fn to_mnemonic(xprv: &str, words_number: u32, idx: u32 ) -> Result<JsValue, JsValue>{ let secp = Secp256k1::new(); let root = jserr!(ExtendedPrivKey::from_str(xprv)); let mn = jserr!(bip85::to_mnemonic(&secp, &root, w...
code_fim
hard
{ "lang": "rust", "repo": "rikitau/wasm-bip85", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> WeakPointer { ptr: ptr::null_mut(), } } } #[derive(Serialize, Deserialize, Clone, Debug)] #[repr(transparent)] pub struct BoxedMemory { pub mem: Box<[u8]>, } impl BoxedMemory { pub fn new(boxed_slice: Box<[u8]>) -> BoxedMemory { BoxedMemory { mem: boxed_sl...
code_fim
hard
{ "lang": "rust", "repo": "datengx/rustboyadvance-ng", "path": "/core/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }