text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let mut potential_tickets = vec![];
for ticket in &input.2 {
if ticket.iter().all(|&v| in_bounds(v, &merged_bounds)) {
potential_tickets.push(ticket);
}
}
// next, we need to determine, for each rule, the possibilities for which field it is
// thus possibi... | code_fim | hard | {
"lang": "rust",
"repo": "tsutton/aoc2020",
"path": "/src/day16.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // next, we need to determine, for each rule, the possibilities for which field it is
// thus possibilities is a map from Rule => usize (index into ticket)
let num_fields = input.1.len();
let mut possibilities = HashMap::new();
for rule in &input.0 {
// for each rule, iterate o... | code_fim | hard | {
"lang": "rust",
"repo": "tsutton/aoc2020",
"path": "/src/day16.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tsutton/aoc2020 path: /src/day16.rs
use std::collections::HashMap;
use std::collections::HashSet;
use regex::Regex;
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub struct Rule {
field: String,
bounds: Vec<(i64, i64)>,
}
impl From<&str> for Rule {
fn from(s: &str) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "tsutton/aoc2020",
"path": "/src/day16.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rects = Layout::default()
.constraints([Constraint::Percentage(100)].as_ref())
.split(f.size());
let selected_style = Style::default().add_modifier(Modifier::REVERSED);
let normal_style = Style::default().bg(Color::Blue);
let header_cells = ["ID", "Date", "Account", "A... | code_fim | hard | {
"lang": "rust",
"repo": "guillaumebreton/ruin",
"path": "/src/ui.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guillaumebreton/ruin path: /src/ui.rs
use crate::model::{Account, Category, Service, Transaction};
use chrono::Duration;
use crossterm::event::{self, Event, KeyCode};
use std::io;
use tui::{
backend::Backend,
layout::{Constraint, Layout},
style::{Color, Modifier, Style},
widgets:... | code_fim | hard | {
"lang": "rust",
"repo": "guillaumebreton/ruin",
"path": "/src/ui.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let element = element_ref.value();
let id = element
.attr("data-tweet-id")
.and_then(|v| v.parse::<u64>().ok());
let user_id = element
.attr("data-user-id")
.and_then(|v| v.parse::<u64>().ok());
let user_screen_name = element.attr("data-screen-name");
l... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/cancel-culture",
"path": "/src/browser/twitter/parser.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/cancel-culture path: /src/browser/twitter/parser.rs
use chrono::{DateTime, TimeZone, Utc};
use flate2::read::GzDecoder;
use lazy_static::lazy_static;
use scraper::element_ref::ElementRef;
use scraper::node::Node;
use scraper::selector::Selector;
use scraper::Html;
use serde::Deserialize;... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/cancel-culture",
"path": "/src/browser/twitter/parser.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RobJenks/advent-of-code path: /2017/rust/day18/src/lib.rs
pub fn run() {
println!("Part 1 result: {}", part1(common::read_file("day18/input.txt")));
println!("Part 2 result: {}", part2(common::read_file("day18/input.txt")));
}
pub fn part1(input: String) -> isize {
CPU::new(100, par... | code_fim | hard | {
"lang": "rust",
"repo": "RobJenks/advent-of-code",
"path": "/2017/rust/day18/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_val(&mut self, reg: &RegVal, val: isize) {
let ri = self.reg_index(reg);
self.reg[ri as usize] = val;
}
fn receive_value(&mut self, val: isize) {
self.state.rcv.push(val);
}
}
impl Iterator for CPU {
type Item = CPUState;
fn next(&mut self) -> O... | code_fim | hard | {
"lang": "rust",
"repo": "RobJenks/advent-of-code",
"path": "/2017/rust/day18/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = try_ready!(self.socket.poll_recv_from(&mut self.buf));
println!("connect");
Ok(Async::Ready(()))
}
}
pub fn execute() {
let addr = "127.0.0.1:9000".to_string().parse::<SocketAddr>().unwrap();
let socket = UdpSocket::bind(&addr).unwrap();
println!("... | code_fim | medium | {
"lang": "rust",
"repo": "nao-kobayashi/tokio_sample",
"path": "/future_sample/src/second_future.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
impl Future for EchoServer {
type Item = ();
type Error = ();
fn poll(&mut self) -> Poll<(), ()> {
match self.socket.poll_recv_from(&mut self.buf) {
Ok(Async::Ready((_size, _peer))) => {
println!("recv");
Ok(Async::Ready(()))
... | code_fim | hard | {
"lang": "rust",
"repo": "nao-kobayashi/tokio_sample",
"path": "/future_sample/src/second_future.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nao-kobayashi/tokio_sample path: /future_sample/src/second_future.rs
use tokio::prelude::*;
use tokio::net::UdpSocket;
use std::net::SocketAddr;
use futures::try_ready;
struct EchoServer {
socket: UdpSocket,
buf: Vec<u8>,
}
impl EchoServer {
fn new(socket: UdpSocket) -... | code_fim | hard | {
"lang": "rust",
"repo": "nao-kobayashi/tokio_sample",
"path": "/future_sample/src/second_future.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_fund(funds: Vec<Coin>, denom: String) -> Result<Coin, ContractError> {
for fund in funds.into_iter() {
if fund.denom == denom {
return Ok(fund);
}
}
Err(ContractError::InsufficientFunds {})
}
pub fn maybe_addr(api: &dyn Api, human: Option<String>) -> St... | code_fim | hard | {
"lang": "rust",
"repo": "moonmidas/cw-contracts",
"path": "/contracts/nft-market/src/state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moonmidas/cw-contracts path: /contracts/nft-market/src/state.rs
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::error::ContractError;
use cosmwasm_std::{Addr, Api, Coin, Decimal, StdResult, Storage};
use cw_storage_plus::{Item, Map};
#[derive(Serialize, Deserialize, C... | code_fim | medium | {
"lang": "rust",
"repo": "moonmidas/cw-contracts",
"path": "/contracts/nft-market/src/state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> SimpleLogger::new().init().unwrap();
let event_loop = EventLoop::new()?;
let window = WindowBuilder::new()
.with_title("An embedded window!")
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.with_embed_parent_window(parent_window_id... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/winit",
"path": "/examples/x11_embed.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-windowing/winit path: /examples/x11_embed.rs
//! A demonstration of embedding a winit window in an existing X11 application.
#[cfg(x11_platform)]
#[path = "util/fill.rs"]
mod fill;
#[cfg(x11_platform)]
mod imple {
use super::fill;
use simple_logger::SimpleLogger;
use winit::{
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/winit",
"path": "/examples/x11_embed.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
#[cfg(not(x11_platform))]
mod imple {
pub(super) fn entry() -> Result<(), Box<dyn std::error::Error>> {
println!("This example is only supported on X11 platforms.");
Ok(())
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
imple::entry()
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "rust-windowing/winit",
"path": "/examples/x11_embed.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut index: usize = 0;
let mut e_index: usize = 0;
while index < len {
if start.get(index..index + 1) == Some("L") {
while e_index < len && end.get(e_index..e_index + 1) != Some("L") {
e_index = e_index + 1;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "lvcq/rust-leetcode",
"path": "/src/solutions/777.在lr字符串中交换相邻字符.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lvcq/rust-leetcode path: /src/solutions/777.在lr字符串中交换相邻字符.rs
/*
* @lc app=leetcode.cn id=777 lang=rust
*
* [777] 在LR字符串中交换相邻字符
*/
// @lc code=start
impl Solution {
pub fn can_transform(start: String, end: String) -> bool {
if !start.replace("X", "").eq(&end.replace("X", "")) {
... | code_fim | hard | {
"lang": "rust",
"repo": "lvcq/rust-leetcode",
"path": "/src/solutions/777.在lr字符串中交换相邻字符.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let module = black_box(EXAMPLE_FILE);
group.throughput(Throughput::Bytes(EXAMPLE_FILE.len() as u64));
group.bench_function("parse example.nix", move |b| {
b.iter_with_large_drop(|| {
SourceFile::from_str(module).expect("Failed to parse example.nix")
});
});
... | code_fim | medium | {
"lang": "rust",
"repo": "plumenator/nix-language-server",
"path": "/nix-parser/benches/example.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plumenator/nix-language-server path: /nix-parser/benches/example.rs
use std::str::FromStr;
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
use nix_parser::ast::SourceFile;
const EXAMPLE_FILE: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/example.... | code_fim | hard | {
"lang": "rust",
"repo": "plumenator/nix-language-server",
"path": "/nix-parser/benches/example.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut group = b.benchmark_group("parse_example");
let module = black_box(EXAMPLE_FILE);
group.throughput(Throughput::Bytes(EXAMPLE_FILE.len() as u64));
group.bench_function("parse example.nix", move |b| {
b.iter_with_large_drop(|| {
SourceFile::from_str(module).expec... | code_fim | medium | {
"lang": "rust",
"repo": "plumenator/nix-language-server",
"path": "/nix-parser/benches/example.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DougLau/splot path: /src/lib.rs
//! # splot
//!
//! Plot data to HTML
//!
//! Project goals:
//!
//! - Simple but powerful API
//! - Styling using CSS
//! - Usable in WebAssembly
//!
//! ## Example Line Plot
//!
//! ```rust
//! use splot::{plot, Chart, Domain, Page};
//!
//! let data = vec {
if_chain! {
if ecx.sess.opts.edition == Edition::Edition2018;
if let ast::ItemKind::Use(use_tree) = &item.kind;
if let Some(mac_attr) = item
... | code_fim | hard | {
"lang": "rust",
"repo": "rabisg0/rust-clippy",
"path": "/clippy_lints/src/macro_use.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rabisg0/rust-clippy path: /clippy_lints/src/macro_use.rs
use crate::utils::{snippet, span_lint_and_sugg};
use if_chain::if_chain;
use rustc_ast::ast;
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rus... | code_fim | hard | {
"lang": "rust",
"repo": "rabisg0/rust-clippy",
"path": "/clippy_lints/src/macro_use.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/dylint path: /internal/src/command.rs
use anyhow::{ensure, Result};
use std::{
ffi::{OsStr, OsString},
path::Path,
process::Output,
};
pub struct Command {
envs: Vec<(OsString, OsString)>,
command: std::process::Command,
}
impl Command {
pub fn new<S: AsRef<OsSt... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/dylint",
"path": "/internal/src/command.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn success(&mut self) -> Result<()> {
log::debug!("{:?}", self.envs);
log::debug!("{:?}", self.command);
let status = self.command.status()?;
ensure!(status.success(), "command failed: {:?}", self.command);
Ok(())
}
}<|fim_prefix|>// repo: isgasho/dyl... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/dylint",
"path": "/internal/src/command.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ardacetinkaya/learning-rust path: /guess-the-number-game/src/main.rs
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn main() {
println!("Hi, I guessed a number. Let's see if you can find it.");
<|fim_suffix|> //Endless game until you find the number :)
loop {
let mut g... | code_fim | hard | {
"lang": "rust",
"repo": "ardacetinkaya/learning-rust",
"path": "/guess-the-number-game/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match guess.cmp(&number) {
Ordering::Less => println!("A little bit bigger ↑"),
Ordering::Greater => println!("A little bit smaller ↓"),
Ordering::Equal => {
println!("You win!");
break;
}
}
}
}<|fim_prefix... | code_fim | hard | {
"lang": "rust",
"repo": "ardacetinkaya/learning-rust",
"path": "/guess-the-number-game/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Get input from user
io::stdin()
.read_line(&mut guess)
.expect("Failed to read line");
//Need to be parsed as integer. If it is not, print some message
let guess: u32 = match guess.trim().parse() {
Ok(num) => num,
Err(_) =>... | code_fim | hard | {
"lang": "rust",
"repo": "ardacetinkaya/learning-rust",
"path": "/guess-the-number-game/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ImmemorConsultrixContrarie/vim-clap path: /crates/fulf/src/filepath_cache.rs
er.write_chunk_to(&mut cache, &mut indicies);
Ok(IndexedCache::new(cache, indicies))
}
/// The base folder is unique: it's the only folder that has no files in it;
/// it has a starting byte zero, whether all othe... | code_fim | hard | {
"lang": "rust",
"repo": "ImmemorConsultrixContrarie/vim-clap",
"path": "/crates/fulf/src/filepath_cache.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn decode(cache: &[u8]) -> Result<(ByteOrUsize, &[u8]), InvalidCache<()>> {
match cache.get(0) {
Some(&byte) => {
if byte & LAST_BIT == 0 {
Ok((if byte == 0 { ZeroByte } else { Byte(byte) }, &cache[1..]))
} else if c... | code_fim | hard | {
"lang": "rust",
"repo": "ImmemorConsultrixContrarie/vim-clap",
"path": "/crates/fulf/src/filepath_cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_serialize_deserialize() {
fn qwe(mut iter: StreamIter) -> Result<(), InvalidCache<()>> {
while let Some(pathstring) = iter.read_next()? {
// println!("{}", pathstring);
let path: &std::p... | code_fim | hard | {
"lang": "rust",
"repo": "ImmemorConsultrixContrarie/vim-clap",
"path": "/crates/fulf/src/filepath_cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yannleretaille/cpp_to_rust path: /src/qt_doc_parser.rs
use errors::{Result, ChainErr};
use file_utils::{PathBufWithAdded, read_dir, file_to_string, os_str_to_str};
use log;
use utils::MapIfOk;
use std::path::PathBuf;
use std::collections::HashMap;
extern crate select;
use self::select::documen... | code_fim | hard | {
"lang": "rust",
"repo": "yannleretaille/cpp_to_rust",
"path": "/src/qt_doc_parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut results = Vec::new();
use self::select::predicate::{And, Attr, Name, Class};
let h3s = doc.find(And(Name("h3"), Class("fn")));
for h3 in h3s.iter() {
let anchor = h3.find(And(Name("a"), Attr("name", ())));
let anchor_node = if let Some(r) = anchor.iter().next() {
... | code_fim | hard | {
"lang": "rust",
"repo": "yannleretaille/cpp_to_rust",
"path": "/src/qt_doc_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn all_method_docs(doc: &Document) -> Result<Vec<QtDocForMethod>> {
let mut results = Vec::new();
use self::select::predicate::{And, Attr, Name, Class};
let h3s = doc.find(And(Name("h3"), Class("fn")));
for h3 in h3s.iter() {
let anchor = h3.find(And(Name("a"), Attr("name", ())));... | code_fim | hard | {
"lang": "rust",
"repo": "yannleretaille/cpp_to_rust",
"path": "/src/qt_doc_parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burakbayramli/books path: /Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter09/miscellaneous/snippet1.rs
use std::thread;
fn main() {
for _ in<|fim_suffix|>read::current().id());
});
}
}<|fim_middle|> 1..5 {
thread::spawn(|| {
println!("Hi from... | code_fim | medium | {
"lang": "rust",
"repo": "burakbayramli/books",
"path": "/Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter09/miscellaneous/snippet1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Hi from thread id {:?}", thread::current().id());
});
}
}<|fim_prefix|>// repo: burakbayramli/books path: /Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter09/miscellaneous/snippet1.rs
use std::thread;
fn main() {
for _ in<|fim_middle|> 1..5 {
thread... | code_fim | easy | {
"lang": "rust",
"repo": "burakbayramli/books",
"path": "/Practical_System_Programming_for_Rust_Developers_Eshwarla/Chapter09/miscellaneous/snippet1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> BFTM0RST_R::new(((self.bits >> 16) & 1) != 0)
}
#[doc = "Bit 17 - BFTM1RST"]
#[inline(always)]
pub fn bftm1rst(&self) -> BFTM1RST_R {
BFTM1RST_R::new(((self.bits >> 17) & 1) != 0)
}
#[doc = "Bit 19 - LCDRST"]
#[inline(always)]
pub fn lcdrst(&self) -> LCDRST_R {
... | code_fim | hard | {
"lang": "rust",
"repo": "ht32-rs/ht32-rs-nightlies",
"path": "/ht32f5xxxx/src/ht32f59741/rstcu/rstcu_apbprstr1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s)]
#[must_use]
pub fn lcdrst(&mut self) -> LCDRST_W<19> {
LCDRST_W::new(self)
}
#[doc = "Bit 21 - DACRST"]
#[inline(always)]
#[must_use]
pub fn dacrst(&mut self) -> DACRST_W<21> {
DACRST_W::new(self)
}
#[doc = "Bit 22 - CMPRST"]
#[inline(always)]
... | code_fim | hard | {
"lang": "rust",
"repo": "ht32-rs/ht32-rs-nightlies",
"path": "/ht32f5xxxx/src/ht32f59741/rstcu/rstcu_apbprstr1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ht32-rs/ht32-rs-nightlies path: /ht32f5xxxx/src/ht32f59741/rstcu/rstcu_apbprstr1.rs
#[doc = "Register `RSTCU_APBPRSTR1` reader"]
pub struct R(crate::R<RSTCU_APBPRSTR1_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<RSTCU_APBPRSTR1_SPEC>;
#[inline(always)]
fn deref(&self)... | code_fim | hard | {
"lang": "rust",
"repo": "ht32-rs/ht32-rs-nightlies",
"path": "/ht32f5xxxx/src/ht32f59741/rstcu/rstcu_apbprstr1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fredmorcos/attic path: /Snippets/Rust/naive_hashmap/src/bin/specialized_interpreter.rs
extern crate naive_hashmap;
use std::io;
use std::io::prelude::*;
use std::str::FromStr;
fn main() {
<|fim_suffix|> for line in n.lock().lines() {
if let Ok(line) = line {
let mut cmd = line.split... | code_fim | medium | {
"lang": "rust",
"repo": "fredmorcos/attic",
"path": "/Snippets/Rust/naive_hashmap/src/bin/specialized_interpreter.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hash_map = naive_hashmap::HashMapU8::new();
let n = io::stdin();
for line in n.lock().lines() {
if let Ok(line) = line {
let mut cmd = line.split_whitespace();
match cmd.next() {
Some("LOOKUP") => if let Some(key) = cmd.next() {
if let Ok(key) = u8::from_s... | code_fim | medium | {
"lang": "rust",
"repo": "fredmorcos/attic",
"path": "/Snippets/Rust/naive_hashmap/src/bin/specialized_interpreter.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhanzehua/fe path: /compiler/src/yul/mappers/contracts.rs
use crate::errors::CompileError;
use crate::yul::mappers::{
constructor,
functions,
};
use crate::yul::runtime::abi as runtime_abi;
use crate::yul::runtime::functions as runtime_functions;
use fe_parser::ast as fe;
use fe_parser::... | code_fim | hard | {
"lang": "rust",
"repo": "zhanzehua/fe",
"path": "/compiler/src/yul/mappers/contracts.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(statements)
},
)?;
statements.append(&mut runtime_functions::all());
statements.push(runtime_abi::dispatcher(functions.to_owned())?);
return Ok(yul::Object {
name: identifier! { Contract },
code: constructor::runtime(... | code_fim | hard | {
"lang": "rust",
"repo": "zhanzehua/fe",
"path": "/compiler/src/yul/mappers/contracts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(dead_code)]
fn score_segmentations(elements: Vec<Vec<f32>>, point_average: f32) -> f32 {
elements
.iter()
.map(|group| {
let mut total: f32 = 0.0_f32;
for group_elem in group.iter() {
total += *group_elem
}
(total ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/partitions",
"path": "/src/partition_methods/football_partition.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/partitions path: /src/partition_methods/football_partition.rs
#[allow(dead_code)]
fn football_partition(mut data: Vec<f32>, ideal_group_length: usize) -> Vec<Vec<f32>> {
data.sort_by(|a, b| b.partial_cmp(a).unwrap_or(std::cmp::Ordering::Equal));
let ideal_group_value: f32 =
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/partitions",
"path": "/src/partition_methods/football_partition.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> elements
.iter()
.map(|group| {
let mut total: f32 = 0.0_f32;
for group_elem in group.iter() {
total += *group_elem
}
(total - point_average).abs()
})
.fold(0.0_f32, |acc: f32, elem: f32| acc + elem)
}<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/partitions",
"path": "/src/partition_methods/football_partition.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let delegator_1_key = PublicKey::from(
&SecretKey::ed25519_from_bytes([42; SecretKey::ED25519_LENGTH]).unwrap(),
);
let delegator_2_key = PublicKey::from(
&SecretKey::ed25519_from_bytes([43; SecretKey::ED25519_LENGTH]).unwrap(),
);
let delega... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/types/src/system/auction/seigniorage_recipient.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nguyenminhhieu12041996/casper-node path: /types/src/system/auction/seigniorage_recipient.rs
use alloc::{collections::BTreeMap, vec::Vec};
use crate::{
bytesrepr::{self, FromBytes, ToBytes},
system::auction::{Bid, DelegationRate},
CLType, CLTyped, PublicKey, U512,
};
/// The seignio... | code_fim | hard | {
"lang": "rust",
"repo": "nguyenminhhieu12041996/casper-node",
"path": "/types/src/system/auction/seigniorage_recipient.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> while !row_complete(n, &numbers) {
numbers.sort();
results.push(numbers.clone());
if target == (*numbers.iter().min().unwrap() + 1) || target == 1 {
numbers.push(n - 1);
target = n - 1;
target_count += 1;
}else{
numbers.r... | code_fim | hard | {
"lang": "rust",
"repo": "elitru/ProgrammingChallenges",
"path": "/Subset/Rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elitru/ProgrammingChallenges path: /Subset/Rust/src/main.rs
use std::io::{self, BufRead};
use std::time::Instant;
use console::Style;
use crate::error::CustomError;
mod error;
fn main() {
match get_input() {
Ok(number) => {
let now = Instant::now();
let _ =... | code_fim | hard | {
"lang": "rust",
"repo": "elitru/ProgrammingChallenges",
"path": "/Subset/Rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/lcdif/vdctrl4/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::VDCTRL4 {
#[doc = r" Modifies the contents of the register"]
#[inlin... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/lcdif/vdctrl4/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>should be delayed before coming out of the LCD_DOTCK pin"]
#[inline]
pub fn dotclk_dly_sel(&self) -> DOTCLK_DLY_SELR {
let bits = {
const MASK: u8 = 7;
const OFFSET: u8 = 29;
((self.bits >> OFFSET) & MASK as u32) as u8
};
DOTCLK_DLY_SELR ... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/lcdif/vdctrl4/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // for loops can loop forever: `for (;;) {}`
if let Some(condition) = maybe_condition {
let condition = self.compile_expr(condition, builder)?;
builder.ins().brz(condition.ir_val, end_body, &[]);
self.fallthrough(builder);
}
self.compile... | code_fim | hard | {
"lang": "rust",
"repo": "jyn514/saltwater",
"path": "/saltwater-codegen/stmt.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> builder.switch_to_block(end_body);
self.exit_loop(old_saw_loop);
Ok(())
}
pub(super) fn fallthrough(&self, builder: &mut FunctionBuilder) {
let bb = builder.create_block();
builder.ins().jump(bb, &[]);
builder.switch_to_block(bb);
}
fn do_loo... | code_fim | hard | {
"lang": "rust",
"repo": "jyn514/saltwater",
"path": "/saltwater-codegen/stmt.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jyn514/saltwater path: /saltwater-codegen/stmt.rs
use cranelift::codegen::cursor::Cursor;
use cranelift::frontend::Switch;
use cranelift::prelude::{Block, FunctionBuilder, InstBuilder};
use cranelift_module::Backend;
use super::Compiler;
use saltwater_parser::data::{
hir::{Expr, Stmt, StmtT... | code_fim | hard | {
"lang": "rust",
"repo": "jyn514/saltwater",
"path": "/saltwater-codegen/stmt.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bjorns/algo path: /rust/hammingcluster.rs
use std::io::File;
use std::io::BufferedReader;
use std::string::String;
use std::os;
mod unionfind;
fn atoi(ch: char) -> uint {
return if ch == '1' {
1
} else {
0
};
}
fn to_uint(mut str: String) -> uint {
let mut re... | code_fim | hard | {
"lang": "rust",
"repo": "bjorns/algo",
"path": "/rust/hammingcluster.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = Path::new(bytes);
let mut file = File::open(&path);
if file.is_ok() {
let data = parse_numbers(file.ok().unwrap());
let uf = init_unionfind(&data);
merge_neighbours(uf, &data);
}
println!("hello!");
}<|fim_prefix|>// repo: bjorns/algo path: /rust/... | code_fim | hard | {
"lang": "rust",
"repo": "bjorns/algo",
"path": "/rust/hammingcluster.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hooops/crypto-crawler-rs path: /crypto-pair/tests/ftx.rs
mod utils;
use crypto_pair::normalize_pair;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use utils::http_get;
const EXCHANGE_NAME: &'static str = "ftx";
#[derive(Serialize, Deserialize)]
#[a... | code_fim | medium | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-pair/tests/ftx.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let txt = http_get("https://ftx.com/api/markets").unwrap();
let resp = serde_json::from_str::<Response>(&txt).unwrap();
assert!(resp.success);
resp.result
}
#[test]
fn verify_all_symbols() {
let markets = fetch_markets_raw();
for market in markets.iter() {
let pair = norma... | code_fim | medium | {
"lang": "rust",
"repo": "hooops/crypto-crawler-rs",
"path": "/crypto-pair/tests/ftx.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vyuham/rtrcrs path: /src/hittable_list.rs
use std::sync::Arc;
use crate::{HitRecord, Hittable, Ray};
/// Defines a data-structure to store all the Hittable objects.
pub struct HittableList {
objects: Vec<Arc<dyn Hittable>>,
}
impl HittableList {
/// Creates an empty object list.
p... | code_fim | medium | {
"lang": "rust",
"repo": "vyuham/rtrcrs",
"path": "/src/hittable_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for object in self.objects.iter() {
if let Some(temp_rec) = object.hit(ray, t_min, closest_so_far) {
closest_so_far = temp_rec.t;
hit_anything = Some(temp_rec);
}
}
hit_anything
}
}<|fim_prefix|>// repo: vyuham/rtrcrs pa... | code_fim | hard | {
"lang": "rust",
"repo": "vyuham/rtrcrs",
"path": "/src/hittable_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>),
)),
|(ident, _, extra)| UseRootNode { ident, extra },
)(t)
}<|fim_prefix|>// repo: illlust/danube path: /danube-parse/src/parse/parse_use_root_node.rs
use super::*;
pub(super) fn parse_use_root_node(t: Tokens) -> ParseResult<UseRoot<|fim_middle|>Node> {
map(
tuple((
... | code_fim | medium | {
"lang": "rust",
"repo": "illlust/danube",
"path": "/danube-parse/src/parse/parse_use_root_node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: illlust/danube path: /danube-parse/src/parse/parse_use_root_node.rs
use super::*;
pub(super) fn parse_use_root_node(t: Tokens) -> ParseResult<UseRoot<|fim_suffix|> parse_symbol(Symbol::DoubleColon),
parse_use_kind(parse_use_extra_kind),
)),
|(ident, _, extra)| UseRoo... | code_fim | medium | {
"lang": "rust",
"repo": "illlust/danube",
"path": "/danube-parse/src/parse/parse_use_root_node.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>intln!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=static=civetweb");
}<|fim_prefix|>// repo: sgrif/rust-civet path: /civet-sys/build.rs
extern crate cmake;
use cmake::Config;
fn main() {
let mut dst = Config::new("civetweb")
<|fim_midd... | code_fim | hard | {
"lang": "rust",
"repo": "sgrif/rust-civet",
"path": "/civet-sys/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgrif/rust-civet path: /civet-sys/build.rs
extern crate cmake;
use cmake::Config;
fn main() {
let mut dst = Config::new("civetweb")
<|fim_suffix|> .define("CIVETWEB_ALLOW_WARNINGS", "ON")
.build();
dst.push("lib");
println!("ca... | code_fim | hard | {
"lang": "rust",
"repo": "sgrif/rust-civet",
"path": "/civet-sys/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_js!(
r#"
pub fn debug(x) {
let x = x
fn(x) { x + 1 }
}
"#,
);
}
#[test]
fn module_const_var() {
assert_js!(
r#"
pub const int = 42
pub const int_alias = int
pub fn use_int_alias() { int_alias }
pub const compound: #(Int, Int) = #(int, int_alias)
pub fn use_compoun... | code_fim | hard | {
"lang": "rust",
"repo": "gleam-lang/gleam",
"path": "/compiler-core/src/javascript/tests/assignments.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_js!(
r#"
pub const int = 42
pub const int_alias = int
pub fn use_int_alias() { int_alias }
pub const compound: #(Int, Int) = #(int, int_alias)
pub fn use_compound() { compound.0 + compound.1 }
"#
);
}
#[test]
fn module_const_var1() {
assert_ts_def!(
r#"
pub const int ... | code_fim | hard | {
"lang": "rust",
"repo": "gleam-lang/gleam",
"path": "/compiler-core/src/javascript/tests/assignments.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gleam-lang/gleam path: /compiler-core/src/javascript/tests/assignments.rs
use crate::{assert_js, assert_ts_def};
#[test]
fn tuple_matching() {
assert_js!(
r#"
fn go(x) {
let #(1, 2) = x
}
"#,
)
}
#[test]
fn assert() {
assert_js!(r#"fn go(x) { let assert 1 = x }"#,);
... | code_fim | hard | {
"lang": "rust",
"repo": "gleam-lang/gleam",
"path": "/compiler-core/src/javascript/tests/assignments.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/matroska-demuxer path: /src/enums.rs
//! Enums exposed in the API.
/// The Matrix Coefficients of the video used to derive luma and chroma values
/// from red, green, and blue color primaries.
///
/// For clarity, the value and meanings for `MatrixCoefficients` are adopted from
/// Tabl... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/matroska-demuxer",
"path": "/src/enums.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<u64> for ChromaSitingVert {
fn from(d: u64) -> Self {
match d {
1 => ChromaSitingVert::LeftCollated,
2 => ChromaSitingVert::Half,
_ => ChromaSitingVert::Unknown,
}
}
}
/// Clipping of the color ranges.
#[derive(Clone, Copy, Debug, Eq, ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/matroska-demuxer",
"path": "/src/enums.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benwaffle/broot path: /src/pattern/mod.rs
mod candidate;
mod composite_pattern;
mod content_pattern;
mod fuzzy_patterns;
mod input_pattern;
mod operator;
mod pattern;
mod name_match;
mod pattern_object;
<|fim_suffix|> pattern_parts::PatternParts,
operator::PatternOperator,
regex_pattern... | code_fim | hard | {
"lang": "rust",
"repo": "benwaffle/broot",
"path": "/src/pattern/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pattern_parts::PatternParts,
operator::PatternOperator,
regex_patterns::RegexPattern,
search_mode::{SearchMode, SearchModeMap, SearchModeMapEntry},
};<|fim_prefix|>// repo: benwaffle/broot path: /src/pattern/mod.rs
mod candidate;
mod composite_pattern;
mod content_pattern;
mod fuzzy_pattern... | code_fim | medium | {
"lang": "rust",
"repo": "benwaffle/broot",
"path": "/src/pattern/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alecmocatta/palaver path: /src/file.rs
g::O_RDONLY, stat::Mode::empty()).unwrap();
let fd_flags = FdFlag::from_bits(fcntl::fcntl(fd, fcntl::FcntlArg::F_GETFD).unwrap()).unwrap();
let fl_flags = OFlag::from_bits_truncate(fcntl::fcntl(fd, fcntl::FcntlArg::F_GETFL).unwrap())
& !(OFlag::O_WRONLY... | code_fim | hard | {
"lang": "rust",
"repo": "alecmocatta/palaver",
"path": "/src/file.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Loops `sendfile` till len elapsed or error
#[cfg(unix)]
pub fn copy_sendfile<O: AsRawFd, I: AsRawFd>(in_: &I, out: &O, len: u64) -> nix::Result<()> {
#[cfg(any(target_os = "android", target_os = "linux"))]
{
use nix::sys::sendfile;
let mut offset: u64 = 0;
while offset != len {
let n = send... | code_fim | hard | {
"lang": "rust",
"repo": "alecmocatta/palaver",
"path": "/src/file.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.1.write(buf).map(|written| {
self.0.write(&buf[..written]);
written
})
}
fn flush(&mut self) -> io::Result<()> {
self.1.flush()
}
}
let tmp =
fcntl::open("/tmp", OFlag::O_CLOEXEC, stat::Mode::empty()).expect("couldn't open /tmp");
let mut to_path = tmpfile(&"".into());
l... | code_fim | hard | {
"lang": "rust",
"repo": "alecmocatta/palaver",
"path": "/src/file.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl DefineSpriteTag {
pub fn read<R: Read>(reader: &mut R) -> Result<Self> {
let sprite_id = reader.read_u16()?;
let frame_count = reader.read_u16()?;
let control_tags = ControlTagList::read_to_end(reader)?;
Ok(Self {
sprite_id,
frame_count,
... | code_fim | medium | {
"lang": "rust",
"repo": "djcsdy/wildflower-codec",
"path": "/src/decode/tags/sprites/define_sprite.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djcsdy/wildflower-codec path: /src/decode/tags/sprites/define_sprite.rs
use crate::decode::read_ext::SwfTypesReadExt;
use crate::decode::tags::sprites::control_tag_list::ControlTagList;
use std::io::{Read, Result};
<|fim_suffix|>impl DefineSpriteTag {
pub fn read<R: Read>(reader: &mut R) ->... | code_fim | medium | {
"lang": "rust",
"repo": "djcsdy/wildflower-codec",
"path": "/src/decode/tags/sprites/define_sprite.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aljoscha/tokio path: /tokio/tests/rt_basic.rs
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
use tokio::runtime::Runtime;
use tokio::sync::oneshot;
use tokio_test::{assert_err, assert_ok};
use std::thread;
use std::time::Duration;
#[test]
fn spawned_task_does_not_progress_without_block_... | code_fim | hard | {
"lang": "rust",
"repo": "aljoscha/tokio",
"path": "/tokio/tests/rt_basic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use tokio::task;
struct OnDrop<F: FnMut()>(F);
impl<F: FnMut()> Drop for OnDrop<F> {
fn drop(&mut self) {
(self.0)()
}
}
let (tx1, rx1) = oneshot::channel();
let (tx2, rx2) = oneshot::channel();
let (tx3, rx3) = oneshot::channel();
let mut rt... | code_fim | hard | {
"lang": "rust",
"repo": "aljoscha/tokio",
"path": "/tokio/tests/rt_basic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> App::build()
.add_plugins(DefaultPlugins)
.add_plugin(InspectorPlugin::<Inspector>::new())
.run();
}<|fim_prefix|>// repo: TanTanDev/bevy-inspector-egui path: /examples/new_egui_window.rs
use bevy::prelude::*;
use bevy_inspector_egui::widgets::InNewWindow;
use bevy_inspector_e... | code_fim | medium | {
"lang": "rust",
"repo": "TanTanDev/bevy-inspector-egui",
"path": "/examples/new_egui_window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TanTanDev/bevy-inspector-egui path: /examples/new_egui_window.rs
use bevy::prelude::*;
use bevy_inspector_egui::widgets::InNewWindow;
use bevy_inspector_egui::{Inspectable, InspectorPlugin};
#[derive(Inspectable, Default)]
struct SomeComplexType {
very_long_field_name: Color,
}
<|fim_suffi... | code_fim | medium | {
"lang": "rust",
"repo": "TanTanDev/bevy-inspector-egui",
"path": "/examples/new_egui_window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> count
}
fn main() {
let args = env::args().collect::<Vec<String>>();
let input = fs::read_to_string(&args[1]).expect("Error: can't read input file.");
println!("--- Part 1 ---");
println!("# of molecules: {}", part_1(&input));
println!("--- Part 2 ---");
println!("# of steps... | code_fim | hard | {
"lang": "rust",
"repo": "cameronfyfe/aoc",
"path": "/2015/rust/19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cameronfyfe/aoc path: /2015/rust/19.rs
use std::{env, fs};
#[derive(Debug)]
struct Machine {
replacements: Vec<(String, String)>,
}
fn parse_puzzle_input(input: &str) -> (Machine, String) {
(
// Machine with replacements list
Machine {
replacements: input
... | code_fim | hard | {
"lang": "rust",
"repo": "cameronfyfe/aoc",
"path": "/2015/rust/19.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("--- Part 1 ---");
println!("# of molecules: {}", part_1(&input));
println!("--- Part 2 ---");
println!("# of steps: {}", part_2(&input));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn part_1_example() {
let puzzle_input = "H => HO
H => OH
O => HH
HOH"... | code_fim | hard | {
"lang": "rust",
"repo": "cameronfyfe/aoc",
"path": "/2015/rust/19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let contents = fs::read_to_string("inputs/day01.txt").expect("Something went wrong reading the file");
let nums: Vec<i32> = contents
.lines()
.map(|s| s.parse::<i32>().unwrap())
.collect();
if let Some((a, b, c)) = solve(&nums) {
println!("{} * {} *... | code_fim | hard | {
"lang": "rust",
"repo": "kolmodin/advent-of-code-2020",
"path": "/src/bin/day01.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kolmodin/advent-of-code-2020 path: /src/bin/day01.rs
use std::collections::HashSet;
use std::fs;
fn solve(nums: &[i32]) -> Option<(i32, i32, i32)> {
let hm: HashSet<i32> = nums.iter().cloned().collect();
for a in nums {
for b in nums {
let c = 2020 - a - b;
... | code_fim | hard | {
"lang": "rust",
"repo": "kolmodin/advent-of-code-2020",
"path": "/src/bin/day01.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some((a, b, c)) = solve(&nums) {
println!("{} * {} * {} = {}", a, b, c, a * b * c);
} else {
println!("could not find solution");
}
}<|fim_prefix|>// repo: kolmodin/advent-of-code-2020 path: /src/bin/day01.rs
use std::collections::HashSet;
use std::fs;
fn solve(nums: &... | code_fim | hard | {
"lang": "rust",
"repo": "kolmodin/advent-of-code-2020",
"path": "/src/bin/day01.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fraser999/Hash-Hasher path: /benches/lib.rs
#![warn(unused, missing_copy_implementations, missing_docs)]
#![deny(
deprecated_in_future,
future_incompatible,
macro_use_extern_crate,
rust_2018_idioms,
nonstandard_style,
single_use_lifetimes,
trivial_casts,
trivial_n... | code_fim | hard | {
"lang": "rust",
"repo": "Fraser999/Hash-Hasher",
"path": "/benches/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn insert_sip_hashes_into_set_using_default_hasher(bencher: &mut Bencher) {
utils::set_using_default_hasher::<SipDigest>(bencher)
}
#[bench]
fn insert_sip_hashes_into_set_using_hash_hasher(bencher: &mut Bencher) {
utils::set_using_hash_hasher::<SipDigest>(bencher)
}
#[bench]
fn insert_s... | code_fim | hard | {
"lang": "rust",
"repo": "Fraser999/Hash-Hasher",
"path": "/benches/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tashf33n/Passenger-Flight-Schedule-Using-Crates path: /src/passenger3.rs
pub mod passengermis {
pub fn passenger3flightname() {
println!("Flight name is PIA");
}
pub fn passenger3flighttime() {
<|fim_suffix|>tination() {
println!("Flight destination is Newyork");
... | code_fim | medium | {
"lang": "rust",
"repo": "tashf33n/Passenger-Flight-Schedule-Using-Crates",
"path": "/src/passenger3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>tination() {
println!("Flight destination is Newyork");
}
}<|fim_prefix|>// repo: tashf33n/Passenger-Flight-Schedule-Using-Crates path: /src/passenger3.rs
pub mod passengermis {
pub fn passenger3flightname() {
println!("Flight name is PIA");
}
pub fn passenger3flighttime()... | code_fim | medium | {
"lang": "rust",
"repo": "tashf33n/Passenger-Flight-Schedule-Using-Crates",
"path": "/src/passenger3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// A specified path was not valid UTF-8
#[error(transparent)]
PathNotUtf8(#[from] camino::FromPathBufError),
}<|fim_prefix|>// repo: lqc/rover path: /installers/binstall/src/error.rs
use thiserror::Error;
use std::io;
/// InstallerError is the type of Error that occurred while installing.
... | code_fim | hard | {
"lang": "rust",
"repo": "lqc/rover",
"path": "/installers/binstall/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lqc/rover path: /installers/binstall/src/error.rs
use thiserror::Error;
use std::io;
/// InstallerError is the type of Error that occurred while installing.
#[derive(Error, Debug)]
pub enum InstallerError {
/// Something went wrong with system I/O
#[error(transparent)]
IoError(#[fr... | code_fim | hard | {
"lang": "rust",
"repo": "lqc/rover",
"path": "/installers/binstall/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Something went wrong while adding the executable to zsh config
#[error("Zsh setup failed")]
ZshSetup,
/// A specified path was not valid UTF-8
#[error(transparent)]
PathNotUtf8(#[from] camino::FromPathBufError),
}<|fim_prefix|>// repo: lqc/rover path: /installers/binstall/src... | code_fim | hard | {
"lang": "rust",
"repo": "lqc/rover",
"path": "/installers/binstall/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.