text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> async fn set_as_current_generation(&self, derivation: &Path) -> Result<(), anyhow::Error> {
let mut cmd = self.session.command("sudo");
cmd.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.stdin(Stdio::inherit());
cmd.args(&["nix-env", "-p", "/nix/var... | code_fim | hard | {
"lang": "rust",
"repo": "andrew-d/deploy-flake",
"path": "/src/os/nixos.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tarberd/formally-cool path: /formally-cool/examples/dfa_compute.rs
use formally_cool::regular_languages::*;
use std::collections::BTreeMap;
fn main() {
let mut hash = BTreeMap::new();
hash.insert((String::from("q0"), String::from("a")), String::from("q0"));
hash.insert((String::fro... | code_fim | hard | {
"lang": "rust",
"repo": "tarberd/formally-cool",
"path": "/formally-cool/examples/dfa_compute.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Result for input {}: {}", input, result);
let input = String::from("bbb");
let result = automata.compute(input.as_str());
println!("Result for input {}: {}", input, result);
}<|fim_prefix|>// repo: tarberd/formally-cool path: /formally-cool/examples/dfa_compute.rs
use formall... | code_fim | hard | {
"lang": "rust",
"repo": "tarberd/formally-cool",
"path": "/formally-cool/examples/dfa_compute.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ffi_fn! {
/// Get the type of a mismatch.
fn pactffi_mismatch_type(mismatch: *const Mismatch) -> *const c_char {
let mismatch = as_ref!(mismatch);
let t = mismatch.mismatch_type();
string::to_c(t)? as *const c_char
} {
ptr::null_to::<c_char>()
}
}
ffi_fn! {... | code_fim | hard | {
"lang": "rust",
"repo": "audunhalland/pact-reference",
"path": "/rust/pact_ffi/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: audunhalland/pact-reference path: /rust/pact_ffi/src/lib.rs
//! A crate exposing the `pact` APIs to other languages
//! via a C Foreign Function Interface.
#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![warn(missing_copy_implementations)]
use std::ffi::CStr;
use std::str::Fr... | code_fim | hard | {
"lang": "rust",
"repo": "audunhalland/pact-reference",
"path": "/rust/pact_ffi/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn convert_cstr(name: &str, value: *const c_char) -> Option<&str> {
unsafe {
if value.is_null() {
::log::warn!("{} is NULL!", name);
None
} else {
let c_str = CStr::from_ptr(value);
match c_str.to_str() {
Ok(str) => Some(s... | code_fim | hard | {
"lang": "rust",
"repo": "audunhalland/pact-reference",
"path": "/rust/pact_ffi/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigp/lighthouse path: /beacon_node/genesis/src/common.rs
use int_to_bytes::int_to_fixed_bytes32;
use merkle_proof::MerkleTree;
use rayon::prelude::*;
use tree_hash::TreeHash;
use types::{ChainSpec, Deposit, DepositData, Hash256};
/// Accepts the genesis block validator `DepositData` list and pr... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/genesis/src/common.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> proofs.push(proof);
}
Ok(deposit_data
.into_iter()
.zip(proofs)
.map(|(data, proof)| (data, proof.into()))
.map(|(data, proof)| Deposit { proof, data })
.collect())
}<|fim_prefix|>// repo: sigp/lighthouse path: /beacon_node/genesis/src/common.rs
us... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/genesis/src/common.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> job.dimens.get_value::<String>("vehicle_id")
}
fn is_correct_vehicle(route: &Route, target_id: &str, target_shift: usize) -> bool {
route.actor.vehicle.dimens.get_id().unwrap() == target_id
&& get_shift_index(&route.actor.vehicle.dimens) == target_shift
}
fn is_single_belongs_to_route(ct... | code_fim | medium | {
"lang": "rust",
"repo": "tertsdiepraam/vrp",
"path": "/vrp-pragmatic/src/constraints/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tertsdiepraam/vrp path: /vrp-pragmatic/src/constraints/mod.rs
//! Contains implementation of extra constraints.
use std::sync::Arc;
use vrp_core::models::common::{Dimensions, IdDimension, ValueDimension};
use vrp_core::models::problem::Single;
use vrp_core::models::solution::{Activity, Route};
... | code_fim | medium | {
"lang": "rust",
"repo": "tertsdiepraam/vrp",
"path": "/vrp-pragmatic/src/constraints/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_single_belongs_to_route(ctx: &RouteContext, single: &Arc<Single>) -> bool {
let vehicle_id = get_vehicle_id_from_job(&single).unwrap();
let shift_index = get_shift_index(&single.dimens);
is_correct_vehicle(&ctx.route, vehicle_id, shift_index)
}
mod breaks;
pub use self::breaks::BreakMo... | code_fim | hard | {
"lang": "rust",
"repo": "tertsdiepraam/vrp",
"path": "/vrp-pragmatic/src/constraints/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn sleep() {
tokio::time::sleep(Duration::from_secs(60 * 10)).await;
}
#[tokio::test]
async fn load_version() {
let (url, version) = get_last_version().await.expect("Could not load version");
println!("Version url: {:?}", url);
println!("Version: {:?}", version);
assert!(
... | code_fim | hard | {
"lang": "rust",
"repo": "VictorKoenders/TrangarBot",
"path": "/src/actions/check_factorio_version.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VictorKoenders/TrangarBot path: /src/actions/check_factorio_version.rs
//! Check factorio version
//!
//! This polls https://forums.factorio.com/viewforum.php?f=3 at a regular interval. If there is a
//! new post available, it will be broadcasted to the IRC client.
use crate::data::Client;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "VictorKoenders/TrangarBot",
"path": "/src/actions/check_factorio_version.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>lazy_static! {
static ref VERSION_REGEX: Regex =
Regex::new(r#"<a href="([^"]*)"[^>]*topictitle">Version ([^<]*)<"#).unwrap();
}
async fn get_last_version() -> Result<(String, String), String> {
let response = reqwest::get("https://forums.factorio.com/viewforum.php?f=3")
.await
... | code_fim | hard | {
"lang": "rust",
"repo": "VictorKoenders/TrangarBot",
"path": "/src/actions/check_factorio_version.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: euclio/seventeen path: /src/screen.rs
use std::io::{self, Stdout, Write};
use bitflags::bitflags;
use euclid::{Point2D, Size2D};
use log::*;
use ndarray::prelude::*;
use termion::{
clear,
color::{Bg, Fg},
cursor,
raw::{IntoRawMode, RawTerminal},
screen::AlternateScreen,
... | code_fim | hard | {
"lang": "rust",
"repo": "euclio/seventeen",
"path": "/src/screen.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let buf = Cursor::new(vec![]);
let mut screen = Screen::new_from_write(Size2D::new(10, 3), buf).unwrap();
screen.write_str(Coordinate::new(0, 0), "foobarbaz");
screen.apply_style(
Coordinate::new(20, 2),
5,
&Style {
underl... | code_fim | hard | {
"lang": "rust",
"repo": "euclio/seventeen",
"path": "/src/screen.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn handle_test(message: MyEntry) -> ZomeApiResult<String>
{
//Ok("Hello " + message + ", welcome to Our World!")
Ok("Hello, welcome to Our World!".to_string())
}
pub fn handle_test2(message: String) -> ZomeApiResult<String>
{
//Ok("Hello " + message + ", welcome to Our World!")
Ok("... | code_fim | hard | {
"lang": "rust",
"repo": "NextGenSoftwareUK/Our-World-OASIS-API-HoloNET-HoloUnity-And-.NET-HDK",
"path": "/NextGenSoftware.Holochain.hApp.OurWorld.External.Partial/our_world/zomes/our_world_core/code/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
... |
<|fim_prefix|>// repo: NextGenSoftwareUK/Our-World-OASIS-API-HoloNET-HoloUnity-And-.NET-HDK path: /NextGenSoftware.Holochain.hApp.OurWorld.External.Partial/our_world/zomes/our_world_core/code/src/lib.rs
#![feature(try_from)]
#[macro_use]
extern crate hdk;
extern crate serde;
#[macro_use]
extern crate serde_derive;
ext... | code_fim | hard | {
"lang": "rust",
"repo": "NextGenSoftwareUK/Our-World-OASIS-API-HoloNET-HoloUnity-And-.NET-HDK",
"path": "/NextGenSoftware.Holochain.hApp.OurWorld.External.Partial/our_world/zomes/our_world_core/code/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
... |
<|fim_suffix|> entry!(
name: "my_entry",
description: "this is a same entry defintion",
sharing: Sharing::Public,
validation_package: || {
hdk::ValidationPackageDefinition::Entry
},
validation: | _validation_data: hdk::EntryValidationData<MyEntry>| {
... | code_fim | hard | {
"lang": "rust",
"repo": "NextGenSoftwareUK/Our-World-OASIS-API-HoloNET-HoloUnity-And-.NET-HDK",
"path": "/NextGenSoftware.Holochain.hApp.OurWorld.External.Partial/our_world/zomes/our_world_core/code/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
... |
<|fim_prefix|>// repo: Catamondium/projects path: /Rust/thread/chat/src/client.rs
use common::*;
use std::env;
use std::fmt::Write as fwrite;
use std::fs::remove_file;
use std::io::{self, stdin, BufRead, BufReader, LineWriter, Read, Write};
use std::net::TcpStream;
use std::os::unix::net::{UnixListener, UnixStream};
u... | code_fim | hard | {
"lang": "rust",
"repo": "Catamondium/projects",
"path": "/Rust/thread/chat/src/client.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pipe = UnixStream::connect(sock).unwrap();
let reader = BufReader::new(pipe);
for line in reader.lines().filter_map(|x| x.ok()).filter(|l| l != "") {
println!("{}", line);
}
}
fn main() -> GenericResult<()> {
match env::args().nth(1) {
Some(x) => {
if ... | code_fim | hard | {
"lang": "rust",
"repo": "Catamondium/projects",
"path": "/Rust/thread/chat/src/client.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> nick: &str,
chan: &mpsc::Receiver<String>,
display: &mut LineWriter<A>,
remote_write: &mut LineWriter<B>,
) -> GenericResult<()> {
let mut pending = false;
let mut buf = String::from(format!("{}\n", CLI_SEND));
for line in chan.try_iter() {
pending = true;
write... | code_fim | hard | {
"lang": "rust",
"repo": "Catamondium/projects",
"path": "/Rust/thread/chat/src/client.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_day_1_2() {
assert_eq!(256, find_duplicate_sum("src/res/day_1_1.txt").unwrap());
}
}
fn main() {
let sum = find_duplicate_sum("src/res/day_1_1.txt").unwrap();
println!("The first duplicated sum is {}", sum);
}<|fim_prefix|>// repo: falukropp/advent-of-code-2018... | code_fim | hard | {
"lang": "rust",
"repo": "falukropp/advent-of-code-2018-rust",
"path": "/src/bin/day_1_2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: falukropp/advent-of-code-2018-rust path: /src/bin/day_1_2.rs
use std::collections::HashSet;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
fn find_duplicate_sum(path: &str) -> Result<i64, std::io::Error> {
<|fim_suffix|> assert_eq!(256, find_duplicate_sum("src/res/day_1... | code_fim | hard | {
"lang": "rust",
"repo": "falukropp/advent-of-code-2018-rust",
"path": "/src/bin/day_1_2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(256, find_duplicate_sum("src/res/day_1_1.txt").unwrap());
}
}
fn main() {
let sum = find_duplicate_sum("src/res/day_1_1.txt").unwrap();
println!("The first duplicated sum is {}", sum);
}<|fim_prefix|>// repo: falukropp/advent-of-code-2018-rust path: /src/bin/day_1_2.rs
use... | code_fim | hard | {
"lang": "rust",
"repo": "falukropp/advent-of-code-2018-rust",
"path": "/src/bin/day_1_2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exoego/aws-lambda-events path: /aws_lambda_events/src/lib.rs
#[macro_use]
extern crate serde_derive;
extern crate base64;
extern crate bytes;
extern crate chrono;
#[cfg(test)]
#[<|fim_suffix|>rn crate http;
extern crate http_serde;
#[cfg(not(test))]
extern crate serde_json;
mod custom_serde;
//... | code_fim | medium | {
"lang": "rust",
"repo": "exoego/aws-lambda-events",
"path": "/aws_lambda_events/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ed in AWS Lambda json event values.
pub mod encodings;
/// AWS Lambda event definitions.
pub mod event;
mod generated;<|fim_prefix|>// repo: exoego/aws-lambda-events path: /aws_lambda_events/src/lib.rs
#[macro_use]
extern crate serde_derive;
extern crate base64;
extern crate bytes;
extern crate chrono;
#... | code_fim | medium | {
"lang": "rust",
"repo": "exoego/aws-lambda-events",
"path": "/aws_lambda_events/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let publication_id = PublicationId::new(publication_id)?;
let mut publication = self.publication_repo.find_by_id(&publication_id).await?;
publication.publish(&author)?;
self.publication_repo.save(&mut publication).await?;
self.event_pub
.publish_all(p... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/omics",
"path": "/publishing/application/publication/publish.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::domain::publication::Status;
use crate::mocks;
#[tokio::test]
async fn publish() {
let c = mocks::container();
let uc = Publish::new(c.event_pub(), c.author_repo(), c.publication_repo());
... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/omics",
"path": "/publishing/application/publication/publish.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dorucioclea/omics path: /publishing/application/publication/publish.rs
use common::event::EventPublisher;
use common::result::Result;
use crate::domain::author::{AuthorId, AuthorRepository};
use crate::domain::publication::{PublicationId, PublicationRepository};
// TODO: add comment
pub struct... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/omics",
"path": "/publishing/application/publication/publish.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
SequenceNumberCondition::Equal(val) => {
builder.header(IF_SEQUENCE_NUMBER_EQ, &val.to_string() as &str)
}
SequenceNumberCondition::LessOrEqual(val) => {
builder.header(IF_SEQUENCE_NUMBER_LE, &val.to_string() as &str)... | code_fim | medium | {
"lang": "rust",
"repo": "Displayr/azure-sdk-for-rust",
"path": "/sdk/core/src/request_options/sequence_number_condition.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Displayr/azure-sdk-for-rust path: /sdk/core/src/request_options/sequence_number_condition.rs
use crate::headers::*;
use crate::AddAsHeader;
use http::request::Builder;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SequenceNumberCondition {
Less(u64),
LessOrEqual(u64),
Equal(u64)... | code_fim | medium | {
"lang": "rust",
"repo": "Displayr/azure-sdk-for-rust",
"path": "/sdk/core/src/request_options/sequence_number_condition.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|>op; nop; nop; nop;");
}
} else {
if counter >= data.len() {
break;
}
p = data[counter];
counter += 1;
bitmask = 0x80;
}
}
}
}<|fim_prefix|>// repo: sajatt... | code_fim | hard | {
"lang": "rust",
"repo": "sajattack/ws2812-rs",
"path": "/src/write/nop.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sajattack/ws2812-rs path: /src/write/nop.rs
use embedded_hal::digital::OutputPin;
use crate::WS2812;
impl <P: OutputPin> WS2812<P> {
pub fn write(&mut self, data: &[u8]) {
let mut counter: usize = 0;
let mut p: u8 = data[counter];
counter += 1;
let mut bitmas... | code_fim | hard | {
"lang": "rust",
"repo": "sajattack/ws2812-rs",
"path": "/src/write/nop.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icyJoseph/advent-of-code path: /2022/src/bin/13.rs
use serde_json::Value;
use std::cmp::Ordering::{self, Equal, Greater, Less};
fn compare(left: &Value, right: &Value) -> Ordering {
match (left, right) {
(Value::Number(l), Value::Number(r)) => {
let left_number = l.as_u6... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2022/src/bin/13.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> packets.push(&two_marker);
packets.push(&six_marker);
packets.sort_by(|a, b| compare(a, b));
let two_pos = packets
.iter()
.position(|&packet| packet == &two_marker)
.unwrap()
+ 1;
let six_pos = packets
.iter()
.position(|&packet| pack... | code_fim | hard | {
"lang": "rust",
"repo": "icyJoseph/advent-of-code",
"path": "/2022/src/bin/13.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Slave: Clear SAIEN
self.slave_channel(|ch| {
ch.cr1.modify(|_, w| w.saien().disabled())
});
// Slave: Wait for SAI to clear
while self.slave_channel(|ch| {
... | code_fim | hard | {
"lang": "rust",
"repo": "hargoniX/stm32h7xx-hal",
"path": "/src/sai/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Access to the current master channel
fn master_channel<F, T>(&self, func: F) -> T
where F: FnOnce(&CH) -> T,
{
match self.master_channel {
SaiChannel::ChannelA => func(&self.rb.cha),
... | code_fim | hard | {
"lang": "rust",
"repo": "hargoniX/stm32h7xx-hal",
"path": "/src/sai/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hargoniX/stm32h7xx-hal path: /src/sai/mod.rs
//! # Serial Audio Interface
use core::marker::PhantomData;
use crate::stm32::sai4::CH;
use crate::stm32::{SAI1, SAI4};
// clocks
use crate::rcc::{rec, CoreClocks, ResetEnable};
use crate::time::Hertz;
use stm32h7::Variant::Val;
mod pdm;
pub use p... | code_fim | hard | {
"lang": "rust",
"repo": "hargoniX/stm32h7xx-hal",
"path": "/src/sai/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Ccr {
pub fn modify<F>(&mut self, f: F)
where for<'w> F: FnOnce(&CcrR, &'w mut CcrW) -> &'w mut CcrW
{
let bits = self.register.read();
let r = CcrR { bits: bits };
let mut w = CcrW { bits: bits };
f(&r, &mut w);
self.register.write(w.bits);
... | code_fim | hard | {
"lang": "rust",
"repo": "hellow554/stm32l4x6-memory-map",
"path": "/src/vref.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># [ derive ( Clone , Copy ) ]
# [ repr ( C ) ]
pub struct CcrR {
bits: u32,
}
impl CcrR {
# [ doc = "Bits 0:5 - Trimming code" ]
pub fn trim(&self) -> u8 {
const MASK: u32 = 63;
const OFFSET: u8 = 0u8;
((self.bits >> OFFSET) & MASK) as u8
}
}
# [ derive ( Clone , ... | code_fim | hard | {
"lang": "rust",
"repo": "hellow554/stm32l4x6-memory-map",
"path": "/src/vref.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hellow554/stm32l4x6-memory-map path: /src/vref.rs
# [ doc = "Voltage reference buffer" ]
# [ repr ( C ) ]
pub struct Vref {
# [ doc = "0x00 - VREF control and status register" ]
pub csr: Csr,
# [ doc = "0x04 - calibration control register" ]
pub ccr: Ccr,
}
# [ repr ( C ) ]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "hellow554/stm32l4x6-memory-map",
"path": "/src/vref.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `L`"]
pub type L_R = crate::R<bool, L_A>;
impl L_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> L_A {
match self.bits {
false => L_A::WARMRESET,
true => L_A::LO... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/emc/control.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fuchsch1234/lpc178x_7x path: /src/emc/control.rs
#[doc = "Reader of register CONTROL"]
pub type R = crate::R<u32, super::CONTROL>;
#[doc = "Writer for register CONTROL"]
pub type W = crate::W<u32, super::CONTROL>;
#[doc = "Register CONTROL `reset()`'s with value 0x03"]
impl crate::ResetValue for... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/emc/control.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for character in input.chars() {
match character {
// Skip whitespace
' ' => continue,
// Ending characters
';' | '\n' => {
result.push(EOF);
break;
}
// Math operations
'*' =>... | code_fim | hard | {
"lang": "rust",
"repo": "Muqito/minicompiler",
"path": "/src/main.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Muqito/minicompiler path: /src/main.rs
use std::error::Error;
use std::fmt;
use std::io;
/// Mathematical operations that our compiler can do.
#[derive(Debug, Eq, PartialEq)]
enum Op {
Mul,
Div,
Add,
Sub,
}
impl Op {
fn precedence(&self) -> i32 {
use Op::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "Muqito/minicompiler",
"path": "/src/main.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Emit a message as part of the current round.
///
/// Returns the index of the emitted message which is needed to check for the result of the
/// emitted message in the next round.
pub fn emit_message(&mut self, message: Message) -> u32 {
self.messages.push(message);
... | code_fim | hard | {
"lang": "rust",
"repo": "rootservers/oasis-core",
"path": "/runtime/src/transaction/context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rootservers/oasis-core path: /runtime/src/transaction/context.rs
//! Runtime call context.
use std::{any::Any, sync::Arc};
use io_context::Context as IoContext;
use super::tags::{Tag, Tags};
use crate::consensus::roothash::{Header, Message, MessageEvent};
struct NoRuntimeContext;
/// Transac... | code_fim | hard | {
"lang": "rust",
"repo": "rootservers/oasis-core",
"path": "/runtime/src/transaction/context.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Start a new transaction.
pub fn start_transaction(&mut self) {
self.tags.push(Tags::new());
}
/// Close the context and return the emitted tags and sent roothash messages.
pub fn close(self) -> (Vec<Tags>, Vec<Message>) {
(self.tags, self.messages)
}
/// E... | code_fim | hard | {
"lang": "rust",
"repo": "rootservers/oasis-core",
"path": "/runtime/src/transaction/context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagaban/rust_exercises path: /src/exercises/trailing_zeros.rs
// Write a program that will calculate the number of trailing zeros in a factorial of a given number.
// N! = 1 * 2 * 3 * ... * N
// Be careful 1000! has 2568 digits...
// For more info, see: http://mathworld.wolfram.com/Factorial.... | code_fim | medium | {
"lang": "rust",
"repo": "sagaban/rust_exercises",
"path": "/src/exercises/trailing_zeros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// For more info, see: http://mathworld.wolfram.com/Factorial.html
// Examples
// zeros(6) = 1
// # 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zero
// zeros(12) = 2
// # 12! = 479001600 --> 2 trailing zeros
// Hint: You're not meant to calculate the factorial. Find another way to find the number of... | code_fim | medium | {
"lang": "rust",
"repo": "sagaban/rust_exercises",
"path": "/src/exercises/trailing_zeros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Represents a secure mutable trie where the key is hashed, and
/// operated on any RLP values.
#[derive(Clone, Debug)]
pub struct AnySecureTrieMut<T: TrieMut>(SecureTrieMut<T>);
impl<T: TrieMut + Default> Default for AnySecureTrieMut<T> {
fn default() -> Self {
AnySecureTrieMut::new(T::def... | code_fim | hard | {
"lang": "rust",
"repo": "etclabscore/ethereum-rs",
"path": "/trie/memory/src/mutable.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etclabscore/ethereum-rs path: /trie/memory/src/mutable.rs
use bigint::H256;
use sha3::{Digest, Keccak256};
use rlp::{self, Rlp};
use std::marker::PhantomData;
/// Represents a trie that is mutable.
pub trait TrieMut {
/// Get the root hash of the current trie.
fn root(&self) -> H256;
... | code_fim | hard | {
"lang": "rust",
"repo": "etclabscore/ethereum-rs",
"path": "/trie/memory/src/mutable.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> AnySecureTrieMut::new(T::default())
}
}
impl<T: TrieMut> AnySecureTrieMut<T> {
/// Into the underlying TrieMut object.
pub fn to_trie(self) -> T {
self.0.to_trie()
}
/// Initialize a new mutable trie.
pub fn new(trie: T) -> Self {
AnySecureTrieMut(SecureTr... | code_fim | hard | {
"lang": "rust",
"repo": "etclabscore/ethereum-rs",
"path": "/trie/memory/src/mutable.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match w {
MouseButton::Left => 0,
MouseButton::Right => 1,
MouseButton::Middle => 2,
MouseButton::Generic(index) => index,
}
}
}
#[derive(Debug, Default)]
pub struct KeyboardInput {
pub pressed_keys: Vec<VirtualKeyCode>,
pub held... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/bit-bots",
"path": "/src/hardware_interfaces/input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sanbox-irl/bit-bots path: /src/hardware_interfaces/input.rs
use super::Vec2;
use winit::event::{ElementState, VirtualKeyCode};
#[derive(Debug)]
pub struct Input {
pub end_requested: bool,
pub new_frame_size: Option<Vec2>,
pub mouse_input: MouseInput,
pub kb_input: KeyboardInput,... | code_fim | hard | {
"lang": "rust",
"repo": "sanbox-irl/bit-bots",
"path": "/src/hardware_interfaces/input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let terminator = match e.len() {
0 => Instr::ret(null_iid, loc),
1 => Instr::jmp(e[0], loc),
2 => Instr::jmp_op(null_iid, instr::Predicate::NonZero, e[0], e[1], loc),
_ => panic!("unhandled edge count"),
};
... | code_fim | hard | {
"lang": "rust",
"repo": "sbuzonas/hhvm",
"path": "/hphp/hack/src/hackc/ir/testutils/testutils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbuzonas/hhvm path: /hphp/hack/src/hackc/ir/testutils/testutils.rs
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
//! This module contains shared functions for use by tests.
use hash::HashMap;
use ir_core::constant::Constant;
use ir_core::instr;
use ir_core::BlockId;
... | code_fim | hard | {
"lang": "rust",
"repo": "sbuzonas/hhvm",
"path": "/hphp/hack/src/hackc/ir/testutils/testutils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (name, edges) in testcase {
fb.start_block(name_to_bid[name]);
fb.cur_block_mut().pname_hint = Some(name.to_string());
let e: Vec<BlockId> = edges
.iter()
.map(|block_name| match name_to_bid.get(block_name) {
... | code_fim | hard | {
"lang": "rust",
"repo": "sbuzonas/hhvm",
"path": "/hphp/hack/src/hackc/ir/testutils/testutils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn post_test1() {
let query_string = "value1=123&value2=234";
let path = "cgi-bin/calculator.py";
let content_length = query_string.len().to_string();
let result = cgi_caller_post(
path,
content_length.as_str(),
"applicati... | code_fim | hard | {
"lang": "rust",
"repo": "fky2015/multithread-cgi-server",
"path": "/src/cgi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fky2015/multithread-cgi-server path: /src/cgi.rs
use std::env;
use std::io::{self, Write};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use crate::cgi::CgiCallError::{FileNotExists, RuntimeError};
const CGI_ROOT_PATH: &str = "./";
#[derive(Debug, PartialEq)]
pub enum CgiCallErr... | code_fim | hard | {
"lang": "rust",
"repo": "fky2015/multithread-cgi-server",
"path": "/src/cgi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn get_test2() {
let query_string = "value1=123&value2=234";
let path = "cgi-bin/not-exists";
let result = cgi_caller_get(path, query_string).err().unwrap();
assert_eq!(CgiCallError::FileNotExists, result);
}
#[test]
fn get_test3() {
let... | code_fim | hard | {
"lang": "rust",
"repo": "fky2015/multithread-cgi-server",
"path": "/src/cgi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 2. construct appropriate conifg struct
let ignore_list = ydoc["ignore"].as_vec();
let ignore_pattern = match ignore_list {
Some(v) => v
.iter()
.map(|y| y.as_str())
.filter(|opt| match opt {
Some(_) ... | code_fim | hard | {
"lang": "rust",
"repo": "AlwaysLee/how_many_lines",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(content) = fs::read_to_string(&fpath) {
let mut local_line = 0;
for _ in content.split('\n') {
local_line += 1;
}
self.total_line += local_line;
self.per_file_log
.push((String::from(fpath.to_str(... | code_fim | hard | {
"lang": "rust",
"repo": "AlwaysLee/how_many_lines",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlwaysLee/how_many_lines path: /src/main.rs
#![allow(dead_code)]
#![feature(never_type)]
extern crate regex;
extern crate yaml_rust;
#[macro_use]
extern crate lazy_static;
use colored::Colorize;
use rayon::prelude::*;
use regex::Regex;
use std::env;
use std::ops::Range;
use std::path;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "AlwaysLee/how_many_lines",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let head = Polygon::from(Triangle::new(
GeoLine::new(Point::new(0, -2), Point::new(0, 2)),
GeoLine::new(Point::new(0, 0), Point::new(3, 0)),
));
let line = Line::from(GeoLine::new(Point::new(-1, 0), Point::new(400, 0)));
Axis {
head: Som... | code_fim | medium | {
"lang": "rust",
"repo": "tokcum/wasm-svg",
"path": "/lib/src/svg/axis.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokcum/wasm-svg path: /lib/src/svg/axis.rs
use crate::geometry::Line as GeoLine;
use crate::geometry::{Point, Triangle};
use crate::svg::class::Class;
use crate::svg::{Line, SvgElement};
use crate::svg::Polygon;
#[derive(Debug)]
pub struct Axis {
head: Option<Polygon>,
line: Line,
}
im... | code_fim | medium | {
"lang": "rust",
"repo": "tokcum/wasm-svg",
"path": "/lib/src/svg/axis.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rummolprod999/WebParserRust path: /src/parsers/mod.rs
pub mod parser_ahstep;
pub mod parser_alfa;
pub mod parser_am;
pub mod parser_asia;
pub mod parser_azer;
pub mod parser_azs;
pub mod parser_baltika;
pub mod parser_beeline;
pub mod parser_dochki;
pub mod parser_eldorado;
pub mod parser_ingrad... | code_fim | medium | {
"lang": "rust",
"repo": "rummolprod999/WebParserRust",
"path": "/src/parsers/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>a;
pub mod parser_ruscoal;
pub mod parser_salavat;
pub mod parser_smp;
pub mod parser_snhz;
pub mod parser_tgk14;
pub mod parser_uds;
pub mod parser_ungi;
pub mod parsers;<|fim_prefix|>// repo: rummolprod999/WebParserRust path: /src/parsers/mod.rs
pub mod parser_ahstep;
pub mod parser_alfa;
pub mod parse... | code_fim | hard | {
"lang": "rust",
"repo": "rummolprod999/WebParserRust",
"path": "/src/parsers/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikialex/rendiation path: /utils/reactive/src/vec.rs
use crate::*;
#[pin_project]
pub struct StreamVec<T> {
streams: Vec<Option<T>>,
waked: Arc<SegQueue<usize>>,
waker: Arc<AtomicWaker>,
}
impl<T> Default for StreamVec<T> {
fn default() -> Self {
Self {
streams: Default::defa... | code_fim | hard | {
"lang": "rust",
"repo": "mikialex/rendiation",
"path": "/utils/reactive/src/vec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut c = 0;
crate::do_updates(&mut stream, |_| c += 1);
assert_eq!(c, 2);
}
#[pin_project]
pub struct MergeIntoStreamVec<S, T> {
#[pin]
inner: S,
#[pin]
vec: StreamVec<T>,
}
impl<S, T> AsRef<StreamVec<T>> for MergeIntoStreamVec<S, T> {
fn as_ref(&self) -> &StreamVec<T> {
&self.vec... | code_fim | hard | {
"lang": "rust",
"repo": "mikialex/rendiation",
"path": "/utils/reactive/src/vec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amar-laksh/rusty-euler path: /problem_18/src/main.rs
use std::time::Instant;
fn total_rows(length: usize) -> i64 {
let result = (((4*(length+length) + 1) as f64).sqrt() as i64 - 1)/2;
return result;
}
fn list(n_index: usize, row:i64, array: &Vec<i64>) -> Vec<i64>{
let max = row+2;
... | code_fim | hard | {
"lang": "rust",
"repo": "amar-laksh/rusty-euler",
"path": "/problem_18/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn main() {
let now = Instant::now();
{
println!("The sum is: {:?}"
, triangle());
}
let elapsed = now.elapsed();
let sec = (elapsed.as_secs() as f64)
+ (elapsed.subsec_nanos() as f64 / 1000_000_000.0);
println!("Time taken: {} seconds", sec... | code_fim | hard | {
"lang": "rust",
"repo": "amar-laksh/rusty-euler",
"path": "/problem_18/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustWorks/ticket_actix_web path: /server/src/routes/front_end.rs
use actix_identity::Identity;
use actix_web::{get, HttpResponse};
use std::{fs::File, io::Read};
#[get("/")]
pub async fn front_end(identity: Identity) -> <|fim_suffix|> let mut file = File::open("./static/public/index.html").unwr... | code_fim | hard | {
"lang": "rust",
"repo": "RustWorks/ticket_actix_web",
"path": "/server/src/routes/front_end.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>n")
.body("<p>This should redirect you, if it doesn't, click <a href=/api/auth/login>here</a>");
}
let mut contents = String::new();
let mut file = File::open("./static/public/index.html").unwrap();
file.read_to_string(&mut contents).unwrap();
HttpResponse::Ok().body(conte... | code_fim | medium | {
"lang": "rust",
"repo": "RustWorks/ticket_actix_web",
"path": "/server/src/routes/front_end.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An event that is sent whenever a listener is opened
#[derive(Debug, Clone)]
pub struct ListenerCreated {
pub id: ListenerId,
}
/*
/// An event that is sent whenever a listener receives a connection request
#[derive(Debug, Clone)]
pub struct ListenerRequest {
pub id: ListenerId,
pub remote... | code_fim | hard | {
"lang": "rust",
"repo": "0x22fe/bevy_prototype_simple_net",
"path": "/src/event.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0x22fe/bevy_prototype_simple_net path: /src/event.rs
use crate::common::{ListenerId, NetError, NetProtocol, Port, SocketAddress, SocketId};
// Socket events
/// An event that is sent whenever a socket should be opened
/// The `port` field must be specified when using UDP
#[derive(Debug, Clone)... | code_fim | hard | {
"lang": "rust",
"repo": "0x22fe/bevy_prototype_simple_net",
"path": "/src/event.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Atul9/simdeez path: /benches/sseby2.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use std::arch::x86_64::*;
const A : [f32;8] = [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0];
const B : [f32;8] = [7.0,6.0,5.0,4.0,3.0,2.0,1.0,0.0];
fn double_load() -> __m256 {
unsafe {
... | code_fim | medium | {
"lang": "rust",
"repo": "Atul9/simdeez",
"path": "/benches/sseby2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let suma = _mm_add_ps(_mm_loadu_ps(A.get_unchecked(0)),_mm_loadu_ps(B.get_unchecked(0)));
let sumb = _mm_add_ps(_mm_loadu_ps(A.get_unchecked(4)),_mm_loadu_ps(B.get_unchecked(4)));
let suma = std::mem::transmute::<__m128,[f32;4]>(suma);
let sumb = std::mem::tran... | code_fim | medium | {
"lang": "rust",
"repo": "Atul9/simdeez",
"path": "/benches/sseby2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: poppindouble/mini-bitcask path: /src/storage/bitcask/log_pointer.rs
pub struct LogPointer {
pub gen: u64,
pub pos: u64,
pub len: u64,
}
impl LogPointer {
<|fim_suffix|>nter {
LogPointer { gen, pos, len }
}
}<|fim_middle|> pub fn new(gen: u64, pos: u64, len: u64) -> Lo... | code_fim | easy | {
"lang": "rust",
"repo": "poppindouble/mini-bitcask",
"path": "/src/storage/bitcask/log_pointer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nter {
LogPointer { gen, pos, len }
}
}<|fim_prefix|>// repo: poppindouble/mini-bitcask path: /src/storage/bitcask/log_pointer.rs
pub struct LogPointer {
pub gen: u64,
pub pos: u64,
pub len: u64,
}
impl LogPointer {
<|fim_middle|> pub fn new(gen: u64, pos: u64, len: u64) -> Lo... | code_fim | easy | {
"lang": "rust",
"repo": "poppindouble/mini-bitcask",
"path": "/src/storage/bitcask/log_pointer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new(gen: u64, pos: u64, len: u64) -> LogPointer {
LogPointer { gen, pos, len }
}
}<|fim_prefix|>// repo: poppindouble/mini-bitcask path: /src/storage/bitcask/log_pointer.rs
pub struct LogPointer {
pub gen: u64,
pub p<|fim_middle|>os: u64,
pub len: u64,
}
impl LogPointer {... | code_fim | easy | {
"lang": "rust",
"repo": "poppindouble/mini-bitcask",
"path": "/src/storage/bitcask/log_pointer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> changes.sum()
}
fn first_repeat<'a>(changes: impl Iterator<Item = &'a isize> + Clone) -> Option<isize> {
let mut frequency = 0;
let mut frequencies = HashSet::new();
frequencies.insert(frequency);
for change in changes.cycle() {
frequency += change;
if frequencies.cont... | code_fim | hard | {
"lang": "rust",
"repo": "reillysiemens/advent-of-rust",
"path": "/2018/01/src/main.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let digits = vec!["-1", "-2", "-3"];
let expected = Ok(vec![-1, -2, -3]);
assert_eq!(expected, parse(digits.iter()));
}
#[test]
fn parse_handles_positive_and_negative_digits() {
let digits = vec!["+1", "+1", "-2"];
let expected = Ok(vec![1, 1, -2]);
... | code_fim | hard | {
"lang": "rust",
"repo": "reillysiemens/advent-of-rust",
"path": "/2018/01/src/main.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reillysiemens/advent-of-rust path: /2018/01/src/main.rs
use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::BufReader;
use std::io::{self, BufRead};
use std::num;
#[derive(Debug)]
enum Error {
ArgumentError,
EmptyInput,
IoError(io::Error),
ParseError(num... | code_fim | hard | {
"lang": "rust",
"repo": "reillysiemens/advent-of-rust",
"path": "/2018/01/src/main.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/euclid/src/box3d.rs
:
:
Output
{
Box3D
:
:
new
(
self
.
min
/
scale
.
clone
(
)
self
.
max
/
scale
)
}
}
impl
<
T
:
Copy
+
DivAssign
U
>
DivAssign
<
T
>
for
Box3D
<
T
U
>
{
#
[
inline
]
fn
div_assign
(
&
mut
self
scale
:
T
)
{
self
.
min
/
=
s... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/euclid/src/box3d.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_finite
(
)
}
}
impl
<
T
U
>
Box3D
<
T
U
>
where
T
:
Round
{
/
/
/
Return
a
box3d
with
edges
rounded
to
integer
coordinates
such
that
/
/
/
the
returned
box3d
has
the
same
set
of
pixel
centers
as
the
original
/
/
/
one
.
/
/
/
Values
equal
to
0
.
5
round
up
.
/
/
/
Suitable
for
most
places
where
integral
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/euclid/src/box3d.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/euclid/src/box3d.rs
n
interpretation
for
a
negative
box
is
to
consider
it
empty
.
It
can
be
obtained
/
/
/
by
calculating
the
intersection
of
two
boxes
that
do
not
intersect
.
#
[
inline
]
pub
fn
is_negative
(
&
self
)
-
>
bool
{
self
.
max
.
x... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/euclid/src/box3d.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(!has_same_adjacent_digits("1114576"));
assert!(!has_same_adjacent_digits("1111457"));
assert!(!has_same_adjacent_digits("1214576"));
assert!(!has_same_adjacent_digits("9234576"));
assert!(!has_same_adjacent_digits("12349576"));
}
}<|fim_prefix|>// repo: ... | code_fim | hard | {
"lang": "rust",
"repo": "fstephany/advent-of-code-2019",
"path": "/day-04/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(!digits_never_decrease("1234576"));
assert!(!digits_never_decrease("9234576"));
assert!(!digits_never_decrease("12349576"));
}
#[test]
fn has_adjacent_digits_test() {
assert!(has_same_adjacent_digits("1134567"));
assert!(has_same_adjacent_digits... | code_fim | hard | {
"lang": "rust",
"repo": "fstephany/advent-of-code-2019",
"path": "/day-04/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fstephany/advent-of-code-2019 path: /day-04/src/main.rs
use std::iter::FromIterator;
fn main() {
bruteforce();
}
fn bruteforce() {
let passwords: Vec<u32> = (137683..596253)
.filter(|c| {
let s = format!("{}", c);
has_same_adjacent_digits(&s) && digits_n... | code_fim | hard | {
"lang": "rust",
"repo": "fstephany/advent-of-code-2019",
"path": "/day-04/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TypeMapKey for DBPool {
type Value = MysqlPool;
}
pub struct ServerContainer;
impl TypeMapKey for ServerContainer {
type Value = HashMap<GuildId, DiscordServer>;
}
pub struct SubmissionSet;
impl TypeMapKey for SubmissionSet {
type Value = HashSet<u64>;
}
#[inline]
pub async fn get_co... | code_fim | medium | {
"lang": "rust",
"repo": "cassidoxa/murahdahla",
"path": "/src/helpers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cassidoxa/murahdahla path: /src/helpers.rs
use std::{
collections::{HashMap, HashSet},
error::Error,
};
use anyhow::Result;
use diesel::{
mysql::MysqlConnection,
r2d2::{ConnectionManager, Pool, PooledConnection},
};
use serenity::{client::Context, model::id::GuildId, prelude::Ty... | code_fim | medium | {
"lang": "rust",
"repo": "cassidoxa/murahdahla",
"path": "/src/helpers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PSeitz/f4ker-rs path: /src/iban.rs
t: 9
}
],
format: "BEkk bbbc cccc ccxx"
},
{
country: "BA",
total: 20,
bban: [
{
type: "n",
count: 6
},
{
type: "n",
count: 10
}
],
... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/iban.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>O",
total: 24,
bban: [
{
type: "a",
count: 4
},
{
type: "c",
count: 16
}
],
format: "ROkk bbbb cccc cccc cccc cccc"
},
{
country: "SM",
total: 27,
bban: [
{
type: "a"... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/iban.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> count: 4
},
{
type: "c",
count: 16
}
],
format: "ROkk bbbb cccc cccc cccc cccc"
},
{
country: "SM",
total: 27,
bban: [
{
type: "a",
count: 1
},
{
type: "n",
... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/f4ker-rs",
"path": "/src/iban.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn make_tx() {
}
fn main() {
println!("Hello, world!");
}<|fim_prefix|>// repo: TheWaWaR/txtool path: /txtool-rs/src/main.rs
extern crate protobuf;
<|fim_middle|>mod transaction;
use transaction::{
Crypto,
Transaction,
UnverifiedTransaction,
SignedTransaction
};
| code_fim | medium | {
"lang": "rust",
"repo": "TheWaWaR/txtool",
"path": "/txtool-rs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Hello, world!");
}<|fim_prefix|>// repo: TheWaWaR/txtool path: /txtool-rs/src/main.rs
extern crate protobuf;
mod transaction;
use transaction::{
Crypto,
Transaction,
UnverifiedTransaction,
SignedTransaction
};
<|fim_middle|>fn make_tx() {
}
fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "TheWaWaR/txtool",
"path": "/txtool-rs/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheWaWaR/txtool path: /txtool-rs/src/main.rs
extern crate protobuf;
mod transaction;
use transaction::{
Crypto,
Transaction,
UnverifiedTransaction,
SignedTransaction
};
<|fim_suffix|>}
fn main() {
println!("Hello, world!");
}<|fim_middle|>fn make_tx() {
| code_fim | easy | {
"lang": "rust",
"repo": "TheWaWaR/txtool",
"path": "/txtool-rs/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>bbabaabaaabaabbbabbbbbbb
aababaaabaaaaaaabbabbaaaabbababbabbbabaa
abbbabbabbaababababaaaaa
abbaaaabaaabbbbababaaabbbababaaabaaaaababbaababb
abaabbaababababbbbbbababbbbbbaababaaaabbabbbbbbaabaaaaaaaabbbbbb
aabbaaabaaabaaaaaababaaa
aaabbabbaabbbbaababbbabaaabbbaabbaababbb
baaabaabababbbabbbababab
aaaaabaaaa... | code_fim | hard | {
"lang": "rust",
"repo": "sumeet/aoc2020",
"path": "/day19_rs/src/main.rs",
"mode": "spm",
"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.