text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let mut config = MajorityConfig {
votes: HashSet::new(),
};
for item in v.iter() {
config.votes.insert(*item);
}
config
}
}
impl From<Vec<u64>> for MajorityConfig {
fn from(v: Vec<u64>) -> Self {
let mut config = MajorityConf... | code_fim | hard | {
"lang": "rust",
"repo": "stanxii/etcd-rs",
"path": "/src/raft/quorum/majority.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<Date> for SystemTime {
fn from(date: Date) -> SystemTime {
date.0.into()
}
}<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/headers/src/common/date.rs
use std::time::SystemTime;
use util::HttpDate;
#[derive(Debug, Clone,... | code_fim | easy | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/headers/src/common/date.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/headers/src/common/date.rs
use std::time::SystemTime;
use util::HttpDate;
<|fim_suffix|> Date(time.into())
}
}
impl From<Date> for SystemTime {
fn from(date: Date) -> SystemTime {
date.0.into()
}
}<|fim_m... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/headers/src/common/date.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wusir2001/coolq-app-python path: /src/lib.rs
#![feature(toowned_clone_into)]
extern crate coolq_sdk_rust;
#[macro_use]
extern crate pyo3;
#[macro_use]
extern crate lazy_static;
use coolq_sdk_rust::cqpapi;
use pyo3::{IntoPyTuple, prelude::*, types::*};
use std::{collections::HashMap, fs::{creat... | code_fim | hard | {
"lang": "rust",
"repo": "wusir2001/coolq-app-python",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wusir2001/coolq-app-python path: /src/lib.rs
ture(specialization)]
#![feature(toowned_clone_into)]
extern crate coolq_sdk_rust;
#[macro_use]
extern crate pyo3;
#[macro_use]
extern crate lazy_static;
use coolq_sdk_rust::cqpapi;
use pyo3::{IntoPyTuple, prelude::*, types::*};
use std::{collection... | code_fim | hard | {
"lang": "rust",
"repo": "wusir2001/coolq-app-python",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> cqpapi::get_group_list()
}
#[pyfunction]
fn get_stranger_info(user_id: i64, use_cache: bool) -> String {
cqpapi::get_stranger_info(user_id, use_cache)
}
#[pyfunction]
fn add_log(priority: i32, tag: &str, msg: &str) -> i32 {
cqpapi::add_log(priority, tag, msg... | code_fim | hard | {
"lang": "rust",
"repo": "wusir2001/coolq-app-python",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Techno-coder/lexica path: /src/lexer/source_split.rs
use std::iter::Peekable;
use std::str::CharIndices;
use crate::source::SourceKey;
use crate::span::{Span, Spanned};
pub const SINGULARITIES: &[char] = &['\t', '\n', '(', ')', ',', '*', '.', '$'];
/// Splits a source string into spanned stri... | code_fim | hard | {
"lang": "rust",
"repo": "Techno-coder/lexica",
"path": "/src/lexer/source_split.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let string = "root::first::second::third";
let lexemes: Vec<_> = SourceSplit::new(string, SourceKey::INTERNAL)
.map(|node| node.node).collect();
assert_eq!(&lexemes, &["root", "::", "first", "::", "second", "::", "third"]);
}
#[test]
fn test_comment() {
let string = "// comment";
assert!(... | code_fim | hard | {
"lang": "rust",
"repo": "Techno-coder/lexica",
"path": "/src/lexer/source_split.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let string = "// comment";
assert!(SourceSplit::new(string, SourceKey::INTERNAL).next().is_none());
}
#[test]
fn test_prime() {
let string = "fn function'(variable: &'lifetime)";
let lexemes: Vec<_> = SourceSplit::new(string, SourceKey::INTERNAL)
.map(|node| node.node).collect();
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "Techno-coder/lexica",
"path": "/src/lexer/source_split.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gmadrid/yewknit path: /temp/src/download.rs
use wasm_bindgen::JsCast;
pub fn download(text: &str, filename: &str) {
// Figure out a better error handling solution here.
let window = web_sys::window().expect("No window");
let document = window.document().expect("no document");
l... | code_fim | hard | {
"lang": "rust",
"repo": "gmadrid/yewknit",
"path": "/temp/src/download.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let el = document.create_element("a").expect("no element created");
el.set_attribute("href", &data).expect("couldn't set href");
el.set_attribute("download", filename)
.expect("couldn't set download");
let body = document.body().expect("What? no Body?");
body.append_child(&el)... | code_fim | medium | {
"lang": "rust",
"repo": "gmadrid/yewknit",
"path": "/temp/src/download.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uazu/stakker_mio path: /examples/echo_server.rs
//! This demonstrates a TCP echo server. It listens for connections
//! on port 7777. Each connection is handled by a separate actor.
//! This actor just sends back whatever data it receives over TCP.
//!
//! However to make things a little more ... | code_fim | hard | {
"lang": "rust",
"repo": "uazu/stakker_mio",
"path": "/examples/echo_server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Don't need `idle!` handling
s.run(Instant::now(), false);
while s.not_shutdown() {
let maxdur = s.next_wait_max(Instant::now(), Duration::from_secs(60), false);
miopoll.poll(maxdur)?;
s.run(Instant::now(), false);
}
println!("Shutdown: {}", s.shutdown_reason... | code_fim | hard | {
"lang": "rust",
"repo": "uazu/stakker_mio",
"path": "/examples/echo_server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eugeneia/rush path: /src/ixy82599/ixgbe.rs
let high = self.get_reg32(IXGBE_RAH(0));
[
(low & 0xff) as u8,
(low >> 8 & 0xff) as u8,
(low >> 16 & 0xff) as u8,
(low >> 24) as u8,
(high & 0xff) as u8,
(high >> 8... | code_fim | hard | {
"lang": "rust",
"repo": "eugeneia/rush",
"path": "/src/ixy82599/ixgbe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tx_queue = IxgbeTxQueue {
descriptors: dma_virt as *mut ixgbe_adv_tx_desc,
bufs_in_use: VecDeque::with_capacity(NUM_TX_QUEUE_ENTRIES),
num_descriptors: NUM_TX_QUEUE_ENTRIES,
clean_index: 0,
tx_index: 0,
... | code_fim | hard | {
"lang": "rust",
"repo": "eugeneia/rush",
"path": "/src/ixy82599/ixgbe.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eugeneia/rush path: /src/ixy82599/ixgbe.rs
e std::ptr;
use std::thread;
use std::time::{Duration, Instant};
use std::cmp;
use super::constants::*;
// use super::interrupts::*;
// use super::memory::*;
// use super::vfio::*;
use super::pci::pci_map_resource;
// use super::vfio::VFIO_PCI_BAR0_RE... | code_fim | hard | {
"lang": "rust",
"repo": "eugeneia/rush",
"path": "/src/ixy82599/ixgbe.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let page = self.pages.curr_page();
let pages = self.pages.last_page();
let mut footer_text = format!("Page {page}/{pages}");
if let Some(idx) = self.author_idx {
let _ = write!(footer_text, " • Your position: {}", idx + 1);
}
let embed = EmbedB... | code_fim | hard | {
"lang": "rust",
"repo": "MaxOhn/Bathbot",
"path": "/bathbot/src/active/impls/snipe/country_list.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaxOhn/Bathbot path: /bathbot/src/active/impls/snipe/country_list.rs
use std::{fmt::Write, sync::Arc};
use bathbot_macros::PaginationBuilder;
use bathbot_model::{CountryName, SnipeCountryPlayer};
use bathbot_util::{
constants::OSU_BASE, numbers::WithComma, osu::flag_url, CowUtils, EmbedBuil... | code_fim | hard | {
"lang": "rust",
"repo": "MaxOhn/Bathbot",
"path": "/bathbot/src/active/impls/snipe/country_list.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/jlrs path: /jlrs/src/value/union_all.rs
//! Support for values with the `Core.UnionAll` type.
use super::type_var::TypeVar;
use super::Value;
use crate::convert::cast::Cast;
use crate::error::{JlrsError, JlrsResult};
use crate::memory::global::Global;
use crate::value::datatype::DataTyp... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/jlrs",
"path": "/jlrs/src/value/union_all.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>unsafe impl<'frame, 'data> Cast<'frame, 'data> for UnionAll<'frame> {
type Output = Self;
fn cast(value: Value<'frame, 'data>) -> JlrsResult<Self::Output> {
if value.is::<Self::Output>() {
return unsafe { Ok(Self::cast_unchecked(value)) };
}
Err(JlrsError::NotA... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/jlrs",
"path": "/jlrs/src/value/union_all.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let self_version = env!("CARGO_PKG_VERSION");
let top_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let profile = env::var("PROFILE").unwrap();
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let target_dir = match env::var("CARGO_TARGET_SUBDIR") {
Ok(dir) => format!... | code_fim | medium | {
"lang": "rust",
"repo": "RandomYe/mesalink",
"path": "/build.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RandomYe/mesalink path: /build.rs
/*
* __ __ _ _ _
* | \/ | ___ ___ __ _| | (_)_ __ | | __
* | |\/| |/ _ \/ __|/ _` | | | | '_ \| |/ /
* | | | | __/\__ \ (_| | |___| | | | | <
* |_| |_|\___||___/\__,_|_____|_|_| |_|_|\_\
*
* Copyright (c) 2017... | code_fim | medium | {
"lang": "rust",
"repo": "RandomYe/mesalink",
"path": "/build.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Use the ALERT/RDY pin as conversion-ready pin.
///
/// This the ALERT/RDY pin outputs the OS bit when in OneShot mode, and
/// provides a continuous-conversion ready pulse when in
/// continuous-conversion mode.
///
/// When calling this the comparator will be disabled and ... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/ads1x1x-rs",
"path": "/src/devices/features/tier2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eldruin/ads1x1x-rs path: /src/devices/features/tier2.rs
//! Tier 2 features.
//!
//! These are the features included only in ADS1x14, ADS1x15
use crate::{
conversion, ic, interface, Ads1x1x, BitFlags as BF, ComparatorLatching, ComparatorMode,
ComparatorPolarity, ComparatorQueue, Error, ... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/ads1x1x-rs",
"path": "/src/devices/features/tier2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set comparator latching
pub fn set_comparator_latching(
&mut self,
latching: ComparatorLatching,
) -> Result<(), Error<E>> {
let config = match latching {
ComparatorLatching::Nonlatching => self.config.with_low(BF::COMP_LAT),
ComparatorLatchi... | code_fim | hard | {
"lang": "rust",
"repo": "eldruin/ads1x1x-rs",
"path": "/src/devices/features/tier2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Name for the virtual interface
fn dev_name(&self) -> String {
format!("vm{}", self.id)
}
/// MAC needs to be predicatable so the VM can pre-configure its network.
/// The MAC address is formatted `self.id`.
pub(crate) fn guest_mac(&self) -> String {
format!("{:... | code_fim | hard | {
"lang": "rust",
"repo": "facebookincubator/antlir",
"path": "/antlir/antlir2/antlir2_vm/src/net.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebookincubator/antlir path: /antlir/antlir2/antlir2_vm/src/net.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
//! This file contains structs that ... | code_fim | hard | {
"lang": "rust",
"repo": "facebookincubator/antlir",
"path": "/antlir/antlir2/antlir2_vm/src/net.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilipK/Newton path: /src/newton.rs
use crate::components::Destroyable;
use crate::components::Player;
use crate::components::ScoreArrow;
use crate::components::SimpleAnimation;
use crate::components::ZoomCamera;
use crate::entities::high_score_text;
use crate::entities::score_board::ScoreBoard;... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipK/Newton",
"path": "/src/newton.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let world = data.world;
title_text::itnitialize_title_text(world);
initialize_star_field(world);
world.register::<ZoomCamera>();
world.register::<Destroyable>();
playercamera::initialize_camera(world);
}
fn update(&mut self, data: &mut StateData<'_,... | code_fim | hard | {
"lang": "rust",
"repo": "PhilipK/Newton",
"path": "/src/newton.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: katyo/bus-queue path: /src/sync.rs
use super::*;
use std::iter::Iterator;
use std::thread;
use std::time::{Duration, Instant};
/// Provides an interface for the publisher
#[derive(Debug)]
pub struct Publisher<T: Send> {
bare_publisher: BarePublisher<T>,
waker: Waker<ArcSwap<thread::Thre... | code_fim | hard | {
"lang": "rust",
"repo": "katyo/bus-queue",
"path": "/src/sync.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let arc_t = Arc::new(ArcSwap::new(Arc::new(thread::current())));
self.sleeper.sender.send(arc_t.clone()).unwrap();
Self {
bare_subscriber: self.bare_subscriber.clone(),
sleeper: Sleeper {
sender: self.sleeper.sender.clone(),
s... | code_fim | hard | {
"lang": "rust",
"repo": "katyo/bus-queue",
"path": "/src/sync.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DoumanAsh/async-timer path: /src/timer/dummy.rs
//! Dummy Timer
use core::{task, time};
use core::future::Future;
use core::pin::Pin;
///Dummy Timer with implementation that panics
pub struct DummyTimer;
impl DummyTimer {
///Creates new instance
pub const fn new(_: time::Duration) -> ... | code_fim | medium | {
"lang": "rust",
"repo": "DoumanAsh/async-timer",
"path": "/src/timer/dummy.rs",
"mode": "psm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unimplemented!();
}
fn restart(&mut self, _: time::Duration) {
unimplemented!();
}
fn restart_ctx(&mut self, _: time::Duration, _: &task::Waker) {
unimplemented!();
}
}
impl super::SyncTimer for DummyTimer {
fn init<R, F: Fn(&crate::state::TimerState) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "DoumanAsh/async-timer",
"path": "/src/timer/dummy.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(self: Pin<&mut Self>, _: &mut task::Context) -> task::Poll<Self::Output> {
unimplemented!();
}
}<|fim_prefix|>// repo: DoumanAsh/async-timer path: /src/timer/dummy.rs
//! Dummy Timer
use core::{task, time};
use core::future::Future;
use core::pin::Pin;
///Dummy Timer with implem... | code_fim | hard | {
"lang": "rust",
"repo": "DoumanAsh/async-timer",
"path": "/src/timer/dummy.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: permosegaard/cxx path: /gen/lib/src/lib.rs
//! The CXX code generator for constructing and compiling C++ code.
//!
//! This is intended as a mechanism for embedding the `cxx` crate into
//! higher-level code generators. See [dtolnay/cxx#235] and
//! [https://github.com/google/autocxx].
//!
//! [... | code_fim | hard | {
"lang": "rust",
"repo": "permosegaard/cxx",
"path": "/gen/lib/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Generate C++ bindings code from a Rust token stream. This should be a Rust
/// token stream which somewhere contains a `#[cxx::bridge] mod {}`.
pub fn generate_header_and_cc(rust_source: TokenStream, opt: &Opt) -> Result<GeneratedCode, Error> {
let syntax = syn::parse2(rust_source)
.map_er... | code_fim | hard | {
"lang": "rust",
"repo": "permosegaard/cxx",
"path": "/gen/lib/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ymgyt/localenv path: /src/config/mod.rs
mod filesystem;
pub use filesystem::{FileEntry, Filesystem, FilesystemEntry, SymlinkEntry};
mod command;
pub use command::{CargoCommand, Command, Commands};
use serde::Deserialize;
use tokio::fs;
use std::{
io,
path::{Path, PathBuf},
};
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "ymgyt/localenv",
"path": "/src/config/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize, Debug)]
pub struct Spec {
#[serde(rename = "localenv")]
pub version: String,
pub required_envs: Vec<RequiredEnvEntry>,
pub commands: Commands,
pub filesystem: Filesystem,
}
#[derive(Deserialize, Debug)]
pub struct RequiredEnvEntry {
name: String,
descrip... | code_fim | hard | {
"lang": "rust",
"repo": "ymgyt/localenv",
"path": "/src/config/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = Regex::new(r"^([^ ]+) \[(.+)\] ").unwrap();
let caps = r.captures(s);
if caps.is_some() {
caps.unwrap().get(2).unwrap().as_str()
} else {
let r = Regex::new(r"^([^ ]+) /").unwrap();
r.captures(s).unwrap().get(1).unwrap().as_str()
}
}
fn main() {
let stdin = ... | code_fim | medium | {
"lang": "rust",
"repo": "inoue-katsumi/edict_romaji",
"path": "/src/edict_romaji.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inoue-katsumi/edict_romaji path: /src/edict_romaji.rs
extern crate regex;
extern crate wana_kana;
use regex::Regex;
use std::io::prelude::*;
use wana_kana::to_romaji::*;
fn parse_line(s: &str) -> &str {
let r = Regex::new(r"^([^ ]+) \[(.+)\] ").unwrap();
let caps = r.captures(s);
i... | code_fim | medium | {
"lang": "rust",
"repo": "inoue-katsumi/edict_romaji",
"path": "/src/edict_romaji.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn pages_iter<'a>(&'a self, chapter: &'a mut Chapter) -> Result<ChapterPages> {
let html = get(&chapter.url)?.text()?;
let document = parse_document(&html);
chapter.set_title(document.dom_text(".comico-global-header__page-title > p")?.replace(" ", " "));
let addresses ... | code_fim | hard | {
"lang": "rust",
"repo": "NickTet/mikack",
"path": "/src/extractors/comico.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NickTet/mikack path: /src/extractors/comico.rs
use super::*;
use serde::Deserialize;
def_regex2![
COMIC_ID => r#"https?://www\.comico\.com\.tw/(challenge/)?(\d+)"#
];
#[derive(Debug, Deserialize)]
struct ComicJson {
result: ComicResult,
}
#[derive(Debug, Deserialize)]
struct ComicRes... | code_fim | hard | {
"lang": "rust",
"repo": "NickTet/mikack",
"path": "/src/extractors/comico.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filename = std::env::args().skip(1).next().unwrap();
let f = std::fs::File::open(filename).unwrap();
let output = typegen(f);
println!("{}", output);
}<|fim_prefix|>// repo: asavchenko/typegen2 path: /typegen_cli/src/main.rs
use typegen_core::typegen;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "asavchenko/typegen2",
"path": "/typegen_cli/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asavchenko/typegen2 path: /typegen_cli/src/main.rs
use typegen_core::typegen;
<|fim_suffix|> let filename = std::env::args().skip(1).next().unwrap();
let f = std::fs::File::open(filename).unwrap();
let output = typegen(f);
println!("{}", output);
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "asavchenko/typegen2",
"path": "/typegen_cli/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (Token::OneOf { invert, list }, ONCE)
}
c => {
leading = is_leading(flags, c);
(Token::Char(c), ONCE)
}
})
}
tokens
}
#[no_mangle]
#[linkage = "weak"] // often redefined in GNU programs
pub unsafe extern "... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/relibc",
"path": "/src/header/fnmatch/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c = *pattern;
pattern = pattern.offset(1);
tokens.push(match c {
b'\\' if flags & FNM_NOESCAPE == FNM_NOESCAPE => {
let c = *pattern;
if c == 0 {
// Trailing backslash. Maybe error here?
break;... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/relibc",
"path": "/src/header/fnmatch/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/relibc path: /src/header/fnmatch/mod.rs
//! fnmatch implementation
use alloc::{borrow::Cow, vec::Vec};
use core::slice;
use crate::platform::types::*;
use posix_regex::{
compile::{Collation, Range, Token},
PosixRegex,
};
const ONCE: Range = Range(1, Some(1));
pub const FNM_N... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/relibc",
"path": "/src/header/fnmatch/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("III", num_to_roman(3));
assert_eq!("IV", num_to_roman(4));
assert_eq!("IX", num_to_roman(9));
assert_eq!("LVIII", num_to_roman(58));
assert_eq!("MCMXCIV", num_to_roman(1994));
println!("finish");
}<|fim_prefix|>// repo: Pencil-Yao/YBlog path: /leetcode/12.整数转罗马数字.rs
/... | code_fim | hard | {
"lang": "rust",
"repo": "Pencil-Yao/YBlog",
"path": "/leetcode/12.整数转罗马数字.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pencil-Yao/YBlog path: /leetcode/12.整数转罗马数字.rs
//罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。
//
//字符 数值
//I 1
//V 5
//X 10
//L 50
//C 100
//D 500
//M 1000
//例如, 罗马数字 2 写做 II ,即为两个并列的 1。12 写做 XII ,即为 X + II 。 27 写做... | code_fim | hard | {
"lang": "rust",
"repo": "Pencil-Yao/YBlog",
"path": "/leetcode/12.整数转罗马数字.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stepchowfun/toast path: /src/runner.rs
use {
crate::{
cache, docker, failure,
failure::Failure,
tar,
toastfile::{command, location, user, Task, Toastfile},
},
std::{
collections::{HashMap, HashSet},
io::{Seek, SeekFrom},
path::P... | code_fim | hard | {
"lang": "rust",
"repo": "stepchowfun/toast",
"path": "/src/runner.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check the cache, if applicable.
let mut cached = false;
if caching_enabled {
// Check the local cache.
cached = settings.read_local_cache
&& match docker::image_exists(&settings.docker_cli, &image, interrupted) {
Ok(exists) => exists,
... | code_fim | hard | {
"lang": "rust",
"repo": "stepchowfun/toast",
"path": "/src/runner.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Only commit the container if we actually need to return a context.
if (need_context || persist_locally || persist_remotely) && !failed_fatally {
// Commit the container.
if let Err(e) =
docker::commit_container(&settings.docker_cli, &container, &i... | code_fim | hard | {
"lang": "rust",
"repo": "stepchowfun/toast",
"path": "/src/runner.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Error, Debug, Serialize, Deserialize)]
pub enum TeeServiceError {
#[error("SgxError")]
SgxError,
#[error("ServiceError")]
ServiceError,
#[error("CommandNotRegistered")]
CommandNotRegistered,
#[error("EnclaveForceTermination")]
EnclaveForceTermination,
}
pub type T... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-teaclave",
"path": "/types/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type TeeServiceResult<T> = std::result::Result<T, TeeServiceError>;
pub type TeaclaveServiceResponseResult<T> = std::result::Result<tonic::Response<T>, tonic::Status>;
pub fn tonic_error<T: std::fmt::Debug>(err: T) -> tonic::Status {
tonic::Status::internal(format!("{:?}", err))
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-teaclave",
"path": "/types/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apache/incubator-teaclave path: /types/src/error.rs
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-teaclave",
"path": "/types/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pitipat1998/karalle path: /src/benchmark/sort.rs
use std::time::Duration;
use std::collections::HashMap;
use crate::benchmark::{run_quick_sort_benchmark,
run_merge_sort_benchmark,
run_sample_sort_benchmark};
#[allow(dead_code)]
<|fim_suffix|>rge_sor... | code_fim | hard | {
"lang": "rust",
"repo": "pitipat1998/karalle",
"path": "/src/benchmark/sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|><String, Duration> = HashMap::new();
println!("Running quick sort size: {:?}", size);
let qs = run_quick_sort_benchmark(d, size, rounds, threads);
println!("Running merge sort size: {:?}", size);
let ms = run_merge_sort_benchmark(d, size, rounds, threads);
println!("Running sample sort... | code_fim | hard | {
"lang": "rust",
"repo": "pitipat1998/karalle",
"path": "/src/benchmark/sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Runs the jude_web executable.
pub fn main() {
env_logger::init().unwrap();
let logger = Logger::new(None);
let router = router!(
get "/" => index::handle,
get "/foo" => foo::handle
);
let mut chain = Chain::new(router);
chain.link(logger);
let sw = sessio... | code_fim | medium | {
"lang": "rust",
"repo": "pikajude/jude-web.rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pikajude/jude-web.rs path: /src/lib.rs
#![feature(convert)]
#![feature(result_expect)]
#![feature(vec_push_all)]
extern crate iron;
extern crate logger;
extern crate mustache;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate router;
#[macro_use]
extern crate log;
extern crate so... | code_fim | medium | {
"lang": "rust",
"repo": "pikajude/jude-web.rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigp/lighthouse path: /common/eth2/src/lighthouse/attestation_performance.rs
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use types::Epoch;
#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)]
pub struct AttestationPerformanceStatistics {
pub active: bo... | code_fim | medium | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/common/eth2/src/lighthouse/attestation_performance.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AttestationPerformance {
pub fn initialize(indices: Vec<u64>) -> Vec<Self> {
let mut vec = Vec::with_capacity(indices.len());
for index in indices {
vec.push(Self {
index,
..Default::default()
})
}
vec
}
}... | code_fim | medium | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/common/eth2/src/lighthouse/attestation_performance.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Smithay/smithay path: /src/wayland/output/xdg.rs
//! XDG Output advertising capabilities
//!
//! This protocol is meant for describing outputs in a way
//! which is more in line with the concept of an output on desktop oriented systems.
use std::sync::{Arc, Mutex};
use tracing::trace;
use wayl... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/wayland/output/xdg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> instances: Vec::new(),
})),
}
}
pub(super) fn add_instance(&self, xdg_output: &ZxdgOutputV1, wl_output: &WlOutput) {
let mut inner = self.inner.lock().unwrap();
xdg_output.logical_position(inner.logical_position.x, inner.logical_position.y);
... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/wayland/output/xdg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sharksforarms/rust-packet path: /src/layer/udp/mod.rs
/*!
UDP layer
*/
use super::{Layer, LayerError};
use crate::layer::{ip::checksum, Ipv4, Ipv6};
use deku::bitvec::{BitVec, Msb0};
use deku::prelude::*;
use std::convert::TryFrom;
/**
UDP Header
```text
0 1 ... | code_fim | hard | {
"lang": "rust",
"repo": "sharksforarms/rust-packet",
"path": "/src/layer/udp/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut udp = self.to_bytes()?;
// Bytes 6, 7 are the checksum. Clear them for calculation.
udp[6] = 0x00;
udp[7] = 0x00;
let mut buf = Vec::with_capacity(12 + udp.len() + data_buf.len());
// Write pseudo header
let mut ipv4_src = BitVec::<Msb0, u8... | code_fim | hard | {
"lang": "rust",
"repo": "sharksforarms/rust-packet",
"path": "/src/layer/udp/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub fn update_checksum_ipv6(&mut self, ipv6: &Ipv6, data: &[Layer]) -> Result<(), LayerError> {
let mut data_buf = Vec::new();
for layer in data {
data_buf.extend(layer.to_bytes()?)
}
let mut udp = self.to_bytes()?;
// Bytes 6,... | code_fim | hard | {
"lang": "rust",
"repo": "sharksforarms/rust-packet",
"path": "/src/layer/udp/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Naive Sum {}", inputs().map(fuel_req).sum::<i32>());
println!("Total Sum {}", inputs().map(total_fuel).sum::<i32>());
}<|fim_prefix|>// repo: Connicpu/AoC2019 path: /src/bin/day01.rs
static INPUT1: &str = include_str!("input/day01.txt");
fn inputs() -> impl Iterator<Item = i32> {
I... | code_fim | hard | {
"lang": "rust",
"repo": "Connicpu/AoC2019",
"path": "/src/bin/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut req = fuel_req(mass);
let mut fuel = req;
loop {
fuel = fuel_req(fuel);
if fuel > 0 {
req += fuel;
} else {
break;
}
}
req
}
fn main() {
println!("Naive Sum {}", inputs().map(fuel_req).sum::<i32>());
println!("Tot... | code_fim | medium | {
"lang": "rust",
"repo": "Connicpu/AoC2019",
"path": "/src/bin/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Connicpu/AoC2019 path: /src/bin/day01.rs
static INPUT1: &str = include_str!("input/day01.txt");
fn inputs() -> impl Iterator<Item = i32> {
INPUT1.lines().filter_map(|line| line.parse().ok())
}
fn fuel_req(mass: i32) -> i32 {
(mass / 3 - 2).max(0)
}
<|fim_suffix|> println!("Naive Su... | code_fim | hard | {
"lang": "rust",
"repo": "Connicpu/AoC2019",
"path": "/src/bin/day01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RalfJung/beef path: /src/lean.rs
//! Namespace containing the 2-word `Cow` implementation.
use core::ptr::{slice_from_raw_parts, slice_from_raw_parts_mut};
use crate::traits::Capacity;
/// Faster, 2-word `Cow`. This version is available only on 64-bit architecture,
/// and it puts both capacit... | code_fim | hard | {
"lang": "rust",
"repo": "RalfJung/beef",
"path": "/src/lean.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len & MASK_HI != 0 {
Some(Lean)
} else {
None
}
}
}
#[cfg(test)]
mod tests {
use super::Cow;
#[test]
fn stress_test_owned() {
let mut expected = String::from("Hello... ");
let mut cow: Cow<str> = Cow::borrowed("Hello... "... | code_fim | hard | {
"lang": "rust",
"repo": "RalfJung/beef",
"path": "/src/lean.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nervosnetwork/ckb path: /tx-pool/src/component/entry.rs
use crate::component::sort_key::{AncestorsScoreSortKey, EvictKey};
use ckb_systemtime::unix_time_as_millis;
use ckb_types::{
core::{
cell::ResolvedTransaction,
tx_pool::{get_transaction_weight, TxEntryInfo},
Capa... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/tx-pool/src/component/entry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PartialEq for TxEntry {
fn eq(&self, other: &TxEntry) -> bool {
self.rtx.transaction == other.rtx.transaction
}
}
impl PartialOrd for TxEntry {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for TxEntry {
fn cmp(&self... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/tx-pool/src/component/entry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nifey/tutor path: /src/info.rs
use super::index::{new_from_string, Index};
use serde::Deserialize;
use std::convert::TryInto;
use std::fs::File;
use std::io::Read;
#[derive(Deserialize, Debug)]
struct Lesson {
title: String,
file: String,
}
impl Lesson {
pub fn get_title(&self) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "nifey/tutor",
"path": "/src/info.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn read_tutorinfo() -> Info {
let mut info_file = File::open("tutorinfo.toml")
.expect("Run tutor from a tutorial directory containing tutorinfo.toml file");
let mut contents = String::new();
info_file
.read_to_string(&mut contents)
.expect("Error reading tutorinfo.... | code_fim | hard | {
"lang": "rust",
"repo": "nifey/tutor",
"path": "/src/info.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: segler-alex/av-stream-info-rust path: /src/streaminfo.rs
#![allow(non_snake_case)]
use crate::DecodeError;
use crate::LatLong;
use serde::{Deserialize, Serialize};
<|fim_suffix|> pub LogoUrl: Option<String>,
pub MainStreamUrl: Option<String>,
pub IcyVersion: u32,
pub OverrideIn... | code_fim | hard | {
"lang": "rust",
"repo": "segler-alex/av-stream-info-rust",
"path": "/src/streaminfo.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub LogoUrl: Option<String>,
pub MainStreamUrl: Option<String>,
pub IcyVersion: u32,
pub OverrideIndexMetaData: Option<bool>,
pub CountryCode: Option<String>,
pub CountrySubdivisonCode: Option<String>,
pub LanguageCodes: Vec<String>,
pub GeoLatLong: Option<Result<LatLong, D... | code_fim | hard | {
"lang": "rust",
"repo": "segler-alex/av-stream-info-rust",
"path": "/src/streaminfo.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /crates/openlimits-exchange/src/model/request/get_price_ticker_request.rs
use derive_more::Constructor;
use serde::Deserialize;
use serde::Serialize;
/// This struct represents the ticker price.
#[derive(Ser<|fim_suffix|>]
pub struct GetPriceTickerRequest {
pub ma... | code_fim | medium | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/crates/openlimits-exchange/src/model/request/get_price_ticker_request.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>ialize, Deserialize, Clone, Constructor, Debug, Default, PartialEq)]
pub struct GetPriceTickerRequest {
pub market_pair: String,
}<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /crates/openlimits-exchange/src/model/request/get_price_ticker_request.rs
use derive_more::Constructor;
use serde::Deseri... | code_fim | medium | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/crates/openlimits-exchange/src/model/request/get_price_ticker_request.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// A trait for all predicates to be applied on a node
pub trait Predicate {
fn matches(&self, node: &NodeIndex) -> bool;
fn and<T: Predicate>(self, other: T) -> And<Self, T> where Self:Sized {
And(self, other)
}
}
// and two predicates
#[derive(Copy, Clone, Debug, PartialEq)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "shaddyshad/inable_nav",
"path": "/src/question_paper/interface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaddyshad/inable_nav path: /src/question_paper/interface.rs
use crate::Tag;
use super::QuestionPaper;
use std::borrow::Cow::{self, Borrowed};
use serde::Serialize;
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub enum NodeData {
Document,
Section(SectionData),
Question(Questi... | code_fim | hard | {
"lang": "rust",
"repo": "shaddyshad/inable_nav",
"path": "/src/question_paper/interface.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // convert every number into an i32 for ease of use
let number = ToPrimitive::to_i32(&data).unwrap();
buf.extend_from_slice(&number.to_ne_bytes()).unwrap();
self.i2c.write(Self::EEPROM_ADDRESS, buf.as_ref()).ok();
}
pub fn read_data<T: Num + PrimInt + FromPrimitiv... | code_fim | hard | {
"lang": "rust",
"repo": "BBScholar/CAN_ENCODER_RUST",
"path": "/src/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BBScholar/CAN_ENCODER_RUST path: /src/memory.rs
use embedded_hal::blocking::i2c::{Read, Write, WriteRead};
use num_traits::{cast::FromPrimitive, cast::ToPrimitive, Num, PrimInt};
use heapless::consts::*;
use core::{convert::TryInto, ops::Deref};
// these are word addresses, since we aren't s... | code_fim | hard | {
"lang": "rust",
"repo": "BBScholar/CAN_ENCODER_RUST",
"path": "/src/memory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Canop/crossterm-input path: /src/input/windows_input.rs
TURN, VK_RIGHT, VK_SHIFT, VK_UP,
},
};
use crossterm_utils::Result;
use crossterm_winapi::{
ButtonState, Console, ConsoleMode, EventFlags, Handle, InputEventType, KeyEventRecord,
MouseEvent,
};
use super::{ITerminalInput, Inpu... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/crossterm-input",
"path": "/src/input/windows_input.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Canop/crossterm-input path: /src/input/windows_input.rs
s without echo and _getwche is with echo
let pressed_char = unsafe { _getwche() };
// we could return error but maybe option to keep listening until valid character is inputted.
if pressed_char == 0 || pressed_char ... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/crossterm-input",
"path": "/src/input/windows_input.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Check if there are input events to read.
///
/// It will return `None` when nothing is there to read, `Some(InputEvent)` if there are events to read.
///
/// # Remark
/// - This is **not** a blocking call.
/// - When calling this method to fast after each other the reader m... | code_fim | hard | {
"lang": "rust",
"repo": "Canop/crossterm-input",
"path": "/src/input/windows_input.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/semc/sdramcr2/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::SDRAMCR2 {
#[doc = r" Modifies the contents of the register"]
#[inli... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/semc/sdramcr2/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>"IDLE timeout period is ITO*Prescale period."]
#[inline]
pub fn ito_7(self) -> &'a mut W {
self.variant(ITOW::ITO_7)
}
#[doc = "IDLE timeout period is ITO*Prescale period."]
#[inline]
pub fn ito_8(self) -> &'a mut W {
self.variant(ITOW::ITO_8)
}
#[doc = "IDL... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/semc/sdramcr2/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let configuration: Rc<RefCell<Configuration>> = Default::default();
let mut bank = GenomeBank::new(configuration);
let genome = Genome::new(1, 1);
bank.add_genome(genome.clone());
bank.mark_fitness(genome.id(), 1337.);
}
}<|fim_prefix|>// repo: stjepangolemac/... | code_fim | hard | {
"lang": "rust",
"repo": "stjepangolemac/neat-rs",
"path": "/core/src/neat/speciation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stjepangolemac/neat-rs path: /core/src/neat/speciation.rs
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use super::configuration::Configuration;
use crate::genome::{Genome, GenomeId};
/// Holds all genomes and species, does the process of speciation
#[derive(Debug)]
p... | code_fim | hard | {
"lang": "rust",
"repo": "stjepangolemac/neat-rs",
"path": "/core/src/neat/speciation.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn can_add_genome() {
let configuration: Rc<RefCell<Configuration>> = Default::default();
let mut bank = GenomeBank::new(configuration);
let genome = Genome::new(1, 1);
bank.add_genome(genome);
}
#[test]
fn can_mark_fitness() {
let conf... | code_fim | hard | {
"lang": "rust",
"repo": "stjepangolemac/neat-rs",
"path": "/core/src/neat/speciation.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tremor-rs/tremor-runtime path: /tremor-script/src/ast/deploy.rs
// Copyright 2020-2021, The Tremor Team
//
// 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
//
// h... | code_fim | hard | {
"lang": "rust",
"repo": "tremor-rs/tremor-runtime",
"path": "/tremor-script/src/ast/deploy.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ConnectStmt {
// we get the field called 'from' as muttable
#[allow(clippy::wrong_self_convention)]
pub(crate) fn from_mut(&mut self) -> &mut DeployEndpoint {
match self {
ConnectStmt::ConnectorToPipeline { from, .. }
| ConnectStmt::PipelineToConnector { f... | code_fim | hard | {
"lang": "rust",
"repo": "tremor-rs/tremor-runtime",
"path": "/tremor-script/src/ast/deploy.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (status, res) = client.post(PREFIX, &format!("users/{}/approval_requests", id), None, Some(params))?;
let approval_request = serde_json::from_value(res["approval_request"].clone())?;
Ok((status, approval_request))
}<|fim_prefix|>// repo: daly4/authy-rs path: /src/api/onetouch.rs
use ser... | code_fim | hard | {
"lang": "rust",
"repo": "daly4/authy-rs",
"path": "/src/api/onetouch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daly4/authy-rs path: /src/api/onetouch.rs
use serde_json;
use std::collections::HashMap;
use error::AuthyError;
use client::{Client, Status};
const PREFIX: &'static str = "onetouch";
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct ApprovalRequest {
uuid: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "daly4/authy-rs",
"path": "/src/api/onetouch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(logos) = logos {
for (k, v) in logos {
params.push(("logos[][res]".into(), k.clone().into()));
params.push(("logos[][res]".into(), v.clone()));
}
}
let (status, res) = client.post(PREFIX, &format!("users/{}/approval_requests", id), None, Som... | code_fim | hard | {
"lang": "rust",
"repo": "daly4/authy-rs",
"path": "/src/api/onetouch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>///
pub mod iter_parents {
/// The error returned by the [`Parents`][super::Parents] iterator.
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("An error occurred when parsing commit parents")]
DecodeCommit(#[from] gix_object::decode::Error... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-revwalk/src/graph/commit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Byron/gitoxide path: /gix-revwalk/src/graph/commit.rs
use gix_date::SecondsSinceUnixEpoch;
use smallvec::SmallVec;
use super::LazyCommit;
use crate::graph::{Commit, Either, Generation};
impl<'graph> LazyCommit<'graph> {
/// Return an iterator over the parents of this commit.
pub fn ite... | code_fim | hard | {
"lang": "rust",
"repo": "Byron/gitoxide",
"path": "/gix-revwalk/src/graph/commit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(se... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/rcc/apb2smenr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32l5/src/stm32l552/rcc/apb2smenr.rs
#[doc = "Reader of register APB2SMENR"]
pub type R = crate::R<u32, super::APB2SMENR>;
#[doc = "Writer for register APB2SMENR"]
pub type W = crate::W<u32, super::APB2SMENR>;
#[doc = "Register APB2SMENR `reset()`'s with... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/rcc/apb2smenr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.