text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let resultado = numero_uno + numero_dos + VALOR; println!("EL resultado de ({} + {} + {}) es: {}", numero_uno, numero_dos, VALOR, resultado); }<|fim_prefix|>// repo: cesantaniello/Rust path: /variables/src/main.rs fn main() { //let <nombre de la variable> = <El valor> //let <nombre d...
code_fim
medium
{ "lang": "rust", "repo": "cesantaniello/Rust", "path": "/variables/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Fail)] pub(crate) enum QnChangelogError { #[fail(display = "unexpected input")] UnexpectedInput, }<|fim_prefix|>// repo: xen0n/qn-changelog-rs path: /src/errors.rs use failure::Error; <|fim_middle|>pub(crate) type Result<T> = ::std::result::Result<T, Error>;
code_fim
medium
{ "lang": "rust", "repo": "xen0n/qn-changelog-rs", "path": "/src/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xen0n/qn-changelog-rs path: /src/errors.rs use failure::Error; <|fim_suffix|>#[derive(Debug, Fail)] pub(crate) enum QnChangelogError { #[fail(display = "unexpected input")] UnexpectedInput, }<|fim_middle|>pub(crate) type Result<T> = ::std::result::Result<T, Error>;
code_fim
medium
{ "lang": "rust", "repo": "xen0n/qn-changelog-rs", "path": "/src/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/memoffset/src/lib.rs / / Copyright ( c ) 2017 Gilad Naaman / / / / Permission is hereby granted free of charge to any person obtaining a copy / / of this software and associated documentation files ( the " Software " ) to deal / / in the Softwa...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/memoffset/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>tFactory a ) 15 ) ; / / ! assert_eq ! ( span_of ! ( HelpMeIAmTrappedInAStructFactory a ) 15 . . 19 ) ; / / ! assert_eq ! ( span_of ! ( HelpMeIAmTrappedInAStructFactory help_me_before_they_ . . a ) 0 . . 15 ) ; / / ! } / / ! / / ! / / ! This functionality can be useful for example for checksum calculations...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/memoffset/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>re = " unstable_const " feature ( const_refs_to_cell ) ) ] # ! [ cfg_attr ( feature = " unstable_offset_of " feature ( allow_internal_unstable ) ) ] # [ macro_use ] # [ cfg ( doctests ) ] # [ cfg ( doctest ) ] extern crate doc_comment ; # [ cfg ( doctests ) ] # [ cfg ( doctest ) ] doctest ! ( " . . / READ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/memoffset/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kmeisthax/retrogram path: /src/memory/endianness.rs //! Types to represent endianness. /// Indicates the byte (or memory unit) order when reading words from memor<|fim_suffix|>t significant bit first. /// /// This is the same order as how English writes numbers. BigEndian, }<|fim_mi...
code_fim
hard
{ "lang": "rust", "repo": "kmeisthax/retrogram", "path": "/src/memory/endianness.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>t significant bit first. /// /// This is the same order as how English writes numbers. BigEndian, }<|fim_prefix|>// repo: kmeisthax/retrogram path: /src/memory/endianness.rs //! Types to represent endianness. /// Indicates the byte (or memory unit) order when reading words from memory. pub e...
code_fim
medium
{ "lang": "rust", "repo": "kmeisthax/retrogram", "path": "/src/memory/endianness.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(unix)] fn convert_permissions(mode: u32) -> Option<fs::Permissions> { use std::os::unix::fs::PermissionsExt; Some(fs::Permissions::from_mode(mode)) } #[cfg(not(unix))] fn convert_permissions(_mode: u32) -> Op...
code_fim
hard
{ "lang": "rust", "repo": "reidwagner/prost", "path": "/prost-build/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reidwagner/prost path: /prost-build/src/lib.rs #![doc(html_root_url = "https://docs.rs/prost-build/0.1.1")] extern crate bytes; extern crate curl; extern crate prost; extern crate prost_codegen; extern crate tempdir; extern crate zip; use std::env; use std::fs; use std::io::{ self, Cur...
code_fim
hard
{ "lang": "rust", "repo": "reidwagner/prost", "path": "/prost-build/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doc22940/relay path: /compiler/crates/relay-codegen/src/build_codegen_ast.rs /* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::codegen_ast::*; use...
code_fim
hard
{ "lang": "rust", "repo": "doc22940/relay", "path": "/compiler/crates/relay-codegen/src/build_codegen_ast.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { schema, variant } } fn build_operation(&self, operation: &OperationDefinition) -> ConcreteDefinition { ConcreteDefinition::Operation(ConcreteOperation { name: operation.name.item.lookup(), argument_definitions: self .build_operation_v...
code_fim
hard
{ "lang": "rust", "repo": "doc22940/relay", "path": "/compiler/crates/relay-codegen/src/build_codegen_ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: subspace/subspace path: /crates/sc-subspace-block-relay/src/utils.rs //! Common utils. use codec::{Decode, Encode}; use futures::channel::oneshot; use parking_lot::Mutex; use sc_network::request_responses::IfDisconnected; use sc_network::types::ProtocolName; use sc_network::{NetworkRequest, Pee...
code_fim
hard
{ "lang": "rust", "repo": "subspace/subspace", "path": "/crates/sc-subspace-block-relay/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { protocol_name, who, network, } } /// Performs the request pub(crate) async fn request<Request, Response>( &self, request: Request, ) -> Result<Response, RequestResponseErr> where Request: Encode, ...
code_fim
hard
{ "lang": "rust", "repo": "subspace/subspace", "path": "/crates/sc-subspace-block-relay/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>flvl(&self) -> FLVL_R { FLVL_R::new(((self.bits >> 16) & 7) as u8) } } #[doc = "Status register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`sai_bsr::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."] pub struct SAI_BSR_SPEC; impl crate::Register...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/sai1/sai_bsr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp157/sai1/sai_bsr.rs #[doc = "Register `SAI_BSR` reader"] pub type R = crate::R<SAI_BSR_SPEC>; #[doc = "Field `OVRUDR` reader - OVRUDR"] pub type OVRUDR_R = crate::BitReader; #[doc = "Field `MUTEDET` reader - MUTEDET"] pub type MUTEDET_R = cr...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp157/sai1/sai_bsr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> struct Config { brokers: Vec<String>, client_cert: Option<String>, client_key: Option<String>, ca_cert: Option<String>, verify_hostname: bool, } impl Config { fn from_cmdline() -> Result<Config, String> { let mut opts = getopts::Opti...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-demo/kafka-rust/examples/example-ssl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-demo/kafka-rust/examples/example-ssl.rs #[macro_use] extern crate log; fn main() { example::main(); } #[cfg(feature = "security")] mod example { extern crate kafka; extern crate openssl; use std::env; use std::process; use self::kafka::...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-demo/kafka-rust/examples/example-ssl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl UltradebugGpio { /// Request the upstream SPI bus to tristate so ultradebug may drive the SPI bus (platforms-ultradebug only). pub const PIN_SPI_ZB: u8 = 4; /// Reset the chip attached to ultradebug. pub const PIN_RESET_B: u8 = 5; /// Request bootstrap mode on the chip attached to...
code_fim
hard
{ "lang": "rust", "repo": "antmicro/opentitan", "path": "/sw/host/opentitanlib/src/transport/ultradebug/gpio.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match strap { StrapConfig::None => self.write("BOOTSTRAP", false), StrapConfig::RomBootstrap => self.write("BOOTSTRAP", true), _ => Err(GpioError::InvalidStrapConfig(strap).into()), } } } lazy_static! { static ref PIN_NAMES: HashMap<&'static str...
code_fim
hard
{ "lang": "rust", "repo": "antmicro/opentitan", "path": "/sw/host/opentitanlib/src/transport/ultradebug/gpio.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: antmicro/opentitan path: /sw/host/opentitanlib/src/transport/ultradebug/gpio.rs // Copyright lowRISC contributors. // Licensed under the Apache License, Version 2.0, see LICENSE for details. // SPDX-License-Identifier: Apache-2.0 use anyhow::{ensure, Result}; use lazy_static::lazy_static; use s...
code_fim
hard
{ "lang": "rust", "repo": "antmicro/opentitan", "path": "/sw/host/opentitanlib/src/transport/ultradebug/gpio.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn get_as_smt_predicate(&self, _mirai_expression: &Expression) -> usize { 0 } fn get_model_as_string(&self) -> String { String::from("not implemented") } fn get_solver_state_as_string(&self) -> String { String::from("not implemented") } fn invert_pre...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/MIRAI", "path": "/checker/src/smt_solver.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Provides a string that contains a set of variable assignments that satisfied the /// assertions in the solver. Can only be called after self.solve return SmtResult::Satisfiable. fn get_model_as_string(&self) -> String; /// Provides a string that contains a listing of all of the defini...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/MIRAI", "path": "/checker/src/smt_solver.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebookexperimental/MIRAI path: /checker/src/smt_solver.rs // Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. use crate::expression::Expression; use mirai_annotati...
code_fim
hard
{ "lang": "rust", "repo": "facebookexperimental/MIRAI", "path": "/checker/src/smt_solver.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Create a new set of params with pretty printing. let params = RequestParams::default().url_param("pretty", true); // Create a query DSL request body. let req = { let query = "*"; let body = json!({ "query": { "query_string": { ...
code_fim
hard
{ "lang": "rust", "repo": "GyrosOfWar/elastic", "path": "/src/reqwest/examples/basic_async.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GyrosOfWar/elastic path: /src/reqwest/examples/basic_async.rs //! Elasticsearch Reqwest Client Samples //! //! This sample assumes you have a node running on `localhost`. //! //! This minimal sample executes a simple search request against all indices. //! To make things readable, the `pretty` u...
code_fim
hard
{ "lang": "rust", "repo": "GyrosOfWar/elastic", "path": "/src/reqwest/examples/basic_async.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/prob_1334.rs impl Solution { pub fn find_the_city(n: i32, edges: Vec<Vec<i32>>, distance_threshold: i32) -> i32 { let n = n as usize; const INF: i32 = std::i32::MAX/2; let mut f = vec![vec![INF; n]; n]; for edge in edges { ...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_1334.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::Solution; #[test] fn test_find_the_city() { let test_cases = vec![ (4, vec![ vec![0,1,3],vec![1,2,1],vec![1,3,4],vec![2,3,1], ], 4, 3), (5, vec![ vec![0,1,2],vec![0,4,8],vec![1,2,3]...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/prob_1334.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> fmt::Display for SqueryCommand<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {} :{}", CMD_SQUERY, self.servicename, self.text) } } impl<'a> IrcMessage<'a> for SqueryCommand<'a> { fn from_raw(raw: &RawMessage<'a>) -> Result<SqueryCommand<'a>, Parse...
code_fim
hard
{ "lang": "rust", "repo": "zonyitoo/irc-rs", "path": "/src/protocol/command/squery.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zonyitoo/irc-rs path: /src/protocol/command/squery.rs use std::fmt; use protocol::command::CMD_SQUERY; use protocol::message::{IrcMessage, RawMessage, ParseMessageError, ParseMessageErrorKind}; #[derive(Debug, Clone, Eq, PartialEq)] pub struct SqueryCommand<'a> { servicename: &'a str, ...
code_fim
medium
{ "lang": "rust", "repo": "zonyitoo/irc-rs", "path": "/src/protocol/command/squery.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "{} {} :{}", CMD_SQUERY, self.servicename, self.text) } } impl<'a> IrcMessage<'a> for SqueryCommand<'a> { fn from_raw(raw: &RawMessage<'a>) -> Result<SqueryCommand<'a>, ParseMessageError> { let mut params = raw.parameters(); let (sn, t) = match (param...
code_fim
medium
{ "lang": "rust", "repo": "zonyitoo/irc-rs", "path": "/src/protocol/command/squery.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for e in entries { let entry = e.unwrap(); if entry.path().is_file() { scripts.push(Script::new(entry.path().to_str().unwrap())); } else { scripts.extend(Script::load_all(&entry.path())) } } scripts } }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "redcodestudios/bracket-lib", "path": "/bracket-script/src/script.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Load all scripts inside a directory and his children recursively. pub fn load_all(dir_path: &Path) -> Vec<Script> { let entries = fs::read_dir(dir_path).unwrap(); let mut scripts: Vec<Script> = Vec::new(); for e in entries { let entry = e.unwrap(); if ...
code_fim
medium
{ "lang": "rust", "repo": "redcodestudios/bracket-lib", "path": "/bracket-script/src/script.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redcodestudios/bracket-lib path: /bracket-script/src/script.rs use std::path::{PathBuf, Path}; use std::fs; use std::io::Read; #[derive(Clone)] pub enum ScriptState {Loaded, Unloaded} #[derive(Clone)] pub struct Script { pub path: PathBuf, pub bytes: Vec<u8>, pub state: ScriptState...
code_fim
hard
{ "lang": "rust", "repo": "redcodestudios/bracket-lib", "path": "/bracket-script/src/script.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod client; mod engines; mod error; mod messages; mod server; pub mod thread_pool;<|fim_prefix|>// repo: QuRyu/kvs path: /src/lib.rs #![deny(missing_docs)] //! A simple key/value store. <|fim_middle|>pub use client::KvsClient; pub use engines::{KvStore, KvsEngine, SledKvsEngine}; pub use error::{KvsErro...
code_fim
hard
{ "lang": "rust", "repo": "QuRyu/kvs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: QuRyu/kvs path: /src/lib.rs #![deny(missing_docs)] //! A simple key/value store. <|fim_suffix|>mod client; mod engines; mod error; mod messages; mod server; pub mod thread_pool;<|fim_middle|>pub use client::KvsClient; pub use engines::{KvStore, KvsEngine, SledKvsEngine}; pub use error::{KvsErro...
code_fim
hard
{ "lang": "rust", "repo": "QuRyu/kvs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: exscape/Rust path: /euler/37.rs extern crate exscape; use exscape::{trunc_left, trunc_right, is_prime}; use std::iter::count; <|fim_suffix|> let mut found = 0; let mut sum = 0; 'outer: for candidate in count(11u, 2) { let mut left = candidate; let mut right = candidate; while left > 0 ...
code_fim
medium
{ "lang": "rust", "repo": "exscape/Rust", "path": "/euler/37.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 'outer: for candidate in count(11u, 2) { let mut left = candidate; let mut right = candidate; while left > 0 && right > 0 { if !is_prime(left) || !is_prime(right) { continue 'outer; } left = trunc_left(left); right = trunc_right(right); } // If we get here, the loop completed and all ...
code_fim
medium
{ "lang": "rust", "repo": "exscape/Rust", "path": "/euler/37.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut found = 0; let mut sum = 0; 'outer: for candidate in count(11u, 2) { let mut left = candidate; let mut right = candidate; while left > 0 && right > 0 { if !is_prime(left) || !is_prime(right) { continue 'outer; } left = trunc_left(left); right = trunc_right(right); } // If w...
code_fim
medium
{ "lang": "rust", "repo": "exscape/Rust", "path": "/euler/37.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // set up the transactions let transfer_amount = 1_000; // insert a block prologue transaction let (txns_info, transfer_txns) = create_cyclic_transfers(&executor, &accounts, transfer_amount); executor.enable_parallel_execution(); let outputs = executor.execute_block(transfer_txn...
code_fim
hard
{ "lang": "rust", "repo": "richardsj/libra", "path": "/diem-move/e2e-testsuite/src/tests/parallel_execution.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: richardsj/libra path: /diem-move/e2e-testsuite/src/tests/parallel_execution.rs // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::tests::peer_to_peer::{check_and_apply_transfer_output, create_cyclic_transfers}; use diem_crypto::{ed25519::Ed25519Private...
code_fim
hard
{ "lang": "rust", "repo": "richardsj/libra", "path": "/diem-move/e2e-testsuite/src/tests/parallel_execution.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Derive to add Toql functionality to your struct. #[proc_macro_derive(Toql, attributes(toql))] pub fn toql_derive(input: TokenStream) -> TokenStream { let _ = env_logger::try_init(); // Avoid multiple init let ast = parse_macro_input!(input as DeriveInput); let generated_result = annot...
code_fim
hard
{ "lang": "rust", "repo": "CinchBlue/toql", "path": "/toql_derive/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CinchBlue/toql path: /toql_derive/src/lib.rs //! //! The Toql Derive creates all the boilerplate functions to make the ✨ happen. //! Using the derive is the easiest way to deal with your structs and is therefore recommended. //! However beware that the generated code size can become large as it'...
code_fim
hard
{ "lang": "rust", "repo": "CinchBlue/toql", "path": "/toql_derive/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Instnatiate a new fraction /// /// This constructor takes as arguments the numerator and denominator, both /// as u128s, as well as the sign of the fraction. `true` represents /// a negative value, `false` represents a positive value. /// /// Examples: /// ``` /// u...
code_fim
medium
{ "lang": "rust", "repo": "nekodjin/frac", "path": "/src/frac/impls/associated_funcs.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nekodjin/frac path: /src/frac/impls/associated_funcs.rs use super::super::Frac; macro_rules! is_neg { ($x:expr) => { $x < 0 }; } macro_rules! unsign { ($x:expr) => { (if is_neg!($x) { -$x } else { $x }) as u128 }; } <|fim_suffix|> let num = num / gcd; let de...
code_fim
hard
{ "lang": "rust", "repo": "nekodjin/frac", "path": "/src/frac/impls/associated_funcs.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>We'll stick with this initialization for now... */ pub fn init() { let gpio_pa_base: u32 = 0x40006000; let gpio_pc_base: u32 = 0x40006048; let gpio_pc_model: *mut u32 = (gpio_pc_base + 0x04) as *mut u32; let gpio_pc_dout: *mut u32 = (gpio_pc_base + 0x0c) as *mut u3...
code_fim
hard
{ "lang": "rust", "repo": "RustyGecko/circle-game", "path": "/src/gamepad.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustyGecko/circle-game path: /src/gamepad.rs /* This approach makes button interrupts a lot faster, probably due to the way interrupts are handled by the 'gpioint' module. This way we ignore everything with functions specific for each interrupt, and clear it in the main loop instead. However, it...
code_fim
hard
{ "lang": "rust", "repo": "RustyGecko/circle-game", "path": "/src/gamepad.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seventh-estate/seventh-estate path: /src/ballots/printed.rs //! # Printed Ballot Information //! //! `printed` contains type aliases to identify information that is //! suitable for printing on the printed ballots. <|fim_suffix|>pub type PrintedBallotSerial = BallotSerial; pub type PrintedVoteC...
code_fim
easy
{ "lang": "rust", "repo": "seventh-estate/seventh-estate", "path": "/src/ballots/printed.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type PrintedBallotSerial = BallotSerial; pub type PrintedVoteCode = VoteCode; pub type PrintedChoiceValue = ChoiceValue;<|fim_prefix|>// repo: seventh-estate/seventh-estate path: /src/ballots/printed.rs //! # Printed Ballot Information //! //! `printed` contains type aliases to identify information t...
code_fim
easy
{ "lang": "rust", "repo": "seventh-estate/seventh-estate", "path": "/src/ballots/printed.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// fourth audio PID. pub const DMX_PES_AUDIO3: u32 = 15; /// fourth video PID. pub const DMX_PES_VIDEO3: u32 = 16; /// fourth teletext PID. pub const DMX_PES_TELETEXT3: u32 = 17; /// fourth subtitle PID. pub const DMX_PES_SUBTITLE3: u...
code_fim
hard
{ "lang": "rust", "repo": "cesbo/libdvb", "path": "/src/dmx/sys.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cesbo/libdvb path: /src/dmx/sys.rs use { crate::ioctl::{ IoctlInt, io_none, io_write, }, }; pub use { dmx_output::*, dmx_input::*, dmx_ts_pes::*, dmx_filter_flags::*, }; /// Output for the demux mod dmx_output { /// Streaming directly to de...
code_fim
hard
{ "lang": "rust", "repo": "cesbo/libdvb", "path": "/src/dmx/sys.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// type of the PES filter mod dmx_ts_pes { /// first audio PID pub const DMX_PES_AUDIO0: u32 = 0; /// first video PID pub const DMX_PES_VIDEO0: u32 = 1; /// first teletext PID pub const DMX_PES_TELETEXT0: u32 = 2; /// first subtitle PID ...
code_fim
hard
{ "lang": "rust", "repo": "cesbo/libdvb", "path": "/src/dmx/sys.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // If there are more columns in the drop selection list, these // are added from the resulting dataframe let res = col_string.iter().skip(1).try_fold(new_df, |new_df, col| { new_df .drop(col) ...
code_fim
hard
{ "lang": "rust", "repo": "apatrushev/nushell", "path": "/crates/nu-command/src/commands/dataframe/drop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (col_string, col_span) = convert_columns(&columns, &tag)?; match args.input.next() { None => Err(ShellError::labeled_error( "No input received", "missing dataframe input from stream", &tag, )), Some(value) => { if let Unt...
code_fim
hard
{ "lang": "rust", "repo": "apatrushev/nushell", "path": "/crates/nu-command/src/commands/dataframe/drop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apatrushev/nushell path: /crates/nu-command/src/commands/dataframe/drop.rs use crate::prelude::*; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{ dataframe::{NuDataFrame, PolarsData}, Signature, SyntaxShape, UntaggedValue, Value, }; use super::utils::{co...
code_fim
hard
{ "lang": "rust", "repo": "apatrushev/nushell", "path": "/crates/nu-command/src/commands/dataframe/drop.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AndreasChristianson/project-euler-rust path: /tests/pe-10.rs extern crate project_euler_rust; use project_euler_rust::generators::primes::*; <|fim_suffix|> let generator: PrimeSequence<u128> = primes(); let sum: u128 = generator.take_while(|&p| p < 2_000_000).sum(); assert_eq!(sum, ...
code_fim
hard
{ "lang": "rust", "repo": "AndreasChristianson/project-euler-rust", "path": "/tests/pe-10.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn solution() { let generator: PrimeSequence<u128> = primes(); let sum: u128 = generator.take_while(|&p| p < 2_000_000).sum(); assert_eq!(sum, 142913828922); }<|fim_prefix|>// repo: AndreasChristianson/project-euler-rust path: /tests/pe-10.rs extern crate project_euler_rust; use proj...
code_fim
hard
{ "lang": "rust", "repo": "AndreasChristianson/project-euler-rust", "path": "/tests/pe-10.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Into<SocketAddr> for Peer { fn into(self) -> SocketAddr { SocketAddr::new(self.ip, self.port) } } #[cfg(test)] mod tests { use super::*; use std::net::{IpAddr, Ipv4Addr}; #[test] fn parse_peer() { let peer_bytes = b"d2:ip9:127.0.0.17:peer id20:rsbt ...
code_fim
hard
{ "lang": "rust", "repo": "kilork/rustorrent", "path": "/service/src/types/peer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kilork/rustorrent path: /service/src/types/peer.rs use crate::{ errors::TryFromBencode, types::{BencodeBlob, BencodeValue}, RsbtError, }; use std::{ convert::{TryFrom, TryInto}, net::{IpAddr, Ipv4Addr, SocketAddr}, }; #[derive(Debug, PartialEq, Clone)] pub struct Peer { ...
code_fim
hard
{ "lang": "rust", "repo": "kilork/rustorrent", "path": "/service/src/types/peer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let reply = run(&opt.host, "help")?; let mut table = Table::new(); let format = format::FormatBuilder::new() .column_separator('|') .separators(&[], format::LineSeparator::new('-', '+', '+', '+')) .padding(1, 1) .build(); table.set_format(format); table....
code_fim
hard
{ "lang": "rust", "repo": "meatlink/northstar", "path": "/dcon/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meatlink/northstar path: /dcon/src/main.rs // Copyright (c) 2019 - 2020 ESRLabs // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache....
code_fim
hard
{ "lang": "rust", "repo": "meatlink/northstar", "path": "/dcon/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Altronix/linq-rs path: /crates/linq-io/src/io.rs use super::request::*; use super::update::*; use super::usb::usb::Usb; use super::usb::{UsbChannel, UsbMetadata}; use crate::channel::Channel; use crate::error::{IoError, Result as IoResult}; use futures::future::LocalBoxFuture; use futures::prelu...
code_fim
hard
{ "lang": "rust", "repo": "Altronix/linq-rs", "path": "/crates/linq-io/src/io.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Print out some version information pub fn version<'a>() -> &'static str { Usb::version() } /// Delete all channels, free any threads, etc. Essentially an explicit /// destructor. It is recommend to join threads explicitly as opposed to in /// a drop routine. (If you fo...
code_fim
hard
{ "lang": "rust", "repo": "Altronix/linq-rs", "path": "/crates/linq-io/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // The first KB should still have the old data in it. assert_eq !(slice[ONE_K - 1], 0xFF); // The additional range should be zero-init'd and accessible. assert_eq !(slice[10 * ONE_K - 1], 0x00); slice[10 * ONE_K - 1] = 0xFF; assert_eq !(slice[10 * ONE_K - 1], 0xFF); } #[test] #[c...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/nix-0.20.0/test/sys/test_mman.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/nix-0.20.0/test/sys/test_mman.rs use nix::Error; use nix::libc::{c_void, size_t}; use nix::sys::mman::{mmap, MapFlags, ProtFlags}; #[cfg(target_os = "linux")] use nix::sys::mman::{mremap, MRemapFlags}; #[test] fn test_mmap_anonymous() { ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/nix-0.20.0/test/sys/test_mman.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[test] #[cfg(target_os = "linux")] fn test_mremap_shrink() { const ONE_K : size_t = 1024; let slice : &mut[u8] = unsafe { let mem = mmap(std::ptr::null_mut(), 10 * ONE_K, ProtFlags::PROT_READ | ProtFlags::PROT_WRITE, MapFlags::MAP_ANONYMOUS | ...
code_fim
medium
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/nix-0.20.0/test/sys/test_mman.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>otifier; pub mod slot_status_observer; pub mod transaction_notifier;<|fim_prefix|>// repo: ramtej/solana path: /accountsdb-plugin-manager/src/lib.rs pub mod accounts_update_notifier; pub mod accountsdb_plugin_manager; pub mod accountsdb_plugin_service; pub mod block_metadata_notifie<|fim_middle|>r; pub m...
code_fim
medium
{ "lang": "rust", "repo": "ramtej/solana", "path": "/accountsdb-plugin-manager/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ramtej/solana path: /accountsdb-plugin-manager/src/lib.rs pub mod accounts_update_notifier; pub mod accountsdb_plugin_manager<|fim_suffix|>r; pub mod block_metadata_notifier_interface; pub mod slot_status_notifier; pub mod slot_status_observer; pub mod transaction_notifier;<|fim_middle|>; pub mo...
code_fim
medium
{ "lang": "rust", "repo": "ramtej/solana", "path": "/accountsdb-plugin-manager/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>r; pub mod block_metadata_notifier_interface; pub mod slot_status_notifier; pub mod slot_status_observer; pub mod transaction_notifier;<|fim_prefix|>// repo: ramtej/solana path: /accountsdb-plugin-manager/src/lib.rs pub mod accounts_update_notifier; pub mod accountsdb_plugin_manager<|fim_middle|>; pub mo...
code_fim
medium
{ "lang": "rust", "repo": "ramtej/solana", "path": "/accountsdb-plugin-manager/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: masan4444/reversi path: /src/etc.rs #[inline] fn delta_swap_64(bitboard: u64, mask: u64, delta: usize) -> u64 { let x = (bitboard ^ (bitboard >> delta)) & mask; bitboard ^ x ^ (x << delta) } #[inline] fn flip_diag_a1_h8(bitboard: u64) -> u64 { let mut bitboard = delta_swap_64(bitboar...
code_fim
hard
{ "lang": "rust", "repo": "masan4444/reversi", "path": "/src/etc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const MASK1: u64 = 0xaaaaaaaaaaaaaaaa; //0xaaaaaaaaaaaaaaaa const MASK2: u64 = 0xcccccccccccccccc; //0xcccccccccccccccc const MASK3: u64 = 0xf0f0f0f0f0f0f0f0; let mut bitboard = bitboard ^ (MASK1 & (bitboard ^ bitboard.rotate_right(8))); bitboard = bitboard ^ (MASK2 & (bitboard ^ bitbo...
code_fim
hard
{ "lang": "rust", "repo": "masan4444/reversi", "path": "/src/etc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/wasm-modules path: /virtualnet/src/vnet.rs }; use smoltcp::phy::Loopback; use smoltcp::socket::{SocketHandle, SocketSet, UdpPacketMetadata, UdpSocket, UdpSocketBuffer}; use smoltcp::time::Duration; use smoltcp::wire::*; use std::collections::hash_map::DefaultHasher; use std::collections...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wasm-modules", "path": "/virtualnet/src/vnet.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/wasm-modules path: /virtualnet/src/vnet.rs he virtual network functions used from JavaScript API. use smoltcp::iface::{EthernetInterface, EthernetInterfaceBuilder, NeighborCache}; use smoltcp::phy::Loopback; use smoltcp::socket::{SocketHandle, SocketSet, UdpPacketMetadata, UdpSocket, Ud...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wasm-modules", "path": "/virtualnet/src/vnet.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> NETWORK.with(|net| { let net2 = &mut *net.borrow_mut(); let network = net2.as_mut().unwrap(); // TODO: gracefully report error if None network.socket_set.add(socket).inner() }) } /// Sends data to a provided destination address. /// /// ## Arguments /// - `sock`: the sour...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wasm-modules", "path": "/virtualnet/src/vnet.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: langzime/ratelimit_meter path: /benches/single_threaded.rs #![feature(test)] extern crate ratelimit_meter; extern crate test; use ratelimit_meter::{Decider, LeakyBucket, MultiDecider, GCRA}; use ratelimit_meter::example_algorithms::Allower; use std::time::{Duration, Instant}; #[bench] fn benc...
code_fim
hard
{ "lang": "rust", "repo": "langzime/ratelimit_meter", "path": "/benches/single_threaded.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut allower = Allower::new(); b.iter(|| allower.check().unwrap()); } #[bench] fn bench_threadsafe_leaky_bucket(b: &mut test::Bencher) { let mut lb = LeakyBucket::per_second(50).unwrap(); let now = Instant::now(); let ms = Duration::from_millis(20); let mut i = 0; b.iter(||...
code_fim
hard
{ "lang": "rust", "repo": "langzime/ratelimit_meter", "path": "/benches/single_threaded.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut lb = LeakyBucket::per_second(50).unwrap(); let now = Instant::now(); let ms = Duration::from_millis(20); let mut i = 0; b.iter(|| { i += 1; lb.check_at(now + (ms * i)).is_ok(); }); } #[bench] fn bench_leaky_bucket_bulk(b: &mut test::Bencher) { let mut l...
code_fim
hard
{ "lang": "rust", "repo": "langzime/ratelimit_meter", "path": "/benches/single_threaded.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PG-MANA/Methylenix path: /src/arch/aarch64/paging/table_entry.rs //! //! AArch64 Virtual Memory Paging Table Entry //! //! Supported 48bit-OA, Level 0~3 use crate::arch::target_arch::paging::PAGE_MASK; use crate::kernel::memory_manager::data_type::{Address, MemoryPermissionFlags, PAddress}; pu...
code_fim
hard
{ "lang": "rust", "repo": "PG-MANA/Methylenix", "path": "/src/arch/aarch64/paging/table_entry.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn invalidate(&mut self) { self.0 = 0; } pub fn validate_as_level3_descriptor(&mut self) { self.0 |= 0b11; } pub fn validate_as_block_descriptor(&mut self) { self.0 |= 0b01; } pub const fn is_validated(&self) -> bool { !((self.0 & 0b11) ==...
code_fim
hard
{ "lang": "rust", "repo": "PG-MANA/Methylenix", "path": "/src/arch/aarch64/paging/table_entry.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_permission(&mut self, permission: MemoryPermissionFlags) { self.0 = (self.0 & !(Self::AP | Self::XN)) | (((!permission.is_executable()) as u64) << Self::XN_OFFSET) | (((((!permission.is_writable()) as u64) << 1) | (permission.is_user_accessibl...
code_fim
hard
{ "lang": "rust", "repo": "PG-MANA/Methylenix", "path": "/src/arch/aarch64/paging/table_entry.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/dynamically-sized-types/dst-irrefutable-bind.rs // run-pass #![feature(unsized_tuple_coercion)] struct Test<T: ?Sized>(T); <|fim_suffix|> let & ref _y = x; // Make sure binding to a fat pointer behind a reference // still works ...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/dynamically-sized-types/dst-irrefutable-bind.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let x = (10, [1,2,3]); let x : &(i32, [i32]) = &x; let & ref _y = x; let slice = &[1,2,3]; let x = (10, &slice); let (_, &_slice) = x; }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/dynamically-sized-types/dst-irrefutable-bind.rs // run-pass #![featur...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/dynamically-sized-types/dst-irrefutable-bind.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manuels/libssh.rs path: /src/ssh_bind.rs #![allow(unused_imports)] #![allow(missing_copy_implementations)] extern crate libc; use libssh_server::*; use ssh_key; use ssh_session::SSHSession; use ssh_message; use std::mem; use std::ptr; use self::libc::types::common::c95::c_void; pub struct SS...
code_fim
hard
{ "lang": "rust", "repo": "manuels/libssh.rs", "path": "/src/ssh_bind.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let opt_key = ssh_bind_options_e::SSH_BIND_OPTIONS_RSAKEY as u32; let res = key_file.with_c_str(|pkey_file| unsafe { ssh_bind_options_set(self._bind, opt_key, pkey_file as *const c_void) }); match res { SSH_OK => Ok(()), _ => Err("ssh_bind_options_set() failed for private ke...
code_fim
hard
{ "lang": "rust", "repo": "manuels/libssh.rs", "path": "/src/ssh_bind.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Find the field that is marked #[niche]. In a regular struct, extract its name; in a // tuple struct, extract its index. In both cases, that can be converted into a // `Member`, which is the type needed down below in the field access expression. let nich...
code_fim
hard
{ "lang": "rust", "repo": "dcreager/controlled-option", "path": "/controlled-option-macros/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dcreager/controlled-option path: /controlled-option-macros/src/lib.rs // -*- coding: utf-8 -*- // ------------------------------------------------------------------------------------------------ // Copyright © 2021, Douglas Creager. // Licensed under either of Apache License, Version 2.0, or MIT...
code_fim
hard
{ "lang": "rust", "repo": "dcreager/controlled-option", "path": "/controlled-option-macros/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: voipir/rust-xmlsec path: /tests/test_templating.rs //! //! Testing of Template Creation //! use xmlsec::XmlSecTemplateBuilder; use xmlsec::XmlSecDocumentTemplating; use xmlsec::XmlSecCanonicalizationMethod; use xmlsec::XmlSecSignatureMethod; use libxml::parser::Parser as XmlParser; #[test] fn...
code_fim
hard
{ "lang": "rust", "repo": "voipir/rust-xmlsec", "path": "/tests/test_templating.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>{ // load document let parser = XmlParser::default(); let doc = parser.parse_file("tests/resources/sign2-doc.xml") .expect("Could not load template document"); // add signature node structure doc.template() .canonicalization(XmlSecCanonicalizationMethod::ExclusiveC14N...
code_fim
hard
{ "lang": "rust", "repo": "voipir/rust-xmlsec", "path": "/tests/test_templating.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>Err > { for variant in Self : : value_variants ( ) { if variant . to_possible_value ( ) . unwrap ( ) . matches ( s false ) { return Ok ( * variant ) ; } } Err ( format ! ( " invalid variant : { s } " ) ) } } impl ValueEnum for ColorChoice { fn value_variants < ' a > ( ) - > & ' a [ Self ] { & [ Self : : A...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/clap_builder/src/util/color.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/clap_builder/src/util/color.rs use crate : : builder : : PossibleValue ; use crate : : derive : : ValueEnum ; / / / Represents the color preferences for program output # [ derive ( Debug Copy Clone Eq PartialEq ) ] pub enum ColorChoice { / / / ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/clap_builder/src/util/color.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexW-GH/Rustboy path: /src/mem/cartridge.rs use super::memory::{MapsMemory, Memory}; #[derive(Debug, Clone)] struct CartridgeHeader { title: String, manufacturer: String, licensee_code: u16, old_licensee_code: u8, cartridge_type: CartridgeType, rom_size: RomSize, ra...
code_fim
hard
{ "lang": "rust", "repo": "AlexW-GH/Rustboy", "path": "/src/mem/cartridge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl RamSize { pub fn new(code: u8) -> RamSize { match code { 0x00 => RamSize::None, 0x01 => RamSize::KB2, 0x02 => RamSize::KB8, 0x03 => RamSize::KB32, 0x04 => RamSize::KB128, 0x05 => RamSize::KB64, _ => panic!...
code_fim
hard
{ "lang": "rust", "repo": "AlexW-GH/Rustboy", "path": "/src/mem/cartridge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tnkmrbg/firrtl-parser path: /src/test.rs use std::fs::File; use std::io::prelude::*; use std::io::{self, BufRead}; use std::path::Path; use super::astbuilder::*; use super::firrtl_ast::*; use super::pest::Parser; // #[ignore] #[test] fn firrtl_test() { (vec![ "./firrtl/counter.fir", ...
code_fim
hard
{ "lang": "rust", "repo": "tnkmrbg/firrtl-parser", "path": "/src/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Ok(ast) = res { println!("{}", ast); } else { println!("{:?}", res); } } }); } #[ignore] #[test] fn stmt_test() { let code2 = r#"when io.en : @[counter.scala 15:15] node _counter_T = add(counter, UInt<1>("h01")) @[counter.scala 16:24] nod...
code_fim
hard
{ "lang": "rust", "repo": "tnkmrbg/firrtl-parser", "path": "/src/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (vec!["abc", "_abc", "_$1a$2B$3c"]) .into_iter() .for_each(|str| { let pairs = FIRRTLParesr::parse(Rule::id, str).unwrap_or_else(|e| panic!("{}", e)); for pair in pairs { println!("{:?}", parse_ident(pair)); } }); } #[ignore] #[test] fn relaxedid_test() { (vec!["...
code_fim
hard
{ "lang": "rust", "repo": "tnkmrbg/firrtl-parser", "path": "/src/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let program = vec!["mov a 5", "inc a", "dec a", "dec a", "jnz a -1", "inc a"]; let expected = map! { "a" => 1 }; compare_registers(expected, simple_assembler(program)); let program = vec![ "mov c 12", "mov b 0", "mov a 200", ...
code_fim
hard
{ "lang": "rust", "repo": "Pluriscient/Rust-Katas", "path": "/src/probs/simple_assembler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let program = vec![ "mov c 12", "mov b 0", "mov a 200", "dec a", "inc b", "jnz a -2", "dec c", "mov a b", "jnz c -5", "jnz 0 1", "mov c a", ]; let exp...
code_fim
hard
{ "lang": "rust", "repo": "Pluriscient/Rust-Katas", "path": "/src/probs/simple_assembler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Pluriscient/Rust-Katas path: /src/probs/simple_assembler.rs use std::collections::HashMap; use std::str::FromStr; fn simple_assembler(program: Vec<&str>) -> HashMap<String, i64> { let mut registers: HashMap<String, i64> = HashMap::new(); let mut current: i64 = 0; while (current as...
code_fim
hard
{ "lang": "rust", "repo": "Pluriscient/Rust-Katas", "path": "/src/probs/simple_assembler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("private_key: {:02x?}", private_key); println!("private_key.sk_seed: {:02x?}", private_key.sk_seed.expose_secret()); println!("private_key.sk_data: {:02x?}", private_key.sk_data.expose_secret()); println!("drop private_key - start ..."); drop(private_key); println!("drop p...
code_fim
hard
{ "lang": "rust", "repo": "jyao1/rust-crypto-example", "path": "/tests/secret_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jyao1/rust-crypto-example path: /tests/secret_test.rs // Copyright (c) 2021 Intel Corporation // // SPDX-License-Identifier: BSD-2-Clause-Patent // // plese use `cargo test -- --nocapture --test-threads=1` to see result. use secrecy::{ExposeSecret, SecretBox, SecretVec, SecretString}; use rust...
code_fim
hard
{ "lang": "rust", "repo": "jyao1/rust-crypto-example", "path": "/tests/secret_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }