text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> match (op_1, op_2, op_3, op_4) { (0x0, 0x0, 0xE, 0x0) => Some(OpCode::ClearDisplay), (0x0, 0x0, 0xE, 0xE) => Some(OpCode::Return), (0x1, _, _, _) => Some(OpCode::Jump(nnn)), (0x2, _, _, _) => Some(OpCode::Call(nnn)), (0x3, _, _, _) => Some(OpCode::SkipEqVal(x, n...
code_fim
hard
{ "lang": "rust", "repo": "micaww/ch8-rs", "path": "/src/disassembler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn piston() -> std::io::Result<()> { let opengl = OpenGL::V3_2; let mut window: PistonWindow = WindowSettings::new("piston: image", [100, 100]) .exit_on_esc(true) .graphics_api(opengl) .build() .unwrap(); let buffer = read_game("GUESS")?; // Create a new ga...
code_fim
hard
{ "lang": "rust", "repo": "RazvanRotari/chip8", "path": "/src/piston.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RazvanRotari/chip8 path: /src/piston.rs mod chip; use chip::{read_game, Machine}; extern crate glutin_window; extern crate graphics; extern crate image; extern crate opengl_graphics; extern crate piston; extern crate gfx_text; extern crate piston_window; #[macro_use] extern crate lazy_static; ...
code_fim
hard
{ "lang": "rust", "repo": "RazvanRotari/chip8", "path": "/src/piston.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rost/rust-lox path: /src/parser.rs Result<Stmt> { let value = self.expression()?; self.consume(TT::Semicolon, "Expected ';' after value.".to_string())?; Ok(Stmt::Print(value)) } fn return_statement(&mut self, return_: Token) -> Result<Stmt> { let mut valu...
code_fim
hard
{ "lang": "rust", "repo": "rost/rust-lox", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rost/rust-lox path: /src/parser.rs zer = Some(self.expression_statement()?); } let mut condition = None; if !self.check(&TT::Semicolon) { condition = Some(self.expression()?); } self.consume( TT::Semicolon, "Expected ';...
code_fim
hard
{ "lang": "rust", "repo": "rost/rust-lox", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let expr = match token.type_ { TT::False => Expr::Literal(Value::Bool(false)), TT::True => Expr::Literal(Value::Bool(true)), TT::Nil => Expr::Literal(Value::Nil), TT::Number(num) => Expr::Literal(Value::Number(num)), // TODO: learn about ...
code_fim
hard
{ "lang": "rust", "repo": "rost/rust-lox", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let v_icons = vec![&self.icon_high,&self.icon_low, &self.icon_mid]; let mut rng = thread_rng(); match v_icons.choose(&mut rng) { Some(icon) => { self.tray.set_icon(&icon); self.tray.set_tip(&"Battery Pal did not detect a batt...
code_fim
hard
{ "lang": "rust", "repo": "maltob/battery_pal_windows", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maltob/battery_pal_windows path: /src/main.rs #![windows_subsystem = "windows"] extern crate native_windows_gui as nwg; extern crate native_windows_derive as nwd; use nwd::NwgUi; use nwg::NativeUi; use rand::thread_rng; use rand::seq::SliceRandom; use std::time::Duration; mod battery_info; use...
code_fim
hard
{ "lang": "rust", "repo": "maltob/battery_pal_windows", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.tray.set_tip(&(format!("You are at {}% battery", percent))); } fn select_random_icon(&self) { let v_icons = vec![&self.icon_high,&self.icon_low, &self.icon_mid]; let mut rng = thread_rng(); match v_icons.choose(&mut rng) { Some(icon) => { ...
code_fim
hard
{ "lang": "rust", "repo": "maltob/battery_pal_windows", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gganley/blaise path: /src/parser/parser.rs use self::ast; pub enum Precedence { Parens = 5, Product = 4, Sum = 3, Comp = 2, Terms = 1, } pub struct Parser<'a> { pub lexer: Lexer<'a>, } impl<'a> Parser<'a> { pub fn new(lexer: Lexer<'a>) -> Self { Parser { le...
code_fim
hard
{ "lang": "rust", "repo": "gganley/blaise", "path": "/src/parser/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn decls(&mut self) -> Result<Vec<ast::Decl>, String> {} pub fn var_decl(&mut self) -> Result<ast::VarDecl, String> { unimplemented!() } pub fn type_type(&mut self) -> Result<ast::Type, String> { unimplemented!() } pub fn proc_decl(&mut self) -> Result<ast::P...
code_fim
hard
{ "lang": "rust", "repo": "gganley/blaise", "path": "/src/parser/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: age-rs/rts.rs path: /tiles/src/data.rs // Copyright (c) 2017 Ivo Wetzel // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may...
code_fim
hard
{ "lang": "rust", "repo": "age-rs/rts.rs", "path": "/tiles/src/data.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } else { false } } fn get_tile_index(&self, x: i32, y: i32) -> Option<u32> { let w = self.width as i32; let h = self.height as i32; if x >= 0 && x < w && y >= 0 && y < h { Some(self.indices[(y * w + x) as usize]) } else { ...
code_fim
hard
{ "lang": "rust", "repo": "age-rs/rts.rs", "path": "/tiles/src/data.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>x_results: 5000, include_metadata: false, next_marker: None, prefix: None, timeout: None, };<|fim_prefix|>// repo: akshayknarayan/AzureSDKForRust path: /src/azure/storage/container/list_container_options.rs #[derive(Debug, Clone, PartialEq)] pub struct ListContainerOptions { pub max_r...
code_fim
hard
{ "lang": "rust", "repo": "akshayknarayan/AzureSDKForRust", "path": "/src/azure/storage/container/list_container_options.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akshayknarayan/AzureSDKForRust path: /src/azure/storage/container/list_container_options.rs #[derive(Debug, Clone, PartialEq)] pub struct ListContainerOptions { pub max_results: u32, pub incl<|fim_suffix|>x_results: 5000, include_metadata: false, next_marker: None, prefix: No...
code_fim
hard
{ "lang": "rust", "repo": "akshayknarayan/AzureSDKForRust", "path": "/src/azure/storage/container/list_container_options.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Set of jobs for which we already accounted data but that are still tracked. We must not account these // jobs a second time. completed_but_still_tracked: BTreeSet<TaskId>, } impl JobRegistryMetrics { fn new(metric_registry: Arc<metric::Registry>) -> Self { Self { ac...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/server/src/job.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtvu/influxdb_iox path: /server/src/job.rs use data_types::job::Job; use parking_lot::Mutex; use std::{ collections::{BTreeMap, BTreeSet}, convert::Infallible, ops::DerefMut, sync::Arc, time::Duration, }; use time::TimeProvider; use tracker::{TaskId, TaskRegistration, TaskReg...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/server/src/job.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { active_gauge: metric_registry .register_metric("influxdb_iox_job_count", "Number of known jobs"), completed_accu: Default::default(), cpu_time_histogram: metric_registry.register_metric_with_options( "influxdb_iox_job_compl...
code_fim
hard
{ "lang": "rust", "repo": "mtvu/influxdb_iox", "path": "/server/src/job.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: longlb/exercism path: /rust/hamming/src/lib.rs /// Return the Hamming distance between the strings, /// or None if the lengths are mismatched. pub fn hamming_distance(s1: &str, s2: &str) -> Option<usize> { if s1.len() != s2.len() { return None; } <|fim_suffix|> for _ in 0..s1...
code_fim
medium
{ "lang": "rust", "repo": "longlb/exercism", "path": "/rust/hamming/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..s1.len() { if iter1.next().unwrap() != iter2.next().unwrap() { hamming += 1; } } Some(hamming) }<|fim_prefix|>// repo: longlb/exercism path: /rust/hamming/src/lib.rs /// Return the Hamming distance between the strings, /// or None if the lengths are mis...
code_fim
medium
{ "lang": "rust", "repo": "longlb/exercism", "path": "/rust/hamming/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn compute_file_hash(file_path: &Path) -> Result<u64> { let mut hasher = SeaHasher::default(); let file = fs::File::open(file_path) .with_context(|| format!("Failed to open file {}", file_path.display()))?; let mut reader = BufReader::new(file); let mut buffer = [0; 1024]; loo...
code_fim
hard
{ "lang": "rust", "repo": "aidas/zinoma", "path": "/src/engine/incremental/fs_hash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aidas/zinoma path: /src/engine/incremental/fs_hash.rs use anyhow::{Context, Result}; use rayon::prelude::*; use seahash::SeaHasher; use std::collections::{HashMap, HashSet}; use std::fs; use std::hash::Hasher; use std::io::{BufReader, Read}; use std::path::{Path, PathBuf}; use walkdir::WalkDir; ...
code_fim
hard
{ "lang": "rust", "repo": "aidas/zinoma", "path": "/src/engine/incremental/fs_hash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hexj/QUANTAXIS path: /qapro-rs/src/parsers/parser/keywords.rs use nom::branch::alt; use nom::bytes::complete::{tag, tag_no_case}; use nom::combinator::peek; use nom::sequence::terminated; use nom::IResult; <|fim_suffix|>pub fn sql_keyword(input: &str) -> IResult<&str, &str> { alt(( ...
code_fim
hard
{ "lang": "rust", "repo": "hexj/QUANTAXIS", "path": "/qapro-rs/src/parsers/parser/keywords.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn sql_keyword(input: &str) -> IResult<&str, &str> { alt(( terminated(tag_no_case("SELECT"), keyword_follow_char), terminated(tag_no_case("FROM"), keyword_follow_char), terminated(tag_no_case("WHERE"), keyword_follow_char), terminated(tag_no_case("ORDER"), keyword_f...
code_fim
hard
{ "lang": "rust", "repo": "hexj/QUANTAXIS", "path": "/qapro-rs/src/parsers/parser/keywords.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evernym/indy-sdk path: /vcx/libvcx/src/messages/payload.rs use messages::message_type::*; use messages::to_u8; use messages::get_message::MessagePayload; use settings::{ProtocolTypes, get_protocol_type}; use utils::libindy::crypto; use error::prelude::*; use std::collections::HashMap; #[derive...
code_fim
hard
{ "lang": "rust", "repo": "evernym/indy-sdk", "path": "/vcx/libvcx/src/messages/payload.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Deserialize, Serialize)] pub enum PayloadKinds { CredOffer, CredReq, Cred, Proof, ProofRequest, Other(String) } impl PayloadKinds { fn family(&self) -> MessageFamilies { match self { PayloadKinds::CredOffer => MessageFamilies::Credent...
code_fim
hard
{ "lang": "rust", "repo": "evernym/indy-sdk", "path": "/vcx/libvcx/src/messages/payload.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> trace!("Sending payload: {:?}", message.as_bytes()); crypto::pack_message(Some(my_vk), &receiver_keys, message.as_bytes()) } } } pub fn decrypt(my_vk: &str, payload: &MessagePayload) -> VcxResult<(String, Option<Thread>)> { match payload...
code_fim
hard
{ "lang": "rust", "repo": "evernym/indy-sdk", "path": "/vcx/libvcx/src/messages/payload.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let executor = FakeExecutor::no_genesis(); // Genesis write sets are not allowed to contain deletions. let write_op = (AccessPath::default(), WriteOp::Deletion); let write_set = WriteSetMut::new(vec![write_op]).freeze().unwrap(); let address = account_config::association_address(); ...
code_fim
medium
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/language/e2e_tests/src/tests/genesis.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xpeerchain/xpeerchain path: /language/e2e_tests/src/tests/genesis.rs // Copyright (c) The XPeer Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{assert_prologue_parity, executor::FakeExecutor}; use assert_matches::assert_matches; use crypto::signing::KeyPair; use types::{ ...
code_fim
medium
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/language/e2e_tests/src/tests/genesis.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-nairobi/workshop-materials path: /code-examples/basic-games/bottles-of-beer/src/main.rs trait Bottles { fn bottles_of_beer(&self) -> Self; fn on_the_wall(&self); } impl Bottles for u32 { fn bottles_of_beer(&self) -> u32 { match *self { 0 => print!("No bottles of beer"), 1 => pr...
code_fim
medium
{ "lang": "rust", "repo": "rust-nairobi/workshop-materials", "path": "/code-examples/basic-games/bottles-of-beer/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn on_the_wall(&self) { println!(" on the wall!"); } } fn main() { for i in (1..100).rev() { i.bottles_of_beer().on_the_wall(); i.bottles_of_beer(); println!("\nTake one down, pass it around..."); (i - 1).bottles_of_beer().on_the_wall(); println!("-----------------------------------"); }...
code_fim
hard
{ "lang": "rust", "repo": "rust-nairobi/workshop-materials", "path": "/code-examples/basic-games/bottles-of-beer/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: h5p9sl/morse_bot path: /src/morse.rs use std::time::Duration; use std::collections::HashMap; /// Describes the state of the virtual morse keyer #[derive(Debug, PartialEq)] pub enum State { Down, Up, } #[derive(Debug)] /// Dynamic Morse-code alphabet loader & converter pub struct Alphab...
code_fim
hard
{ "lang": "rust", "repo": "h5p9sl/morse_bot", "path": "/src/morse.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let converter = Alphabet::new(); assert_eq!( converter.to_morse("Hello World"), ".... . .-.. .-.. --- / .-- --- .-. .-.. -.." ); assert_eq!(converter.to_morse(" Test "), "- . ... -"); assert_eq!(converter.to_morse(".-"), ".-.-.- -....-"...
code_fim
hard
{ "lang": "rust", "repo": "h5p9sl/morse_bot", "path": "/src/morse.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { extern crate test; use crate::morse::*; use test::Bencher; #[bench] fn bench_tests(b: &mut Bencher) { b.iter(|| { to_morse_tests(); from_morse_tests(); }); } #[test] fn to_morse_tests() { let convert...
code_fim
hard
{ "lang": "rust", "repo": "h5p9sl/morse_bot", "path": "/src/morse.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (key, value) in iter { let key = key.as_str(); match key { KEY_CHECKSUM => device.checksum = Some(dbus_str(&value, key).into()), KEY_CREATED => device.created = dbus_u64(&value, key), KEY_DESCRIPTION => device.description ...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/fwupd-dbus", "path": "/src/device.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pop-os/fwupd-dbus path: /src/device.rs use crate::{common::*, dbus_helpers::*, DBusEntry}; use dbus::arg::RefArg; use std::iter::FromIterator; bitflags! { /// Describes attributes of a device. pub struct DeviceFlags: u64 { /// Device cannot be removed easily const INTERN...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/fwupd-dbus", "path": "/src/device.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Checks if the device requires a reboot. pub fn needs_reboot(&self) -> bool { self.has_flag(DeviceFlags::NEEDS_REBOOT) } /// Check if the device must be updated offline. pub fn only_offline(&self) -> bool { self.has_flag(DeviceFlags::ONLY_OFFLINE) } } impl AsRef<DeviceId> for Device {...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/fwupd-dbus", "path": "/src/device.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saf/completers path: /src/lib.rs extern crate array2d; extern crate itertools; extern crate libc;<|fim_suffix|>ters; pub mod config; pub mod core; pub mod scoring; pub mod ui;<|fim_middle|> extern crate log; extern crate term_cursor; extern crate term_size; extern crate termion; extern crate ter...
code_fim
medium
{ "lang": "rust", "repo": "saf/completers", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ize; extern crate termion; extern crate termios; pub mod completers; pub mod config; pub mod core; pub mod scoring; pub mod ui;<|fim_prefix|>// repo: saf/completers path: /src/lib.rs extern crate array2d; extern crate itertools; extern crate libc;<|fim_middle|> extern crate log; extern crate term_cursor...
code_fim
medium
{ "lang": "rust", "repo": "saf/completers", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use Slave::*; let channel = match channel { 1 => Ok(Slave1), 2 => Ok(Slave2), 3 => Ok(Slave3), 4 => Ok(Slave4), _ => Err(Error::InvalidFormat), }?; ...
code_fim
hard
{ "lang": "rust", "repo": "Wassasin/dsmr5", "path": "/src/obis.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wassasin/dsmr5 path: /src/obis.rs use crate::types::*; use crate::{Error, Result}; /// One of two tariffs used by the meter. #[derive(Debug)] pub enum Tariff { Tariff1 = 0, Tariff2 = 1, } /// One of up to three powerlines connected to the meter. #[derive(Debug)] pub enum Line { Lin...
code_fim
hard
{ "lang": "rust", "repo": "Wassasin/dsmr5", "path": "/src/obis.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn perft(p: &Position, depth:usize, positions: &mut Vec<String>){ let hash = calc_position_hash(p); positions.push(format!("{:016x} - {}", hash, render_fen(p))); if depth > 0 { for mv in p.gen_moves() { let mut p1 = *p; p1.apply_move(&mv); //these 2 ...
code_fim
hard
{ "lang": "rust", "repo": "Djuffin/rusty-chess", "path": "/src/hash.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn position_tree_hashes() { ::tables::init_tables(); let mut positions:Vec<String> = Vec::new(); let initial_position = parse_fen("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1").unwrap(); perft(&initial_position, 3, &mut positions); //positions with equ...
code_fim
hard
{ "lang": "rust", "repo": "Djuffin/rusty-chess", "path": "/src/hash.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Djuffin/rusty-chess path: /src/hash.rs //implementation of Zobrist Hashing use tables::get_random_number; use types::*; pub fn calc_position_hash(position: &Position) -> u64 { let mut result:u64 = 0; let board = &position.board; for &color in [White, Black].iter() { for &kin...
code_fim
hard
{ "lang": "rust", "repo": "Djuffin/rusty-chess", "path": "/src/hash.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [`tdt1r`] module"] pub type TDT1R = crate::Reg<tdt1r::TDT1R_SPEC>; #[doc = "mailbox data length control and time stamp register"] pub mod tdt1r; #[doc = "TDL1R (rw) register accessor: mai...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l4/src/stm32l4p5/can1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l4/src/stm32l4p5/can1.rs ister\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`tdl1r::R`]. You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zer...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l4/src/stm32l4p5/can1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l4/src/stm32l4p5/can1.rs `](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`f11r2::W`]. You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#rea...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l4/src/stm32l4p5/can1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn from_dict( mut dict: Dictionary<'a>, resolver: &mut dyn Resolve<'a>, ) -> PdfResult<Self> { dict.expect_type(Self::TYPE, resolver, false)?; let file_system = dict.get_name("Fs", resolver)?; let file_specification_string = dict .get...
code_fim
hard
{ "lang": "rust", "repo": "jungle-bits/pdf", "path": "/src/file_specification.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jungle-bits/pdf path: /src/file_specification.rs use crate::{ assert_empty, catalog::{assert_len, Collection}, error::{ParseError, PdfResult}, objects::{Dictionary, Object, ObjectType}, Resolve, }; #[derive(Debug, Clone, PartialEq)] pub enum FileSpecification<'a> { Simpl...
code_fim
hard
{ "lang": "rust", "repo": "jungle-bits/pdf", "path": "/src/file_specification.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// The standard format for representing a simple file specification in string form divides /// the string into component substrings separated by the SOLIDUS character (2Fh) (/). The /// SOLIDUS is a generic component separator that shall be mapped to the appropriate /// platform-specific separator when g...
code_fim
hard
{ "lang": "rust", "repo": "jungle-bits/pdf", "path": "/src/file_specification.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> type Argv = Argv<3>; type Ret = (); type Staged = Output<'a, CpuidResult, &'a mut CpuidResult>; type Committed = Self::Staged; type Collected = Result<()>; fn stage(self, alloc: &mut impl Allocator) -> Result<(Self::Argv, Self::Staged)> { let result = Output::stage(alloc,...
code_fim
medium
{ "lang": "rust", "repo": "enarx/enarx", "path": "/crates/sallyport/src/guest/call/enarxcall/cpuid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: enarx/enarx path: /crates/sallyport/src/guest/call/enarxcall/cpuid.rs // SPDX-License-Identifier: Apache-2.0 use super::super::types::Argv; use super::Alloc; use crate::guest::alloc::{Allocator, Collect, Collector, Output}; use crate::item::enarxcall::Number; use crate::Result; use core::arch:...
code_fim
hard
{ "lang": "rust", "repo": "enarx/enarx", "path": "/crates/sallyport/src/guest/call/enarxcall/cpuid.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn collect( result: Self::Committed, ret: Result<Self::Ret>, col: &impl Collector, ) -> Self::Collected { if ret.is_ok() { result.collect(col); } ret } }<|fim_prefix|>// repo: enarx/enarx path: /crates/sallyport/src/guest/call/enarxc...
code_fim
hard
{ "lang": "rust", "repo": "enarx/enarx", "path": "/crates/sallyport/src/guest/call/enarxcall/cpuid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imorph/vector path: /src/top/state.rs use std::collections::btree_map::BTreeMap; use tokio::sync::mpsc; type NamedMetric = (String, i64); #[derive(Debug)] pub enum EventType { EventsInTotals(Vec<NamedMetric>), /// Interval in ms + named metric EventsInThroughputs(i64, Vec<NamedMetr...
code_fim
hard
{ "lang": "rust", "repo": "imorph/vector", "path": "/src/top/state.rs", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Prime the receiver with the initial state let _ = tx.send(state.clone()).await; tokio::spawn(async move { loop { if let Some(event_type) = event_rx.recv().await { match event_type { EventType::EventsInTotals(rows) => { ...
code_fim
hard
{ "lang": "rust", "repo": "imorph/vector", "path": "/src/top/state.rs", "mode": "spm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for group in result { assert_eq!(group.hits.len(), group_by_request.group_size); } } } /// Tests out the different features working together. The individual features are already tested in other places. mod group_by_builder { use collection::grouping::GroupBy; use ...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/collection/tests/integration/grouping_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qdrant/qdrant path: /lib/collection/tests/integration/grouping_test.rs erations::PointOperation( Batch { ids: (0..docs * chunks).map(|x| x.into()).collect_vec(), vectors: (0..docs * chunks) .map(|_| rand_vector(&mut rng, 4)) ...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/collection/tests/integration/grouping_test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let result = result.unwrap(); assert_eq!(result.len(), 4); for group in result { assert_eq!(group.hits.len(), group_by_request.group_size); assert!(group.hits[0].payload.is_some()); assert!(group.hits[0].vector.is_some()); } } ...
code_fim
hard
{ "lang": "rust", "repo": "qdrant/qdrant", "path": "/lib/collection/tests/integration/grouping_test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IvoSte/SimpleTragedyofTheCommons path: /Commons/src/main.rs // Modules mod agent; mod commons; mod config; mod experiment; mod statistics; // Aliases use std::error::Error; use std::fs; use std::fs::OpenOptions; use std::path::PathBuf; use std::sync::mpsc::channel; use csv::WriterBuilder; use ...
code_fim
hard
{ "lang": "rust", "repo": "IvoSte/SimpleTragedyofTheCommons", "path": "/Commons/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "Running {} experiment{} with {} generations", CONFIG.simulation.n_experiments, if CONFIG.simulation.n_experiments > 1 { "s" } else { "" }, CONFIG.experiment.n_generations ); if args.output_dir.as_path().exists(...
code_fim
hard
{ "lang": "rust", "repo": "IvoSte/SimpleTragedyofTheCommons", "path": "/Commons/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atonal/learn_rust path: /8/vectors/src/main.rs fn main() { let a: Vec<i32> = Vec::new(); let b = vec![1, 2, 3]; let mut c = Vec::new(); c.push(5); c.push(6); c.push(7); c.push(8); <|fim_suffix|> let mut e = vec![1, 2, 3, 4, 5]; let first = &e[0]; // e.pus...
code_fim
hard
{ "lang": "rust", "repo": "atonal/learn_rust", "path": "/8/vectors/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut e = vec![1, 2, 3, 4, 5]; let first = &e[0]; // e.push(6); // mutable borrow when there is immutable borrow on the line above println!("the first element is {}", first); let f = vec![100, 34, 45]; for i in &f { println!("{}", i); } let mut g = vec![48, 39, ...
code_fim
hard
{ "lang": "rust", "repo": "atonal/learn_rust", "path": "/8/vectors/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rng = thread_rng(); let mut p; loop { p = 2.0 * Vec3::new( rng.gen_range::<f32>(0.0, RAND_END), rng.gen_range::<f32>(0.0, RAND_END), 0.0, ) - Vec3::new(1.0, 1.0, 0.0); if !(dot(&p, &p) >= 1.0) { ...
code_fim
hard
{ "lang": "rust", "repo": "0X1A/raytracerweekend", "path": "/lib/camera.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0X1A/raytracerweekend path: /lib/camera.rs extern crate rand; extern crate std; use std::f32; use super::{cross, dot, unit_vector, Ray, Vec3, RAND_END}; use rand::{thread_rng, Rng}; #[derive(Debug, Clone)] pub struct Camera { lower_left: Vec3, horizontal: Vec3, vertical: Vec3, ...
code_fim
hard
{ "lang": "rust", "repo": "0X1A/raytracerweekend", "path": "/lib/camera.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn into_compile_error(self) -> TokenStream { // compile_error! { $message } TokenStream::from_iter(vec![ TokenTree::Ident(Ident::new("compile_error", self.span)), TokenTree::Punct({ let mut punct = Punct::new('!', Spacing::Alone); ...
code_fim
hard
{ "lang": "rust", "repo": "minikin/keypath", "path": "/keypath-proc-macros/src/keypath_parse.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: minikin/keypath path: /keypath-proc-macros/src/keypath_parse.rs use std::iter::{FromIterator, Peekable}; use proc_macro::token_stream::IntoIter as StreamIter; use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; use quote::quote_spanned; use super::...
code_fim
hard
{ "lang": "rust", "repo": "minikin/keypath", "path": "/keypath-proc-macros/src/keypath_parse.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> lit: &Literal, result: &mut Vec<SpannedComponent>, ) -> Result<(), SyntaxError> { let span = lit.span(); match parse_literal(lit)? { FieldLiteral::Named(name) => result.push(SpannedComponent { element: PathComponent::named(name), span, }), Fi...
code_fim
hard
{ "lang": "rust", "repo": "minikin/keypath", "path": "/keypath-proc-macros/src/keypath_parse.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Trailer starts with 6 bytes of padding let trailer_start = self.reader.seek(SeekFrom::End(-32 + 6))?; let offset_size = self.reader.read_u8()?; match offset_size { 1 | 2 | 4 | 8 => (), _ => return Err(Error::InvalidData) } self.r...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/plist/src/binary/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = match (ty, size) { (0x0, 0x00) => return Err(Error::InvalidData), // null (0x0, 0x08) => Some(PlistEvent::BooleanValue(false)), (0x0, 0x09) => Some(PlistEvent::BooleanValue(true)), (0x0, 0x0f) => return Err(Error::InvalidData), // fill ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/plist/src/binary/reader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /third_party/rust_crates/vendor/plist/src/binary/reader.rs use byteorder::{BigEndian, ReadBytesExt}; use std::io::{Read, Seek, SeekFrom}; use std::mem::size_of; use std::string::{FromUtf8Error, FromUtf16Error}; use {Date, Error, Result, PlistEvent, u64_to_usize}; impl...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/third_party/rust_crates/vendor/plist/src/binary/reader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ekmartin/trawler path: /src/execution/issuer.rs use WorkerCommand; use client::LobstersClient; use crossbeam_channel; use execution::Stats; use futures::Future; use hdrhistogram::Histogram; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; use std::{mem, time}; use tokio_co...
code_fim
hard
{ "lang": "rust", "repo": "ekmartin/trawler", "path": "/src/execution/issuer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> barrier.wait(); } Ok(WorkerCommand::Start(barrier)) => { { while *in_flight.borrow_mut() > 0 { core.turn(None); } } barrier.wait(); // st...
code_fim
hard
{ "lang": "rust", "repo": "ekmartin/trawler", "path": "/src/execution/issuer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>This isn't as fast as some of our previous examples where we used the `csv` crate to read into a `StringRecord` or a `ByteRecord`. This is mostly because this example reads a field at a time, which incurs more overhead than reading a record at a time. To fix this, you would want to use the [`Reader::read_...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-csv", "path": "/src/tutorial.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/rust-csv path: /src/tutorial.rs t). Since we put them in a slice literal, the type of our parameter is `&'static [&'static str]`, or more succinctly written as `&[&str]` without the lifetime annotations. Since slices satisfy the `IntoIterator` bound and strings satisfy the `AsRef<[u8]...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-csv", "path": "/src/tutorial.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BurntSushi/rust-csv path: /src/tutorial.rs reader(io::stdin()); for result in rdr.records() { // Examine our Result. // If there was no problem, print the record. // Otherwise, print the error message and quit the program. match result { Ok(record)...
code_fim
hard
{ "lang": "rust", "repo": "BurntSushi/rust-csv", "path": "/src/tutorial.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_varint_prefixed_bytes(&mut self) -> Result<Vec<u8>, BufErr> { let size = self.read_varint()? as usize; let mut v = vec![0; size]; self.c.read_exact(&mut v)?; Ok(v) } pub fn read_remainder(&mut self) -> Result<Vec<u8>, BufErr> { let size = se...
code_fim
hard
{ "lang": "rust", "repo": "Gjum/voxelmap-cache", "path": "/src/buf_rw.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gjum/voxelmap-cache path: /src/buf_rw.rs extern crate rustc_serialize; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use std::fmt; use std::io::{Cursor, Read, Write}; error_chain!{ types { BufErr, BufErrorKind, BufResult; } foreign_links { Io(::std::io::E...
code_fim
hard
{ "lang": "rust", "repo": "Gjum/voxelmap-cache", "path": "/src/buf_rw.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plippe/tic-tac-toe-rust path: /src/main.rs use std::io; use std::str::FromStr; mod lib; use crate::lib::board::Board; use crate::lib::coordinates::Coordinates; use crate::lib::game::Game; use crate::lib::player::Player; use crate::lib::state::State; fn start_game(game: &Game) -> State { S...
code_fim
hard
{ "lang": "rust", "repo": "plippe/tic-tac-toe-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn read_input<A: FromStr>() -> Result<A, String> { let mut input = String::new(); io::stdin() .read_line(&mut input) .map_err(|e| format!("Input can't be read: {}", e)) .and_then(|_| { input .trim() .parse::<A>() ....
code_fim
hard
{ "lang": "rust", "repo": "plippe/tic-tac-toe-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for arg in args[1..].iter() { let file = match File::open(arg) { Err(e) => return Err(e), Ok(file) => file, }; let reader = BufReader::new(file); for line in reader.lines() { let l = line?; if l.contains(pattern) { ...
code_fim
medium
{ "lang": "rust", "repo": "kaneshin/rustil", "path": "/src/grep.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaneshin/rustil path: /src/grep.rs use std::fs::File; use std::io::{self, BufRead, BufReader}; pub const SYNOPSIS: &str = "grep [PATTERN] [FILE]..."; <|fim_suffix|> let reader = BufReader::new(file); for line in reader.lines() { let l = line?; if l.contai...
code_fim
hard
{ "lang": "rust", "repo": "kaneshin/rustil", "path": "/src/grep.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mijalk0/glium-physics path: /src/import.rs sion_offset in 0..dimension { let start = offset + (i * stride) + (dimension_offset * data_type.size()); let end = start + data_type.size(); let bytes = &buffer[start..end]; //TODO find crate to do this ...
code_fim
hard
{ "lang": "rust", "repo": "mijalk0/glium-physics", "path": "/src/import.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn load_material<F: ?Sized, P>( facade: &F, material: GltfMaterial, material_location: P, ) -> InternalMaterial where F: Facade, P: AsRef<Path>, { let diffuse_map_source = match material.pbr_metallic_roughness().base_color_texture() { Some(texture) => texture, N...
code_fim
hard
{ "lang": "rust", "repo": "mijalk0/glium-physics", "path": "/src/import.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let normal_map_source = match material.normal_texture() { Some(texture) => texture, None => return load_missing_material(facade), } .texture() .source() .source(); let normal_map = if let ImageSource::Uri { uri: path, .. } = normal_map_source { load_rgba_te...
code_fim
hard
{ "lang": "rust", "repo": "mijalk0/glium-physics", "path": "/src/import.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use std::collections::HashMap; impl Solution { pub fn partition_labels(s: String) -> Vec<i32> { let n = s.len(); let mut ans = vec![]; let mut last = 0; let mut i = 0; let mut k = 0; let s = s.as_bytes(); while i < n { let mut h = Has...
code_fim
medium
{ "lang": "rust", "repo": "lythesia/leet", "path": "/rs/src/quests/partition_labels.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lythesia/leet path: /rs/src/quests/partition_labels.rs /** * [763] Partition Labels * * You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. Note that the partition is done so that after concatenating all the...
code_fim
hard
{ "lang": "rust", "repo": "lythesia/leet", "path": "/rs/src/quests/partition_labels.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test() { assert_eq!(vec![9,7,8], Solution::partition_labels("ababcbacadefegdehijhklij".into())); assert_eq!(vec![10], Solution::partition_labels("eccbbbbdec".into())); } }<|fim_prefix|>// repo: lythesia/leet path: /rs/src/quests/partition_labels.rs /** * [763] Part...
code_fim
hard
{ "lang": "rust", "repo": "lythesia/leet", "path": "/rs/src/quests/partition_labels.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Path<String>) -> impl Responder { HttpResponse::Ok().body(format!("user_id is {}", user_id)) }<|fim_prefix|>// repo: RimlTempest/rust_web path: /src/controllers/get_user_id.rs use actix_web::{web, HttpResponse, Responder}; p<|fim_middle|>ub async fn get_user_id(web::Path(user_id): web::
code_fim
easy
{ "lang": "rust", "repo": "RimlTempest/rust_web", "path": "/src/controllers/get_user_id.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RimlTempest/rust_web path: /src/controllers/get_user_id.rs use actix_web::{web, HttpResponse, Responder}; p<|fim_suffix|>Path<String>) -> impl Responder { HttpResponse::Ok().body(format!("user_id is {}", user_id)) }<|fim_middle|>ub async fn get_user_id(web::Path(user_id): web::
code_fim
easy
{ "lang": "rust", "repo": "RimlTempest/rust_web", "path": "/src/controllers/get_user_id.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: milky2028/rust-calcs2 path: /src/fns.rs #[cfg(target_arch = "wasm32")] use serde::{Deserialize, Serialize}; <|fim_suffix|>#[cfg_attr(not(target_arch = "wasm32"), no_mangle)] pub fn total(data: &Vec<Data>) -> f64 { data.iter().fold(0_f64, |acc, i| acc + i.value) }<|fim_middle|>#[cfg_attr(tar...
code_fim
medium
{ "lang": "rust", "repo": "milky2028/rust-calcs2", "path": "/src/fns.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg_attr(not(target_arch = "wasm32"), no_mangle)] pub fn total(data: &Vec<Data>) -> f64 { data.iter().fold(0_f64, |acc, i| acc + i.value) }<|fim_prefix|>// repo: milky2028/rust-calcs2 path: /src/fns.rs #[cfg(target_arch = "wasm32")] use serde::{Deserialize, Serialize}; <|fim_middle|>#[cfg_attr(tar...
code_fim
medium
{ "lang": "rust", "repo": "milky2028/rust-calcs2", "path": "/src/fns.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &'a mut W { self.bit(false) } #[doc = r" Writes raw bits to the field"] #[inline] pub fn bit(self, value: bool) -> &'a mut W { const MASK: bool = true; const OFFSET: u8 = 6; self.w.bits &= !((MASK as u32) << OFFSET); self.w.bits |= ((value & MASK) a...
code_fim
hard
{ "lang": "rust", "repo": "dfrankland/mk20d7", "path": "/src/can0/iflag1/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dfrankland/mk20d7 path: /src/can0/iflag1/mod.rs #[doc = r" Reserved"] _Reserved(u8), } impl BUF4TO0IR { #[doc = r" Value of the field as raw bits"] #[inline] pub fn bits(&self) -> u8 { match *self { BUF4TO0IR::_0 => 0, BUF4TO0IR::_1 => 1, ...
code_fim
hard
{ "lang": "rust", "repo": "dfrankland/mk20d7", "path": "/src/can0/iflag1/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ted transmission/reception (when MCR[RFEN]=0) or Rx FIFO overflow (when MCR[RFEN]=1)"] _1, } impl BUF7IW { #[allow(missing_docs)] #[doc(hidden)] #[inline] pub fn _bits(&self) -> bool { match *self { BUF7IW::_0 => false, BUF7IW::_1 => true, } ...
code_fim
hard
{ "lang": "rust", "repo": "dfrankland/mk20d7", "path": "/src/can0/iflag1/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: starblue/dust path: /dust-lpc8xx/src/swm/swm_lpc84x.rs //! SWM peripheral unit for LPC84x //! //! TODO Checked against UM11029 2017-12-08. use crate::swm::{FixedFunction, MovableFunction}; pub const PINASSIGN_REGISTERS: usize = 15; pub const PINASSIGN_FIXED_REGISTERS: usize = 0; pub const PINE...
code_fim
hard
{ "lang": "rust", "repo": "starblue/dust", "path": "/dust-lpc8xx/src/swm/swm_lpc84x.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>movable_function!(T0_MAT3, 14, 0); movable_function!(T0_CAP0, 14, 1); movable_function!(T0_CAP1, 14, 2); movable_function!(T0_CAP2, 14, 3); fixed_pin_function!(ACMP_I1, 0, 0); fixed_pin_function!(ACMP_I2, 0, 1); fixed_pin_function!(ACMP_I3, 0, 2); fixed_pin_function!(ACMP_I4, 0, 3); fixed_pin_function!(A...
code_fim
hard
{ "lang": "rust", "repo": "starblue/dust", "path": "/dust-lpc8xx/src/swm/swm_lpc84x.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let number = num.trim().parse().unwrap(); let mut index = 1; while index <= number { if index == 1 { println!("*"); } else if index == 2 { println!("**"); } else if index == 3 { println!("***"); } else if index == 4 { println!("****"); } else if index == 5 { println!(...
code_fim
medium
{ "lang": "rust", "repo": "kamranajabbar/aiot_rust_q1_assignment2", "path": "/src/question_05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kamranajabbar/aiot_rust_q1_assignment2 path: /src/question_05.rs use std::io; pub fn run() { println!("Please enter number between 1-10"); let mut user_input = String::new(); io::stdin().read_line(&mut user_input).expect("Failed to read number"); println!("\n"); <|fim_suffix|> let number ...
code_fim
medium
{ "lang": "rust", "repo": "kamranajabbar/aiot_rust_q1_assignment2", "path": "/src/question_05.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn finish(&mut self, outdata: &mut [u8]) -> Result<usize> { // Check that minimum required space is available in outdata buffer if outdata.len() < self.block_size() { return Err(Error::CipherFullBlockExpected); } let mut olen = 0; unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "raoulstrackx/rust-mbedtls", "path": "/mbedtls/src/cipher/raw/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: raoulstrackx/rust-mbedtls path: /mbedtls/src/cipher/raw/mod.rs /* Copyright (c) Fortanix, Inc. * * Licensed under the GNU General Public License, version 2 <LICENSE-GPL or * https://www.gnu.org/licenses/gpl-2.0.html> or the Apache License, Version * 2.0 <LICENSE-APACHE or http://www.apache.o...
code_fim
hard
{ "lang": "rust", "repo": "raoulstrackx/rust-mbedtls", "path": "/mbedtls/src/cipher/raw/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }