text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: bluss/ease path: /examples/strings.rs
extern crate ease;
use ease::{Url, Request};
<|fim_suffix|> let url = Url::parse("http://httpbin.org/get").unwrap();
println!("{}", Request::new(url).param("foo", "bar").get().unwrap().body);
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "bluss/ease",
"path": "/examples/strings.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jhspetersson/fselect path: /src/expr.rs
use std::collections::HashSet;
use std::fmt;
use std::fmt::Display;
use std::fmt::Formatter;
use crate::field::Field;
use crate::function::Function;
use crate::operators::ArithmeticOp;
use crate::operators::LogicalOp;
use crate::operators::Op;
#[derive(D... | code_fim | hard | {
"lang": "rust",
"repo": "jhspetersson/fselect",
"path": "/src/expr.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> left
}
pub fn contains_colorized(&self) -> bool {
Self::contains_colorized_field(self)
}
fn contains_colorized_field(expr: &Expr) -> bool {
if expr.function.is_some() {
return false;
}
let field = match expr.field {
Some(re... | code_fim | hard | {
"lang": "rust",
"repo": "jhspetersson/fselect",
"path": "/src/expr.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let left = match expr.left {
Some(ref left) => Self::contains_numeric_field(&left),
None => false
};
left
}
pub fn contains_datetime(&self) -> bool {
Self::contains_datetime_field(self)
}
fn contains_datetime_field(expr: &Expr) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "jhspetersson/fselect",
"path": "/src/expr.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>scription(format!("[Clique aqui]({}) caso a imagem não apareça.", cat))
.image(cat)).await?;
})
);<|fim_prefix|>// repo: TheRuskyTeam/Rusky.old path: /src/commands/misc.rs
use serenity::builder::CreateEmbed;
use crate::{apis::MeowApi, slash};
pub struct CatCommand;
slas... | code_fim | hard | {
"lang": "rust",
"repo": "TheRuskyTeam/Rusky.old",
"path": "/src/commands/misc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheRuskyTeam/Rusky.old path: /src/commands/misc.rs
use serenity::builder::CreateEmbed;
use crate::{apis::MeowApi, slash};
pub struct CatCommand;
slash!(CatCommand =>
(@name: "<|fim_suffix|>scription(format!("[Clique aqui]({}) caso a imagem não apareça.", cat))
.... | code_fim | hard | {
"lang": "rust",
"repo": "TheRuskyTeam/Rusky.old",
"path": "/src/commands/misc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _session = sink.open_session().await.unwrap();
Ok(())
}<|fim_prefix|>// repo: ajunlonglive/ntex-amqp path: /examples/client.rs
use ntex_amqp::client;
#[ntex::main]
async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "ntex=trace,ntex_amqp=trace,basic=trace");
env_l... | code_fim | medium | {
"lang": "rust",
"repo": "ajunlonglive/ntex-amqp",
"path": "/examples/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajunlonglive/ntex-amqp path: /examples/client.rs
use ntex_amqp::client;
#[ntex::main]
async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "ntex=trace,ntex_amqp=trace,basic=trace");
env_logger::init();
let driver = client::Connector::new()
.connect("127.0.... | code_fim | easy | {
"lang": "rust",
"repo": "ajunlonglive/ntex-amqp",
"path": "/examples/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for tx in txs {
let mut rng = thread_rng();
let client: u16 = Uniform::new_inclusive(1, num_accounts)
.sample_iter(&mut rng)
.take(1)
.sum();
let tx_type: i32 = Uniform::new_inclusive(1, 5)
.sample... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/tx-sim",
"path": "/src/accounting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryanmtate/tx-sim path: /src/accounting.rs
use std::collections::HashMap;
use std::io::{self, Write};
use std::path::PathBuf;
use csv::{Reader, Writer};
use rand::distributions::{Distribution, Uniform};
use rand::thread_rng;
use crate::*;
#[derive(Debug, Default)]
pub struct Accounting {
a... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/tx-sim",
"path": "/src/accounting.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let txs: Vec<u32> = Uniform::new_inclusive(1, num_transactions)
.sample_iter(&mut rng)
.take(num_transactions as usize)
.collect();
for tx in txs {
let mut rng = thread_rng();
let client: u16 = Uniform::new_inclusive(1, num_accou... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/tx-sim",
"path": "/src/accounting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn func(req: Request, _: Context) -> Result<impl IntoResponse, Error> {
Ok(match req.body() {
Body::Text(text) => text.to_string().into_response(),
_ => Response::builder()
.status(400)
.body("unexpected request".into())
.expect("failed to rend... | code_fim | medium | {
"lang": "rust",
"repo": "anyakichi/lambda-rust-api-sample",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anyakichi/lambda-rust-api-sample path: /src/main.rs
use lambda_http::{handler, Body, IntoResponse, Request, Response};
use lambda_runtime::{Context, Error};
<|fim_suffix|>async fn func(req: Request, _: Context) -> Result<impl IntoResponse, Error> {
Ok(match req.body() {
Body::Text(t... | code_fim | medium | {
"lang": "rust",
"repo": "anyakichi/lambda-rust-api-sample",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns `true` if the event is a mouse interaction.
pub(crate) fn is_mouse(&self) -> bool {
matches!(
self.detail,
Detail::MouseMove { .. }
| Detail::MouseDown { .. }
| Detail::MouseUp { .. }
| Detail::RightMouseDo... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/earthquake-rust",
"path": "/libearthquake/src/platform/event.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csnover/earthquake-rust path: /libearthquake/src/platform/event.rs
//! Types for events received from the platform.
use super::WindowRecord;
use core::time::Duration;
use libmactoolbox::{
events::EventModifiers,
quickdraw::{Point, Rect},
};
/// A platform event.
#[derive(Debug)]
pub st... | code_fim | hard | {
"lang": "rust",
"repo": "csnover/earthquake-rust",
"path": "/libearthquake/src/platform/event.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>: StudyId },
JoinStudy { name: StudyName },
}<|fim_prefix|>// repo: sile/plumtuna path: /src/global/message.rs
use crate::study::{StudyId, StudyName};
#[deriv<|fim_middle|>e(Debug, Clone, Serialize, Deserialize)]
pub enum Message {
CreateStudy { name: StudyName, id | code_fim | medium | {
"lang": "rust",
"repo": "sile/plumtuna",
"path": "/src/global/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sile/plumtuna path: /src/global/message.rs
use crate::study::{StudyId, StudyName};
#[deriv<|fim_suffix|> Message {
CreateStudy { name: StudyName, id: StudyId },
JoinStudy { name: StudyName },
}<|fim_middle|>e(Debug, Clone, Serialize, Deserialize)]
pub enum | code_fim | easy | {
"lang": "rust",
"repo": "sile/plumtuna",
"path": "/src/global/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let txns = apps.iter()
.zip(&usages)
.map(|(a, u)| Transaction::new(a, None, Some(u), Some(&ts)))
.collect::<Vec<_>>();
let mut extensions = Extensions::new();
extensions.insert("no_body", "1");
extensions.insert("testing[=]", "0[=:... | code_fim | hard | {
"lang": "rust",
"repo": "peakmorgana/threescalers",
"path": "/examples/curl-easy-report.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("apicall: {:#?}", apicall);
println!("request: {:#?}", request);
let _ = run_request(request);
Ok(())
}
fn run_request(request: Request) -> Result<(), curl::Error> {
let mut client = Easy::new();
let _ = client.verbose(true).unwrap();
let curlclient = client.setup_r... | code_fim | hard | {
"lang": "rust",
"repo": "peakmorgana/threescalers",
"path": "/examples/curl-easy-report.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peakmorgana/threescalers path: /examples/curl-easy-report.rs
use threescalers::{
api_call::*,
application::*,
credentials::*,
extensions::Extensions,
http::{
request::{
curl::CurlEasyClient,
SetupRequest,
},
Request,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "peakmorgana/threescalers",
"path": "/examples/curl-easy-report.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32l5/src/stm32l552/sec_gtzc_mpcbb2/mpcbb2_vctr45.rs
8)) | (((value as u32) & 0x01) << 18);
self.w
}
}
#[doc = "Reader of field `B1459`"]
pub type B1459_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1459`"]
pub struct B1459_W<'a>... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/sec_gtzc_mpcbb2/mpcbb2_vctr45.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32l5/src/stm32l552/sec_gtzc_mpcbb2/mpcbb2_vctr45.rs
crate::R<bool, bool>;
#[doc = "Write proxy for field `B1455`"]
pub struct B1455_W<'a> {
w: &'a mut W,
}
impl<'a> B1455_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn s... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/sec_gtzc_mpcbb2/mpcbb2_vctr45.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.w.bits = (self.w.bits & !(0x01 << 18)) | (((value as u32) & 0x01) << 18);
self.w
}
}
#[doc = "Reader of field `B1459`"]
pub type B1459_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1459`"]
pub struct B1459_W<'a> {
w: &'a mut W,
}
impl<'a> B1459_W<'a> {
#[doc = r"Se... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32l5/src/stm32l552/sec_gtzc_mpcbb2/mpcbb2_vctr45.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MeyerFabian/advent-practice path: /06/src/main.rs
use std::fs::File;
use std::io::Read;
// In this area, there are sixteen memory banks; each memory bank can hold any number of blocks.
// The goal of the reallocation routine is to balance the blocks between the memory banks.
// The reallocatio... | code_fim | hard | {
"lang": "rust",
"repo": "MeyerFabian/advent-practice",
"path": "/06/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //cycle
cycle(&mut v_clone);
//routine to find if step was already employed
let mut found = true;
for (ind, row) in v_collection.iter().enumerate() {
let mut v_c_iter = v_clone.iter();
found = true;
for i in row {
... | code_fim | hard | {
"lang": "rust",
"repo": "MeyerFabian/advent-practice",
"path": "/06/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
D: Deserializer<'de>,
{
Option::<PackageVersion>::deserialize(deserializer).map(|v| v.map(|v| v.0))
}
impl PackageConfig {
/// The binary name.
#[allow(dead_code)]
pub fn binary_name(&self) -> Option<String> {
#[cfg(target_os = "linux")]
{
self.product_name.as_ref().map(|n| ... | code_fim | hard | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/core/tauri-utils/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tauri-apps/tauri path: /core/tauri-utils/src/config.rs
tems and `false` on Windows
// dotfiles are not supposed to be exposed by default on unix
#[serde(alias = "require-literal-leading-dot")]
require_literal_leading_dot: Option<bool>,
},
}
impl Default for FsScope {
fn default(... | code_fim | hard | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/core/tauri-utils/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tauri-apps/tauri path: /core/tauri-utils/src/config.rs
.
/// Required for code signing. SHA-256 is recommended.
#[serde(alias = "digest-algorithm")]
pub digest_algorithm: Option<String>,
/// Specifies the SHA1 hash of the signing certificate.
#[serde(alias = "certificate-thumbprint")]
... | code_fim | hard | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/core/tauri-utils/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let string = OsString::from("hello");
assert!(!string.is_empty());
assert_eq!(string.len(), 5);
assert_eq!(string.split_unicode().next(), Some(OsStrSection::Unicode("hello")));
assert_eq!(OsStr::new("\nHello World").split_whitespace().collect::<Vec<_>>(),
... | code_fim | hard | {
"lang": "rust",
"repo": "wthrowe/osstring_prototype",
"path": "/src/std_integration.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wthrowe/osstring_prototype path: /src/std_integration.rs
use std::prelude::v1::*;
use std::borrow::Borrow;
use std::ffi;
use std::mem;
use std::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher};
use os_str;
use slice_concat_ext::LocalSliceConcatExt;
macro_rules! make_conversions {
... | code_fim | hard | {
"lang": "rust",
"repo": "wthrowe/osstring_prototype",
"path": "/src/std_integration.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, StructOpt)]
pub struct List {}
impl List {
pub fn run(&self) -> Result<RoverOutput> {
Ok(RoverOutput::DocsList(
shortlinks::get_shortlinks_with_description(),
))
}
}<|fim_prefix|>// repo: lqc/rover path: /src/command/docs/list.rs
use crate::... | code_fim | medium | {
"lang": "rust",
"repo": "lqc/rover",
"path": "/src/command/docs/list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lqc/rover path: /src/command/docs/list.rs
use crate::{command::RoverOutput, Result};
use super::shortlinks;
<|fim_suffix|>impl List {
pub fn run(&self) -> Result<RoverOutput> {
Ok(RoverOutput::DocsList(
shortlinks::get_shortlinks_with_description(),
))
}
}<|... | code_fim | medium | {
"lang": "rust",
"repo": "lqc/rover",
"path": "/src/command/docs/list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl List {
pub fn run(&self) -> Result<RoverOutput> {
Ok(RoverOutput::DocsList(
shortlinks::get_shortlinks_with_description(),
))
}
}<|fim_prefix|>// repo: lqc/rover path: /src/command/docs/list.rs
use crate::{command::RoverOutput, Result};
use super::shortlinks;
us... | code_fim | easy | {
"lang": "rust",
"repo": "lqc/rover",
"path": "/src/command/docs/list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prudam/thanks path: /src/authors.rs
use models::{Author, NewAuthor};
use mailmap::Mailmap;
use diesel::*;
use diesel::pg::PgConnection;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use git2::Repository;
use std::path::Path;
use releases;
/... | code_fim | hard | {
"lang": "rust",
"repo": "prudam/thanks",
"path": "/src/authors.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This is more efficient than querying the DB for each author individually
for author in new_authors.into_iter() {
let (m_name, m_email) = self.mailmap.map(author.name, author.email);
match self.cache.get(&(m_name.clone(), m_email.clone())) {
Some(... | code_fim | hard | {
"lang": "rust",
"repo": "prudam/thanks",
"path": "/src/authors.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bugcai/-algorithm015 path: /Week_01/src/main.rs
mod climbing_stairs;
mod move_zeroes;
mod plus_one;
mod container_with_most_water;
mod swap_<|fim_suffix|>rectangle_in_histogram;
mod rotate_array;
mod two_sum;
mod trapping_rain_water;
fn main() {}<|fim_middle|>nodes_in_pairs;
mod merge_two_sorte... | code_fim | medium | {
"lang": "rust",
"repo": "bugcai/-algorithm015",
"path": "/Week_01/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>circular_deque;
mod remove_duplicates_from_sorted_array;
mod merge_sorted_array;
mod largest_rectangle_in_histogram;
mod rotate_array;
mod two_sum;
mod trapping_rain_water;
fn main() {}<|fim_prefix|>// repo: bugcai/-algorithm015 path: /Week_01/src/main.rs
mod climbing_stairs;
mod move_zeroes;
mod plus_o... | code_fim | medium | {
"lang": "rust",
"repo": "bugcai/-algorithm015",
"path": "/Week_01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rectangle_in_histogram;
mod rotate_array;
mod two_sum;
mod trapping_rain_water;
fn main() {}<|fim_prefix|>// repo: bugcai/-algorithm015 path: /Week_01/src/main.rs
mod climbing_stairs;
mod move_zeroes;
mod plus_one;
mod container_with_most_water;
mod swap_nodes_in_pairs;
mod merge_two_sorted_lists;
mod b... | code_fim | medium | {
"lang": "rust",
"repo": "bugcai/-algorithm015",
"path": "/Week_01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Dispatcher for WasccNativeDispatcher {
/// Called by a capability provider to invoke a function on an actor
fn dispatch(&self, actor: &str, op: &str, msg: &[u8]) -> Result<Vec<u8>, Box<dyn Error>> {
trace!(
"Dispatching operation '{}' ({} bytes) to actor",
op,
... | code_fim | hard | {
"lang": "rust",
"repo": "Atul9/wascc-host",
"path": "/src/dispatch.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Atul9/wascc-host path: /src/dispatch.rs
// Copyright 2015-2020 Capital One Services, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.or... | code_fim | hard | {
"lang": "rust",
"repo": "Atul9/wascc-host",
"path": "/src/dispatch.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Starting execution");
let elapsed = now.elapsed();
let sec = (elapsed.as_secs() as f64) + (elapsed.subsec_nanos() as f64 / 1_000_000_000.0);
println!("Seconds passed: {}", sec);
}<|fim_prefix|>// repo: Instillingererno/Rust path: /test2/src/main.rs
use std::thread;
use std::cmp... | code_fim | medium | {
"lang": "rust",
"repo": "Instillingererno/Rust",
"path": "/test2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::time::Instant;
let now = Instant::now();
println!("Starting execution");
let elapsed = now.elapsed();
let sec = (elapsed.as_secs() as f64) + (elapsed.subsec_nanos() as f64 / 1_000_000_000.0);
println!("Seconds passed: {}", sec);
}<|fim_prefix|>// repo: Instillingererno/R... | code_fim | easy | {
"lang": "rust",
"repo": "Instillingererno/Rust",
"path": "/test2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Instillingererno/Rust path: /test2/src/main.rs
use std::thread;
use std::cmp::min;
<|fim_suffix|>
fn main() {
use std::time::Instant;
let now = Instant::now();
println!("Starting execution");
let elapsed = now.elapsed();
let sec = (elapsed.as_secs() as f64) + (elapsed.sub... | code_fim | easy | {
"lang": "rust",
"repo": "Instillingererno/Rust",
"path": "/test2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpmech/gemlab path: /src/mesh/generators_tri.rs
use super::{Cell, Mesh, Point};
use crate::shapes::GeoKind;
use crate::StrError;
use russell_lab::math::PI;
use tritet::Triangle;
/// Groups generators of unstructured meshes (Tri and Tet only)
pub struct Unstructured {}
impl Unstructured {
/... | code_fim | hard | {
"lang": "rust",
"repo": "cpmech/gemlab",
"path": "/src/mesh/generators_tri.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#[cfg(test)]
mod tests {
use super::Unstructured;
#[allow(unused_imports)]
use crate::mesh::draw_mesh;
#[test]
fn tri_quarter_ring_2d_captures_errors() {
... | code_fim | hard | {
"lang": "rust",
"repo": "cpmech/gemlab",
"path": "/src/mesh/generators_tri.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Eq, PartialEq, Clone)]
pub struct Function<'a> {
labels: Option<Vec<Label<'a>>>,
body: Option<Box<Ast<'a>>>,
}
impl<'a> Function<'a> {
fn new(labels: Option<Vec<Label<'a>>>, body: Option<Box<Ast<'a>>>) -> Self {
Function { labels, body }
}
}
#[derive(Debug, Eq, Pa... | code_fim | hard | {
"lang": "rust",
"repo": "thejefflarson/goat",
"path": "/parser/src/ast/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thejefflarson/goat path: /parser/src/ast/mod.rs
pub mod renamer;
#[macro_use]
pub mod visitor;
pub mod folder;
pub use self::folder::Folder;
pub use self::renamer::Renamer;
pub use self::visitor::Visitor;
use crate::parser::*;
use pest::iterators::Pair;
use pest::prec_climber::{Assoc, Operator... | code_fim | hard | {
"lang": "rust",
"repo": "thejefflarson/goat",
"path": "/parser/src/ast/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match pair.as_rule() {
Rule::goat => {
let inner = pair.into_inner().next();
let node = match inner {
None => Ast::Empty,
Some(pair) => Ast::new(pair),
};
Ast::Program(Box::new(node))
}
Rule::string... | code_fim | hard | {
"lang": "rust",
"repo": "thejefflarson/goat",
"path": "/parser/src/ast/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>end(&mut buf) {
Ok(_) => disassembler::reader::start(buf),
Err(error) => {
panic!("{:?}", error)
}
};
}<|fim_prefix|>// repo: Bo0km4n/rust-disassembler-x86-8086 path: /src/main.rs
use std::io::Read;
use std::fs::File;
mod disassembler;
use std::env;
fn main() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Bo0km4n/rust-disassembler-x86-8086",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bo0km4n/rust-disassembler-x86-8086 path: /src/main.rs
use std::io::Read;
use std::fs::File;
mod disassembler;
use std::env;
fn main() {
let path = match env::current_dir() {
Ok(path) => format!("{}/example_c/a.out", path.display()),
Err(err) => panic!("{:?}", err)
};
... | code_fim | medium | {
"lang": "rust",
"repo": "Bo0km4n/rust-disassembler-x86-8086",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kawadakk/qrun-rs path: /src/main.rs
times
///
/// Alternatively, you can pass a log level by a `QRUN_LOG` environment
/// variable.
#[clap(short, long, parse(from_occurrences))]
verbose: usize,
#[clap(long, short, default_value = "aarch64-unknown-none")]
target: Str... | code_fim | hard | {
"lang": "rust",
"repo": "kawadakk/qrun-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> emu.mem_write(phdr.p_vaddr, bytes)
.map_err(fix_unicorn_err)
.with_context(|| format!("Could not load the segment from the compiled file"))?;
if (phdr.p_flags & goblin::elf::program_header::PF_X) != 0 {
printed.push((phdr, bytes));
... | code_fim | hard | {
"lang": "rust",
"repo": "kawadakk/qrun-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Symbolicate the location
if let Some(name) = sym_map.get(&va) {
println!("{}:", name);
}
// Print the instruction
let instr = u32::from_le_bytes([instr[0], instr[1], instr[2], instr[3]]);
... | code_fim | hard | {
"lang": "rust",
"repo": "kawadakk/qrun-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jcmorrow/hex path: /src/hex.rs
use std::ops::Add;
#[derive(Debug, Clone, Copy, Hash)]
pub struct Hex {
pub q: i64,
pub r: i64,
pub s: i64,
}
<|fim_suffix|>#[derive(Debug, Clone, Copy)]
pub struct FractionalHex {
pub q: f64,
pub r: f64,
pub s: f64,
}
impl Hex {
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "jcmorrow/hex",
"path": "/src/hex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Hex {
q: self.q + other.q,
r: self.r + other.r,
s: self.s + other.s,
}
}
}
const HEX_DIRECTIONS: [Hex; 6] = [
Hex { q: 1, r: 0, s: -1 },
Hex { q: 0, r: 1, s: -1 },
Hex { q: -1, r: 1, s: 0 },
Hex { q: -1, r: 0, s: 1 },
Hex { q: 0,... | code_fim | medium | {
"lang": "rust",
"repo": "jcmorrow/hex",
"path": "/src/hex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
maze.corner_walls((matrix_pos(1, 1), &walls::DOWN))
.collect::<Vec<_>>(),
vec![
(matrix_pos(1, 1), &walls::DOWN),
(matrix_pos(1, 2), &walls::RIGHT),
(matrix_pos(2, 2), &walls::UP),
(... | code_fim | hard | {
"lang": "rust",
"repo": "moses-palmer/labyru",
"path": "/maze/src/shape/quad.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moses-palmer/labyru path: /maze/src/shape/quad.rs
use crate::matrix;
use crate::physical;
use crate::wall;
use crate::wall::{Angle, Offset};
use crate::WallPos;
use super::{COS_45, SIN_45};
/// A span step angle
///
/// This is half the angle span used by a single wall.
const D: f32 = 2.0 * s... | code_fim | hard | {
"lang": "rust",
"repo": "moses-palmer/labyru",
"path": "/maze/src/shape/quad.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if result == 0 {
eprintln!("set console mode error for echo input disable");
return Err(Error::last_os_error());
}
print!("\x1b[?1049h");
Ok(ConsoleEnabledToken)
}
pub fn restore_console() {
// todo: restore console modes.
println!("\x1b[?1049l");
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "chyyran/conmux",
"path": "/src/wincon.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chyyran/conmux path: /src/wincon.rs
use winapi::shared::minwindef::DWORD;
use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode};
use winapi::um::processenv::GetStdHandle;
use winapi::um::winbase::{STD_INPUT_HANDLE, STD_OUTPUT_HANDLE};
use winapi::um::wincon::*;
use std::io::{Error, Resul... | code_fim | hard | {
"lang": "rust",
"repo": "chyyran/conmux",
"path": "/src/wincon.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = unsafe { GetConsoleMode(console_out_handle, &mut console_out_mode) };
if result == 0 {
eprintln!("get console mode error");
return Err(Error::last_os_error());
}
let result = unsafe {
SetConsoleMode(
console_out_handle,
console... | code_fim | medium | {
"lang": "rust",
"repo": "chyyran/conmux",
"path": "/src/wincon.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file = File::create(pprof_path).unwrap();
let profile = report.pprof().unwrap();
let mut content = Vec::new();
profile.encode(&mut content).unwrap();
file.write_all(&content).unwrap();
report
.flamegraph_with_... | code_fim | hard | {
"lang": "rust",
"repo": "qdrant/qdrant",
"path": "/lib/collection/benches/prof.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qdrant/qdrant path: /lib/collection/benches/prof.rs
use std::fs::File;
use std::io::Write;
use std::os::raw::c_int;
use std::path::Path;
use criterion::profiler::Profiler;
use pprof::flamegraph::TextTruncateDirection;
use pprof::protos::Message;
use pprof::ProfilerGuard;
/// Small custom profi... | code_fim | hard | {
"lang": "rust",
"repo": "qdrant/qdrant",
"path": "/lib/collection/benches/prof.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nakagami/awabi path: /src/lib.rs
/*
*MIT License
*
*Copyright (c) 2020 Hajime Nakagami
*
*Permission is hereby granted, free of charge, to any person obtaining a copy
*of this software and associated documentation files (the "Software"), to deal
*in the Software without restriction, including wi... | code_fim | hard | {
"lang": "rust",
"repo": "nakagami/awabi",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>RS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*SOFTWARE.
*/
mod dic;
mod lattice;
mod mecabrc;
pub mod tokenizer;
#[cfg(test)]
mod tests;<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "nakagami/awabi",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tup: (i32, f64, u8) = (500, 6.4, 1);
let (_x, y, _z) = tup;
println!("The value of y is: {}", y);
}<|fim_prefix|>// repo: aempisse/rust_lang path: /variables/src/main.rs
fn main() {
let shadowed = 5;
let shadowed = shadowed + 1;
let shadowed = shadowed * 2;
<|fim_middle|> ... | code_fim | medium | {
"lang": "rust",
"repo": "aempisse/rust_lang",
"path": "/variables/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aempisse/rust_lang path: /variables/src/main.rs
fn main() {
let shadowed = 5;
let shadowed = shadowed + 1;
let shadowed = shadowed * 2;
println!("The value of shadowed is: {}", shadowed);
let spaces = " ";
let spaces = spaces.len();
<|fim_suffix|> let (_x, y, _z) ... | code_fim | medium | {
"lang": "rust",
"repo": "aempisse/rust_lang",
"path": "/variables/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: martinrlilja/borealis path: /borealis/src/serializer/document.rs
use std::io::Write;
use super::serializer::Serializer;
use super::NodeSerializer;
use super::node::new_node_ser;
pub struct DocumentSerializer<'a, 'b: 'a, 'w: 'b, W: 'w + Write> {
serializer: &'a mut Serializer<'b, 'w, W>,
... | code_fim | hard | {
"lang": "rust",
"repo": "martinrlilja/borealis",
"path": "/borealis/src/serializer/document.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, 'b, 'w, W: Write> DocumentDoctypeSerializer<'a, 'b, 'w, W> {
pub fn node(self) -> NodeSerializer<'a, 'b, 'w, W> {
self.internal.node()
}
}
pub fn new_doc_ser<'a, 'b, 'w, W: Write>(ser: &'a mut Serializer<'b, 'w, W>)
-> DocumentSerializer<'... | code_fim | hard | {
"lang": "rust",
"repo": "martinrlilja/borealis",
"path": "/borealis/src/serializer/document.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: charles-wangkai/exercism path: /rust/role-playing-game/src/lib.rs
use std::cmp;
pub struct Player {
pub health: u32,
pub mana: Option<u32>,
pub level: u32,
}
impl Player {
pub fn revive(&self) -> Option<Player> {
if self.health == 0 {
Some(Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "charles-wangkai/exercism",
"path": "/rust/role-playing-game/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0
}
Some(mana) => {
if *mana < mana_cost {
0
} else {
*mana -= mana_cost;
mana_cost * 2
}
}
}
}
}<|fim_prefix|>// repo: charles-wangk... | code_fim | hard | {
"lang": "rust",
"repo": "charles-wangkai/exercism",
"path": "/rust/role-playing-game/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: southpawgeek/perlweeklychallenge-club path: /challenge-110/roger-bell-west/rust/ch-1.rs
use std::io;
use std::io::prelude::*;
use regex::Regex;
<|fim_suffix|> let vp=Regex::new(r"^ *(\+[0-9]{2}|\([0-9]{2}\)|[0-9]{4}) [0-9]{10} *$").unwrap();
let stdin = io::stdin();
for line in stdin... | code_fim | easy | {
"lang": "rust",
"repo": "southpawgeek/perlweeklychallenge-club",
"path": "/challenge-110/roger-bell-west/rust/ch-1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vp=Regex::new(r"^ *(\+[0-9]{2}|\([0-9]{2}\)|[0-9]{4}) [0-9]{10} *$").unwrap();
let stdin = io::stdin();
for line in stdin.lock().lines() {
let ll=line.unwrap();
if vp.is_match(&ll) {
println!("{}",ll);
}
}
}<|fim_prefix|>// repo: southpawgeek/perlwee... | code_fim | easy | {
"lang": "rust",
"repo": "southpawgeek/perlweeklychallenge-club",
"path": "/challenge-110/roger-bell-west/rust/ch-1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mipli/baduk-rs path: /src/lib.rs
mod error;
mod state;
mod position;
mod game;
pub use crate::game::GameTree;
pub use crate::error::{BadukError, BadukErrorKind};
pub <|fim_suffix|>se crate::position::Position;
pub use sgf_parser::{Color, SgfToken};<|fim_middle|>use crate::state::{GameState, Gam... | code_fim | medium | {
"lang": "rust",
"repo": "mipli/baduk-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>se crate::position::Position;
pub use sgf_parser::{Color, SgfToken};<|fim_prefix|>// repo: mipli/baduk-rs path: /src/lib.rs
mod error;
mod state;
mod position;
mod game;
pub use crate::game:<|fim_middle|>:GameTree;
pub use crate::error::{BadukError, BadukErrorKind};
pub use crate::state::{GameState, Gam... | code_fim | medium | {
"lang": "rust",
"repo": "mipli/baduk-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn jpeg_in_quality_range_upper_bound_inside() {
let value: &str = "100";
assert!(validate_jpeg_quality(u8::from_str(value).unwrap()).is_ok())
}
#[test]
fn jpeg_in_quality_range_upper_bound_outside() {
let value: &str = "101";
assert!(validate_jp... | code_fim | hard | {
"lang": "rust",
"repo": "foresterre/sic-automate",
"path": "/src/app/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foresterre/sic-automate path: /src/app/config.rs
use anyhow::bail;
use sic_image_engine::engine::Instr;
use sic_io::load::FrameIndex;
#[derive(Debug)]
pub struct Config<'a> {
pub tool_name: &'static str,
// organisational
/// Display license of this software or its dependencies.
... | code_fim | hard | {
"lang": "rust",
"repo": "foresterre/sic-automate",
"path": "/src/app/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xcaff/dht-crawler path: /packages/krpc_encoding/src/messages.rs
use crate::{
booleans,
errors::{
ErrorKind,
Result,
},
node_info,
Addr,
NodeID,
NodeInfo,
};
use serde_bencode;
use serde_bytes::{
self,
ByteBuf,
};
use serde_derive::{
Deseri... | code_fim | hard | {
"lang": "rust",
"repo": "0xcaff/dht-crawler",
"path": "/packages/krpc_encoding/src/messages.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(f, "{:?}", self)
}
}
/// Possible queries
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(tag = "q", content = "a")]
pub enum Query {
/// Most basic query
///
/// The appropriate response to a ping is [`Response::OnlyID`] with the node
/// ID of the resp... | code_fim | hard | {
"lang": "rust",
"repo": "0xcaff/dht-crawler",
"path": "/packages/krpc_encoding/src/messages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magurofly/cargo-compete path: /src/commands/test.rs
use crate::{
config::CargoCompeteConfigTestProfile,
project::{MetadataExt as _, PackageExt as _},
shell::ColorChoice,
};
use human_size::Size;
use std::path::PathBuf;
use structopt::StructOpt;
use strum::VariantNames as _;
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "magurofly/cargo-compete",
"path": "/src/commands/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[structopt(required_unless("src"))]
/// Name or alias for a `bin`/`example`
pub name_or_alias: Option<String>,
}
pub(crate) fn run(opt: OptCompeteTest, ctx: crate::Context<'_>) -> anyhow::Result<()> {
let OptCompeteTest {
src,
testcases,
display_limit,
pac... | code_fim | hard | {
"lang": "rust",
"repo": "magurofly/cargo-compete",
"path": "/src/commands/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_css_lints/src/rules/color_no_invalid_hex.rs
use swc_css_ast::*;
use swc_css_visit::{Visit, VisitWith};
use crate::rule::{visitor_rule, LintRule, LintRuleContext};
<|fim_suffix|>#[derive(Debug, Default)]
struct ColorNoInvalidHex {
ctx: LintRuleContext<()>,
... | code_fim | medium | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_css_lints/src/rules/color_no_invalid_hex.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let HexColor { value, .. } = hex_color;
let length = value.len();
if (length == 3 || length == 4 || length == 6 || length == 8)
&& value.chars().all(|c| c.is_ascii_hexdigit())
{
hex_color.visit_children_with(self);
return;
}
... | code_fim | medium | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_css_lints/src/rules/color_no_invalid_hex.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Visit for ColorNoInvalidHex {
fn visit_hex_color(&mut self, hex_color: &HexColor) {
let HexColor { value, .. } = hex_color;
let length = value.len();
if (length == 3 || length == 4 || length == 6 || length == 8)
&& value.chars().all(|c| c.is_ascii_hexdigit())
... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_css_lints/src/rules/color_no_invalid_hex.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if parts.is_empty() {
parts.push(n.to_string());
}
parts.join("")
}<|fim_prefix|>// repo: LukeCarrier/exercism-solutions path: /rust/raindrops/src/lib.rs
pub fn raindrops(n: u32) -> String {
let mut parts = Vec::<String>::with_capacity(3);
<|fim_middle|> if n % 3 == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "LukeCarrier/exercism-solutions",
"path": "/rust/raindrops/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LukeCarrier/exercism-solutions path: /rust/raindrops/src/lib.rs
pub fn raindrops(n: u32) -> String {
let mut parts = Vec::<String>::with_capacity(3);
<|fim_suffix|> if parts.is_empty() {
parts.push(n.to_string());
}
parts.join("")
}<|fim_middle|> if n % 3 == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "LukeCarrier/exercism-solutions",
"path": "/rust/raindrops/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'input> Lexer<'input> {
pub fn consume_whitespace(&mut self) -> Option<()> {
loop {
if self.buf.chars().next()?.is_whitespace() {
self.pos += 1;
self.buf = &self.buf[1..]
} else {
break Some(());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Trolldemorted/isla",
"path": "/isla-lib/src/lexer.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Trolldemorted/isla path: /isla-lib/src/lexer.rs
// BSD 2-Clause License
//
// Copyright (c) 2020 Alasdair Armstrong
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met... | code_fim | hard | {
"lang": "rust",
"repo": "Trolldemorted/isla",
"path": "/isla-lib/src/lexer.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//fn hor_mirror(s: String) -> String {
// s.split('\n').rev().collect::<Vec<&str>>().join("\n")
//}
//fn vert_mirror(s: String) -> String {
// s.split('\n').map(|s| s.chars().rev().collect::<String>()).collect::<Vec<String>>().join("\n")
//}
//fn oper(oper: fn(String) -> String, s: String) -> Strin... | code_fim | medium | {
"lang": "rust",
"repo": "luckyuro/rsKata",
"path": "/src/katas/move_squared_strings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luckyuro/rsKata path: /src/katas/move_squared_strings.rs
//7kyu
//kata_URL:
// https://www.codewars.com/kata/56dbe0e313c2f63be4000b25/train/rust
pub fn vert_mirror(s: String) -> String {
let d: Vec<&str> = s.split('\n').collect();
let nd: Vec<String> = d
.into_iter()
... | code_fim | medium | {
"lang": "rust",
"repo": "luckyuro/rsKata",
"path": "/src/katas/move_squared_strings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yanshoutong/dump_alicsv_iplist path: /src/config.rs
#[derive(Debug)]
pub struct Config {
pub filename: String,
pub prefix: String,
pub column: u8,
}
impl Config {
pub fn new(filename: &str, prefix: &str, c<|fim_suffix|> prefix: String::from(prefix),
column:... | code_fim | medium | {
"lang": "rust",
"repo": "yanshoutong/dump_alicsv_iplist",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>olumn: u8) -> Self {
Config {
filename: String::from(filename),
prefix: String::from(prefix),
column: column,
}
}
}<|fim_prefix|>// repo: yanshoutong/dump_alicsv_iplist path: /src/config.rs
#[derive(Debug)]
pub struct Config {
pub filename: Stri... | code_fim | medium | {
"lang": "rust",
"repo": "yanshoutong/dump_alicsv_iplist",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gil0mendes/advent-of-code path: /2018/day2/part_2/src/main.rs
const PUZZLE: &str = include_str!("input.txt");
fn main() {
let boxes = PUZZLE.lines().collect::<Vec<&str>>();
let mut common_chars = String::new();
<|fim_suffix|> // Join the two iterators into one to make
... | code_fim | hard | {
"lang": "rust",
"repo": "gil0mendes/advent-of-code",
"path": "/2018/day2/part_2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if num_differences == 1 {
break 'iter1;
}
}
}
print!("Common id: {}", common_chars);
}<|fim_prefix|>// repo: gil0mendes/advent-of-code path: /2018/day2/part_2/src/main.rs
const PUZZLE: &str = include_str!("input.txt");
fn main() {
let boxes = ... | code_fim | hard | {
"lang": "rust",
"repo": "gil0mendes/advent-of-code",
"path": "/2018/day2/part_2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_intcodes(mut ic: std::vec::Vec<i32>) -> std::vec::Vec<i32> {
let mut pointer = 0;
loop{
if ic[pointer] == 99 {
return ic;
} else if ic[pointer] == 1 {
let arg1 = ic[pointer+1] as usize;
let arg2 = ic[pointer+2] as usize;
let an... | code_fim | hard | {
"lang": "rust",
"repo": "Juuiko/advent-of-code",
"path": "/day2/puzzle2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Juuiko/advent-of-code path: /day2/puzzle2.rs
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn main() {
for i in 0..100{
for j in 0..100{
if let Ok(lines) = read_lines("./rust_input.txt") {
for line in lines {
if... | code_fim | hard | {
"lang": "rust",
"repo": "Juuiko/advent-of-code",
"path": "/day2/puzzle2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ulysseB/telamon path: /telamon-gen/src/flat_filter.rs
//! Filter generation.
use crate::ir::{self, Adaptable};
use fxhash::FxHashMap;
use utils::*;
/// Merge flat filters that can be merged in the given list.
pub fn merge(mut filters: Vec<FlatFilter>, ir_desc: &ir::IrDesc) -> Vec<FlatFilter> {
... | code_fim | hard | {
"lang": "rust",
"repo": "ulysseB/telamon",
"path": "/telamon-gen/src/flat_filter.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Inverse a filter on a symmetric or anti-symmetric relation.
pub fn inverse(&self, antisymmetric: bool, ir_desc: &ir::IrDesc) -> Self {
let mut adaptator = ir::Adaptator::default();
adaptator.set_variable(ir::Variable::Arg(0), ir::Variable::Arg(1));
adaptator.set_variabl... | code_fim | hard | {
"lang": "rust",
"repo": "ulysseB/telamon",
"path": "/telamon-gen/src/flat_filter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Try to merge another filter into `Self`.
fn try_merge(&mut self, other: &FlatFilter, ir_desc: &ir::IrDesc) -> bool {
if self.inputs.is_empty() != other.inputs.is_empty() {
return false;
}
if self.set_constraints != other.set_constraints {
return ... | code_fim | hard | {
"lang": "rust",
"repo": "ulysseB/telamon",
"path": "/telamon-gen/src/flat_filter.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
println!("two girls in the class");
}
}
}<|fim_prefix|>// repo: mfarzamalam/Rust path: /class13/stu/src/lib.rs
pub fn class() {
pub fn student() {
pub fn boys() {
<|fim_middle|> println!("four boys in the class");
}
}
}
pub mod anotherclass {
... | code_fim | medium | {
"lang": "rust",
"repo": "mfarzamalam/Rust",
"path": "/class13/stu/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfarzamalam/Rust path: /class13/stu/src/lib.rs
pub fn class() {
pub fn student() {
pub fn boys() {
println!("four boys in the class");
}
}
}
p<|fim_suffix|>
println!("two girls in the class");
}
}
}<|fim_middle|>ub mod anotherclass {
... | code_fim | medium | {
"lang": "rust",
"repo": "mfarzamalam/Rust",
"path": "/class13/stu/src/lib.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.