text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let res = client.request(req).await;
match res {
Ok(res) => {
println!("Response: {:?}", res)
}
Err(err) => {
println!("Error: {}", err)
}
}
}
/// This function demonstrates how you can send a presigned request using [reqwest](https://c... | code_fim | hard | {
"lang": "rust",
"repo": "awsdocs/aws-doc-sdk-examples",
"path": "/rust_dev_preview/examples/sending-presigned-requests/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CrueLu/ibc-rs path: /relayer-cli/src/config.rs
//! Cli Config
//!
//! See instructions in `commands.rs` to specify the path to your
//! application's configuration file and/or command-line options
//! for specifying it.
use std::path::PathBuf;
use abscissa_core::{error::BoxError, EntryPoint, O... | code_fim | medium | {
"lang": "rust",
"repo": "CrueLu/ibc-rs",
"path": "/relayer-cli/src/config.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>use abscissa_core::{error::BoxError, EntryPoint, Options};
use crate::commands::CliCmd;
pub use ibc_relayer::config::Config;
/// Get the path to configuration file
pub fn config_path() -> Result<PathBuf, BoxError> {
let mut args = std::env::args();
assert!(args.next().is_some(), "expected one a... | code_fim | medium | {
"lang": "rust",
"repo": "CrueLu/ibc-rs",
"path": "/relayer-cli/src/config.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: irh/freeverb-rs path: /src/clib/src/lib.rs
pub use freeverb::Freeverb;
/// Create a Freeverb instance with a given sample rate
///
/// The client is responsible for freeing the instance's memory when it's no longer required,
/// see `destroy()`.
#[no_mangle]
pub extern "C" fn create(sample_rate... | code_fim | hard | {
"lang": "rust",
"repo": "irh/freeverb-rs",
"path": "/src/clib/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern "C" fn set_dry(freeverb: &mut Freeverb, value: f64) {
freeverb.set_dry(value)
}
#[no_mangle]
pub extern "C" fn set_room_size(freeverb: &mut Freeverb, value: f64) {
freeverb.set_room_size(value)
}<|fim_prefix|>// repo: irh/freeverb-rs path: /src/clib/src/lib.rs
pub use fre... | code_fim | hard | {
"lang": "rust",
"repo": "irh/freeverb-rs",
"path": "/src/clib/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern "C" fn set_wet(freeverb: &mut Freeverb, value: f64) {
freeverb.set_wet(value)
}
#[no_mangle]
pub extern "C" fn set_width(freeverb: &mut Freeverb, value: f64) {
freeverb.set_width(value)
}
#[no_mangle]
pub extern "C" fn set_dry(freeverb: &mut Freeverb, value: f64) {
fr... | code_fim | hard | {
"lang": "rust",
"repo": "irh/freeverb-rs",
"path": "/src/clib/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.callback_calls += 1;
}
fn on_pattern_playback_end(&mut self, _pattern: &Pattern) {
self.callback_calls += 1;
}
fn on_completed(&mut self, composition: &Composition) {
self.callback_calls += 1;
assert_eq!(composition.get_n... | code_fim | hard | {
"lang": "rust",
"repo": "soundust/chord-composer-interface",
"path": "/tests/test_interface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: soundust/chord-composer-interface path: /tests/test_interface.rs
extern crate chord_composer;
#[test]
fn chord_to_string_array() {
let chords = chord_composer::get_chord_keywords();
assert_eq!(chords.len(), 73);
assert_eq!(chords[0], "AUGMENTED = [0, 4, 8]");
}
#[test]
fn export_mi... | code_fim | hard | {
"lang": "rust",
"repo": "soundust/chord-composer-interface",
"path": "/tests/test_interface.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.callback_calls += 1;
}
fn on_event(&mut self, event: &PatternEvent) {
self.callback_calls += 1;
let (event_time, event_notes) = event;
assert_eq!(event_time, &MusicTime::default());
assert_eq!(event_notes, &vec![60]);
... | code_fim | hard | {
"lang": "rust",
"repo": "soundust/chord-composer-interface",
"path": "/tests/test_interface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: acmumn/snackcoin path: /crates/tarhandler/src/lib.rs
//! An Iron handler that serves out of a tar file.
extern crate futures;
extern crate iron;
extern crate mime_guess;
extern crate tar;
mod fs;
use std::fs::File;
use std::io::{Cursor, Error, ErrorKind, Read, Result};
use std::path::{Compone... | code_fim | hard | {
"lang": "rust",
"repo": "acmumn/snackcoin",
"path": "/crates/tarhandler/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Handler for TarHandler {
fn handle(&self, req: &mut Request) -> IronResult<Response> {
let root = self.root.read().unwrap();
let path = req.url.path();
if let Some(file) = root.get_file(&path) {
let mime = path.last()
.map(|f| -> &Path { f.as_re... | code_fim | hard | {
"lang": "rust",
"repo": "acmumn/snackcoin",
"path": "/crates/tarhandler/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mdcg/a-tour-of-rust path: /4-tipos-genericos/2-representando-o-nada.rs
// Em outras linguagens, a palavra-chave null é usada para representar a ausência
// de um valor. Isso cria dificuldades nas linguagens de programação, porque o nosso
// programa possa falhar ao interagir com uma variável/cam... | code_fim | hard | {
"lang": "rust",
"repo": "mdcg/a-tour-of-rust",
"path": "/4-tipos-genericos/2-representando-o-nada.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Esse padrão para fornecer uma representação alternativa ao None
// por um ou vários valores alternados é muito comum em Rust devido a
// falta de um valor null. Tipos genéricos ajudam a resolver esse desafio
enum Item {
Inventario(String),
// None representa a ausência de um item
None,
}
... | code_fim | medium | {
"lang": "rust",
"repo": "mdcg/a-tour-of-rust",
"path": "/4-tipos-genericos/2-representando-o-nada.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tirust/msp432e4 path: /src/can0/if2crq.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::IF2CRQ {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "tirust/msp432e4",
"path": "/src/can0/if2crq.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bits 0:5 - Message Number"]
#[inline(always)]
pub fn can_if2crq_mnum(&self) -> CAN_IF2CRQ_MNUMR {
let bits = ((self.bits >> 0) & 63) as u8;
CAN_IF2CRQ_MNUMR { bits }
}
#[doc = "Bit 15 - Busy Flag"]
#[... | code_fim | hard | {
"lang": "rust",
"repo": "tirust/msp432e4",
"path": "/src/can0/if2crq.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KeatonTech/epoxy_rs path: /epoxy_streams/src/streams.rs
use std::any::Any;
use std::collections::BTreeMap;
use std::sync::{Arc, Mutex};
pub(crate) struct StreamImpl<T> {
highest_id: u16,
is_alive: bool,
on_emit: BTreeMap<u16, Box<dyn Fn(Arc<T>) + Send + Sync>>,
pub(crate) extra_... | code_fim | hard | {
"lang": "rust",
"repo": "KeatonTech/epoxy_rs",
"path": "/epoxy_streams/src/streams.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn read_extra_fields<ExtraFieldsType, RetType, FnType>(&self, cb: FnType) -> RetType
where
ExtraFieldsType: 'static,
ExtraFieldsType: Send,
ExtraFieldsType: Sync,
RetType: 'static,
FnType: FnOnce(&ExtraFieldsType) -> RetType,
{
match s... | code_fim | hard | {
"lang": "rust",
"repo": "KeatonTech/epoxy_rs",
"path": "/epoxy_streams/src/streams.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Stream {
pointer: Arc::clone(&self.pointer),
}
}
}
impl<T> StreamImpl<T> {
fn subscribe<F>(&mut self, listener: F) -> u16
where
F: Fn(Arc<T>),
F: Send,
F: Sync,
F: 'static,
{
let new_subscription_id = self.highest_id;
... | code_fim | hard | {
"lang": "rust",
"repo": "KeatonTech/epoxy_rs",
"path": "/epoxy_streams/src/streams.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
"this is a sentence",
Solution::reorder_spaces(" this is a sentence ".to_string())
);
assert_eq!(
"practice makes perfect ",
Solution::reorder_spaces(" practice makes perfect".to_string())
);
assert_eq!(
"hello wor... | code_fim | medium | {
"lang": "rust",
"repo": "linshaoyong/leetcode",
"path": "/rust/src/easy/e1592_rearrange_spaces_between_words.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linshaoyong/leetcode path: /rust/src/easy/e1592_rearrange_spaces_between_words.rs
struct Solution;
impl Solution {
pub fn reorder_spaces(text: String) -> String {
let mut spaces = 0;
let mut words: Vec<String> = vec![];
let mut word: Vec<char> = vec![];
for c... | code_fim | hard | {
"lang": "rust",
"repo": "linshaoyong/leetcode",
"path": "/rust/src/easy/e1592_rearrange_spaces_between_words.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_reorder_spaces() {
assert_eq!(
"this is a sentence",
Solution::reorder_spaces(" this is a sentence ".to_string())
);
assert_eq!(
"practice makes perfect ",
Solution::reorder_spaces(" practice makes perfect".to_string())
);
... | code_fim | hard | {
"lang": "rust",
"repo": "linshaoyong/leetcode",
"path": "/rust/src/easy/e1592_rearrange_spaces_between_words.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: codec-abc/kas path: /src/class.rs
// 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 in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
/... | code_fim | hard | {
"lang": "rust",
"repo": "codec-abc/kas",
"path": "/src/class.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
Self: Sized,
{
self.set_rich_text(text.into())
}
/// Set rich text
fn set_rich_text(&mut self, text: kas::text::RichText) -> TkAction;
}
/// Set a control label
///
/// Control labels do not support rich-text formatting but do support
/// accelerator keys, ident... | code_fim | hard | {
"lang": "rust",
"repo": "codec-abc/kas",
"path": "/src/class.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcellodash/popcap_framework-rs path: /src/pak/interface.rs
use crate::pak::file::{
File,
FileHandle,
};
use popcap_framework_sys as ffi;
use std::{
convert::TryInto,
ffi::{
CStr,
CString,
},
mem::MaybeUninit,
};
pub struct PakInterface(pub(crate) *mut f... | code_fim | hard | {
"lang": "rust",
"repo": "marcellodash/popcap_framework-rs",
"path": "/src/pak/interface.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::fmt::Debug for FileData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FileData")
.field("filename", &self.filename())
.field("alternate_filename", &self.alternate_filename())
.field("file_size", &self.file_s... | code_fim | hard | {
"lang": "rust",
"repo": "marcellodash/popcap_framework-rs",
"path": "/src/pak/interface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FileSearch {
pub fn new(h: ffi::HANDLE) -> Self {
assert!(!h.is_null());
Self(h)
}
}
pub struct FileSearchIter<'a> {
search: FileSearch,
data: Option<FileData>,
interface: &'a mut PakInterface,
}
impl<'a> FileSearchIter<'a> {
pub(crate) fn new(interface: &'a ... | code_fim | hard | {
"lang": "rust",
"repo": "marcellodash/popcap_framework-rs",
"path": "/src/pak/interface.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expr = ctx.append_expression(expr, span);
Ok(expr)
}
fn constructor<'out>(
&mut self,
constructor: &ast::ConstructorType<'source>,
mut ctx: ExpressionCon... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/naga/src/front/wgsl/lower/construction.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/naga/src/front/wgsl/lower/construction.rs
dule: &'a crate::Module) -> ConcreteConstructor<'a> {
match *self {
Self::PartialVector { size } => ConcreteConstructor::PartialVector { size },
Self::PartialMatri... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/naga/src/front/wgsl/lower/construction.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> match opcode {
"nop" => index = index + 1,
"acc" => {
index = index + 1;
accumulator = accumulator + operand;
}
"jmp" => index = index + operand,
_ => panic!("Invalid opcode.... | code_fim | hard | {
"lang": "rust",
"repo": "mllanos/advent-of-code-2020",
"path": "/src/day_8/handheld_halting_part_2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mllanos/advent-of-code-2020 path: /src/day_8/handheld_halting_part_2.rs
use std::fs;
use std::str;
#[test]
fn validate_8_2() {
assert_eq!(algorithm("src/day_8/input_test.txt"), 8);
}
fn algorithm(file_location: &str) -> i32 {
let content = fs::read_to_string(file_location).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "mllanos/advent-of-code-2020",
"path": "/src/day_8/handheld_halting_part_2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn path(&self) -> &str {
self.url.path()
}
pub fn href(&self) -> Cow<str> {
let stripped = self
.url
.as_str()
.strip_prefix(BASE_SITE_URL.as_str())
.unwrap();
if stripped.starts_with('#') {
Cow::Borrowed(... | code_fim | hard | {
"lang": "rust",
"repo": "treeman/jonashietala",
"path": "/src/site_url.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_site_url() {
let url = SiteUrl::parse("/blog/2022/01/31/test_post#top").unwrap();
assert_eq!(url.path(), "/blog/2022/01/31/test_post");
assert_eq!(url.href(), "/blog/2022/01/31/test_post#top");
let url = S... | code_fim | hard | {
"lang": "rust",
"repo": "treeman/jonashietala",
"path": "/src/site_url.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: treeman/jonashietala path: /src/site_url.rs
#![allow(dead_code)]
use crate::site::BASE_SITE_URL;
use camino::{Utf8Path, Utf8PathBuf};
use eyre::{eyre, Result};
use std::borrow::Cow;
use url::Url;
#[derive(Debug, Clone, Eq, Hash, PartialEq, Ord, PartialOrd)]
pub enum HrefUrl {
Fragment(Stri... | code_fim | hard | {
"lang": "rust",
"repo": "treeman/jonashietala",
"path": "/src/site_url.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buf = Vec::new();
let mut items: Vec<FeedItem> = Vec::new();
let mut current_item: Option<FeedItem> = None;
let mut current_field = FeedItemField::Invalid;
loop {
match reader.read_event(&mut buf) {
Ok(Event::Start(ref e)) => match e.name() {
b"item" | b"entry" => {
... | code_fim | hard | {
"lang": "rust",
"repo": "yuyoyuppe/rs_sbo_tg",
"path": "/src/feed.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yuyoyuppe/rs_sbo_tg path: /src/feed.rs
use chrono::{
naive::NaiveDateTime,
prelude::{DateTime, FixedOffset, Utc}
};
use curl::easy::Easy;
use failure::{err_msg, Error, ResultExt};
use quick_xml::{events::Event, Reader};
use std::{
fs::File,
io::{prelude::*, BufReader, Write},
path::Pat... | code_fim | hard | {
"lang": "rust",
"repo": "yuyoyuppe/rs_sbo_tg",
"path": "/src/feed.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avantgardnerio/rsui path: /src/scroll_panel.rs
use piston_window::*;
use piston_window::text::Text;
use crate::widget::Widget;
use crate::widget::WidgetImpl;
use crate::widget::Rect;
use crate::h_scroll::HScroll;
<|fim_suffix|> self.widget.children.insert(0, child);
}
fn draw(&... | code_fim | hard | {
"lang": "rust",
"repo": "avantgardnerio/rsui",
"path": "/src/scroll_panel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn draw(&self, ctx: Context, gl: &mut G2d, glyphs: &mut Glyphs) {
self.widget.draw(ctx, gl, glyphs)
}
}<|fim_prefix|>// repo: avantgardnerio/rsui path: /src/scroll_panel.rs
use piston_window::*;
use piston_window::text::Text;
use crate::widget::Widget;
use crate::widget::WidgetImpl;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "avantgardnerio/rsui",
"path": "/src/scroll_panel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32h7/src/stm32h747cm4/exti/d3pcr1h.rs
#[doc = "Reader of register D3PCR1H"]
pub type R = crate::R<u32, super::D3PCR1H>;
#[doc = "Writer for register D3PCR1H"]
pub type W = crate::W<u32, super::D3PCR1H>;
#[doc = "Register D3PCR1H `reset()`'s with value 0... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h747cm4/exti/d3pcr1h.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.w.bits = (self.w.bits & !(0x03 << 18)) | (((value as u32) & 0x03) << 18);
self.w
}
}
impl R {
#[doc = "Bits 6:7 - D3 Pending request clear input signal selection on Event input x = truncate ((n+32)/2)"]
#[inline(always)]
pub fn pcs19(&self) -> PCS19_R {
PCS19_R::new... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/stm32-rs-nightlies",
"path": "/stm32h7/src/stm32h747cm4/exti/d3pcr1h.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns index for specified resource inside this array.
/// Inserts resource if not in array yet.
///
/// # Panics
///
///
pub fn get_or_insert(&mut self, descriptor: T::Descriptor) -> u32
where
T::Descriptor: Hash + Clone + Eq,
{
match self.indices.... | code_fim | hard | {
"lang": "rust",
"repo": "fu5ha/sierra",
"path": "/src/descriptor/sparse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fu5ha/sierra path: /src/descriptor/sparse.rs
use {
super::{
DescriptorBindingFlags, DescriptorSet, DescriptorSetInfo, DescriptorSetLayout,
DescriptorSetLayoutBinding, DescriptorSetLayoutFlags, DescriptorSetLayoutInfo,
DescriptorsAllocationError, DescriptorsInput, Desc... | code_fim | hard | {
"lang": "rust",
"repo": "fu5ha/sierra",
"path": "/src/descriptor/sparse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andyyu2004/l-lang path: /src/lc-tir/src/visitor.rs
use crate as tir;
/// tir Visitor
pub trait Visitor<'tcx> {
fn visit_expr(&mut self, expr: &'tcx tir::Expr<'tcx>) -> bool;
<|fim_suffix|>/// tir Folder
pub trait Folder<'tcx>: Sized {
fn fold_expr(&mut self, expr: &'tcx tir::Expr<'tcx>)... | code_fim | medium | {
"lang": "rust",
"repo": "andyyu2004/l-lang",
"path": "/src/lc-tir/src/visitor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn fold_item(&mut self, item: &'tcx tir::Item<'tcx>) -> &'tcx tir::Item<'tcx>;
}<|fim_prefix|>// repo: andyyu2004/l-lang path: /src/lc-tir/src/visitor.rs
use crate as tir;
/// tir Visitor
pub trait Visitor<'tcx> {
fn visit_expr(&mut self, expr: &'tcx tir::Expr<'tcx>) -> bool;
fn visit_item(&... | code_fim | medium | {
"lang": "rust",
"repo": "andyyu2004/l-lang",
"path": "/src/lc-tir/src/visitor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// tir Folder
pub trait Folder<'tcx>: Sized {
fn fold_expr(&mut self, expr: &'tcx tir::Expr<'tcx>) -> &'tcx tir::Expr<'tcx>;
fn fold_item(&mut self, item: &'tcx tir::Item<'tcx>) -> &'tcx tir::Item<'tcx>;
}<|fim_prefix|>// repo: andyyu2004/l-lang path: /src/lc-tir/src/visitor.rs
use crate as t... | code_fim | medium | {
"lang": "rust",
"repo": "andyyu2004/l-lang",
"path": "/src/lc-tir/src/visitor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl Element {
pub fn mass(self) -> f64 {
match self {
$(Element::$S => $M as f64),+
}
}
pub fn from_str(s: &str) -> Option<Element> {
match s {
$(stringify!($S) => Some(Ele... | code_fim | hard | {
"lang": "rust",
"repo": "Osspial/mmass",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Osspial/mmass path: /src/main.rs
use std::env;
#[derive(Debug)]
enum Token {
Element(Element),
Count(u32)
}
fn main() {
let name = env::args().skip(1).next().unwrap();
let mut tokens = Vec::new();
let mut token_range = 0..1;
for (i, c) in name.chars().enumerate().skip(1) ... | code_fim | hard | {
"lang": "rust",
"repo": "Osspial/mmass",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! elements {
($($S:ident, $N:expr, $M:expr,)+) => {
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Element {
$($S = $N),+
}
impl Element {
pub fn mass(self) -> f64 {
match self {
... | code_fim | hard | {
"lang": "rust",
"repo": "Osspial/mmass",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(ossl110)]
pub(super) unsafe fn get_evp_rsa_sign_method() -> Result<*const openssl_sys2::EVP_PKEY_METHOD, openssl2::Error> {
// The default RSA method works fine but for one problem. When signing with a PSS key,
// it does the PSS padding itself and then invokes the key's encrypt function with RSA_... | code_fim | hard | {
"lang": "rust",
"repo": "tatac1/openssl-pkcs11-demo",
"path": "/openssl-engine-pkcs11/src/rsa.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tatac1/openssl-pkcs11-demo path: /openssl-engine-pkcs11/src/rsa.rs
impl crate::ex_data::HasExData<pkcs11::Object<openssl::rsa::Rsa<openssl::pkey::Private>>> for openssl_sys::RSA {
unsafe fn index() -> openssl::ex_data::Index<Self, pkcs11::Object<openssl::rsa::Rsa<openssl::pkey::Private>>> {
c... | code_fim | hard | {
"lang": "rust",
"repo": "tatac1/openssl-pkcs11-demo",
"path": "/openssl-engine-pkcs11/src/rsa.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return vertical.min.y < horizontal.min.y
&& horizontal.min.y < vertical.max.y
&& horizontal.min.x < vertical.min.x
&& vertical.min.x < horizontal.max.x;
}
}<|fim_prefix|>// repo: bonanaaaaaa/advent-of-code-2019-rust path: /src/day03/line.rs
use crate::day03::point::Point;
#[deriv... | code_fim | hard | {
"lang": "rust",
"repo": "bonanaaaaaa/advent-of-code-2019-rust",
"path": "/src/day03/line.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bonanaaaaaa/advent-of-code-2019-rust path: /src/day03/line.rs
use crate::day03::point::Point;
#[derive(PartialEq, Debug)]
enum Alignment {
Horizontal,
Vertical,
}
#[derive(Debug)]
pub struct Line {
pub start: Point,
pub end: Point,
min: Point,
max: Point,
alignment: Alignment,
... | code_fim | hard | {
"lang": "rust",
"repo": "bonanaaaaaa/advent-of-code-2019-rust",
"path": "/src/day03/line.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxfriends/dwarf-mine-builder path: /src/system/camera/target.rs
use game_engine::{system, prelude::*};
use crate::model::Point3D;
use crate::resource::VisibleRange;
use crate::constant::ISO_GRID;
<|fim_suffix|> &mut self,
visible_range: &Resource<VisibleRange>,
... | code_fim | medium | {
"lang": "rust",
"repo": "foxfriends/dwarf-mine-builder",
"path": "/src/system/camera/target.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>system! {
impl CameraTarget {
fn run(
&mut self,
visible_range: &Resource<VisibleRange>,
camera: &mut Resource<Camera>,
) {
let target = ISO_GRID.origin(visible_range.origin() - Point3D { x: 0, y: 0, z: visible_range.size().depth as i32 /... | code_fim | medium | {
"lang": "rust",
"repo": "foxfriends/dwarf-mine-builder",
"path": "/src/system/camera/target.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut or = 0;
let mut and = 0;
for c in s.chars() {
match c {
'1' => {
or |= 1;
and |= 1;
}
'0' => {}
'X' => and |= 1,
_ => unreachable!("Invalid ma... | code_fim | medium | {
"lang": "rust",
"repo": "imDema/advent_of_code_2020",
"path": "/d14/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: imDema/advent_of_code_2020 path: /d14/src/main.rs
use std::io::{BufRead, stdin};
use std::collections::HashMap;
use lazy_static::lazy_static;
use regex::Regex;
lazy_static!(
static ref RE_MEM: Regex = Regex::new(r"^mem\[(\d+)\]\D+(\d+)").unwrap();
);
const MASK_PREFIX: &'static str = "mask... | code_fim | hard | {
"lang": "rust",
"repo": "imDema/advent_of_code_2020",
"path": "/d14/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let stdin = stdin();
let ops = stdin.lock().lines().map(|l| l.unwrap())
.map(|l| Op::new(&l).unwrap());
let mut memmap: HashMap<u64, u64> = HashMap::new();
let mut and = 0;
let mut or = 0;
for op in ops {
match op {
Op::Mask(a, o) => {a... | code_fim | hard | {
"lang": "rust",
"repo": "imDema/advent_of_code_2020",
"path": "/d14/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.debug_struct("MySqlConnection").finish()
}
}
pub struct DropBox<T> {
pub inner: Option<T>,
}
impl<T> Deref for DropBox<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
self.inner.as_ref().expect("conn closed")
}
}
impl<T> DerefMut for DropBox<T> {
fn d... | code_fim | hard | {
"lang": "rust",
"repo": "rbatis/rbatis",
"path": "/rbdc-mysql/src/connection/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rbatis/rbatis path: /rbdc-mysql/src/connection/mod.rs
use crate::protocol::statement::StmtClose;
use crate::protocol::text::{Ping, Quit};
use crate::stmt::MySqlStatementMetadata;
use either::Either;
use futures_core::future::BoxFuture;
use futures_core::stream::BoxStream;
use futures_util::{Futu... | code_fim | hard | {
"lang": "rust",
"repo": "rbatis/rbatis",
"path": "/rbdc-mysql/src/connection/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.inner.as_mut().expect("conn closed")
}
}
impl MySqlConnection {
#[inline]
async fn do_close(&mut self) -> Result<(), Error> {
self.stream.send_packet(Quit).await?;
self.stream.shutdown().await?;
Ok(())
}
fn do_ping(&mut self) -> BoxFuture<'_, Resu... | code_fim | hard | {
"lang": "rust",
"repo": "rbatis/rbatis",
"path": "/rbdc-mysql/src/connection/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn using_other_iterator_trait_methods() {
let sum: u32 = Counter::new(8)
.zip(Counter::new(8).skip(1))
.map(|(a, b)| a * b)
.filter(|x| x % 3 == 0)
.sum();
assert_eq!(90, sum);
}<|fim_prefix|>// repo: dipique/rust_book path: /13_closures_iterators/s... | code_fim | hard | {
"lang": "rust",
"repo": "dipique/rust_book",
"path": "/13_closures_iterators/src/iterator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // at this time, no operation has been performed (just like .Select in C#);
// we need to use a consuming function to execute the operation/query
let data: Vec<i32> = mapped.collect();
println!("Now the operation has been executed: {:?}", data);
}
#[test]
fn using_other_iterator_... | code_fim | hard | {
"lang": "rust",
"repo": "dipique/rust_book",
"path": "/13_closures_iterators/src/iterator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dipique/rust_book path: /13_closures_iterators/src/iterator.rs
mod counter;
use counter::Counter;
pub fn do_thing() {
let v1 = vec![1,2,3];
let v1_iter = v1.iter();
let sum: i32 = v1_iter.sum();
println!("Sum is {}", sum);
<|fim_suffix|> // at this time, no operatio... | code_fim | hard | {
"lang": "rust",
"repo": "dipique/rust_book",
"path": "/13_closures_iterators/src/iterator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PeterGrace/powerline-rust path: /src/modules/newline.rs
use std::{marker::PhantomData};
use super::Module;
use crate::{terminal::Color, Segment, R};
pub struct NewLine<S: NewLineScheme> {
scheme: PhantomData<S>,
}
<|fim_suffix|> segments.push(Segment::simple(format!("\n"), S::NEWLINE_FG, S::N... | code_fim | hard | {
"lang": "rust",
"repo": "PeterGrace/powerline-rust",
"path": "/src/modules/newline.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S: NewLineScheme> Module for NewLine<S> {
fn append_segments(&mut self, segments: &mut Vec<Segment>) -> R<()> {
segments.push(Segment::simple(format!("\n"), S::NEWLINE_FG, S::NEWLINE_BG));
Ok(())
}
}<|fim_prefix|>// repo: PeterGrace/powerline-rust path: /src/modules/newline.rs
use std::{marker... | code_fim | hard | {
"lang": "rust",
"repo": "PeterGrace/powerline-rust",
"path": "/src/modules/newline.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/ts/classes/index_signature_class_member.rs
use crate::prelude::*;
use crate::utils::FormatOptionalSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsIndexSignatureClassMember;
use rome_js_syntax::TsIndexSignatureClassMemberFields;
<|fim_s... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_js_formatter/src/ts/classes/index_signature_class_member.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
node: &TsIndexSignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsIndexSignatureClassMemberFields {
modifiers,
l_brack_token,
parameter,
r_brack_token,
type_annotation,
s... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_js_formatter/src/ts/classes/index_signature_class_member.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(
f,
[
modifiers.format(),
space(),
l_brack_token.format(),
parameter.format(),
r_brack_token.format(),
type_annotation.format(),
FormatOptionalSemicolon::n... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_js_formatter/src/ts/classes/index_signature_class_member.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("I've got {} numbers.", my_numbers.len());
}<|fim_prefix|>// repo: a-bakos/rust-playground path: /archived-learning/rust-prog-for-beginners/vectors/src/main.rs
struct TestScore {
score: i32,
}
fn main() {
let test_scores = vec![
TestScore { score: 99 },
TestScore { s... | code_fim | hard | {
"lang": "rust",
"repo": "a-bakos/rust-playground",
"path": "/archived-learning/rust-prog-for-beginners/vectors/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: a-bakos/rust-playground path: /archived-learning/rust-prog-for-beginners/vectors/src/main.rs
struct TestScore {
score: i32,
}
fn main() {
let test_scores = vec![
TestScore { score: 99 },
TestScore { score: 52 },
TestScore { score: 23 },
TestScore { score:... | code_fim | hard | {
"lang": "rust",
"repo": "a-bakos/rust-playground",
"path": "/archived-learning/rust-prog-for-beginners/vectors/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl WriteMemory for WavePatternRam {
fn write_byte(&mut self, position: Word, value: Byte) {
self.data.write_byte(position, value);
}
}
impl Default for WavePatternRam {
fn default() -> Self {
Self {
data: MemorySector::with_size(0x10),
}
}
}<|fim_pref... | code_fim | medium | {
"lang": "rust",
"repo": "jdomenechb/rustiegb",
"path": "/src/memory/wave_pattern_ram.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdomenechb/rustiegb path: /src/memory/wave_pattern_ram.rs
use crate::memory::memory_sector::{MemorySector, ReadMemory, WriteMemory};
use crate::{Byte, Word};
pub struct WavePatternRam {
pub data: MemorySector,
}
<|fim_suffix|> self.data.read_byte(position)
}
}
impl WriteMemory ... | code_fim | medium | {
"lang": "rust",
"repo": "jdomenechb/rustiegb",
"path": "/src/memory/wave_pattern_ram.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rl,
crate::Message {
body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
content_type: Some("application/json".to_string()),
},
)
.await
}
/**
* Delete an IP pool.
*
* This functi... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/third-party-api-clients",
"path": "/sendgrid/src/ip_pools.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oxidecomputer/third-party-api-clients path: /sendgrid/src/ip_pools.rs
use crate::Client;
use crate::ClientResult;
pub struct IpPools {
pub client: Client,
}
impl IpPools {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
IpPools { client }
}
/**
* Retrieve ... | code_fim | hard | {
"lang": "rust",
"repo": "oxidecomputer/third-party-api-clients",
"path": "/sendgrid/src/ip_pools.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> attrs.extend(item.attrs);
item.attrs = attrs;
return Ok(Input::Trait(item));
}
if ahead.peek(Token![impl]) {
let mut item: ItemImpl = input.parse()?;
if item.trait_.is_none() {
let impl_token = item.impl_token;
... | code_fim | hard | {
"lang": "rust",
"repo": "brace-rs/brace-cast",
"path": "/crates/brace-cast-macros/src/parse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> attrs.extend(item.attrs);
item.attrs = attrs;
return Ok(Input::Impl(item));
}
Err(input.error("expected trait Trait or impl Trait for Type"))
}
}<|fim_prefix|>// repo: brace-rs/brace-cast path: /crates/brace-cast-macros/src/parse.rs
use quote::quo... | code_fim | hard | {
"lang": "rust",
"repo": "brace-rs/brace-cast",
"path": "/crates/brace-cast-macros/src/parse.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brace-rs/brace-cast path: /crates/brace-cast-macros/src/parse.rs
use quote::quote;
use syn::parse::{Parse, ParseStream, Result};
use syn::{Attribute, Error, ItemImpl, ItemTrait, Token, Visibility};
pub enum Input {
Trait(ItemTrait),
Impl(ItemImpl),
}
<|fim_suffix|> return Ok... | code_fim | hard | {
"lang": "rust",
"repo": "brace-rs/brace-cast",
"path": "/crates/brace-cast-macros/src/parse.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> nums.push(numbers[0].as_array().unwrap());
nums.push(numbers[1].as_array().unwrap());
nums.push(numbers[2].as_array().unwrap());
if chunk == 0 {
return result;
} else {
// 100, 200, ..., 900
if chunk >= 100 {
let number = nums[2][(chunk / 100 - 1) a... | code_fim | hard | {
"lang": "rust",
"repo": "MaksRawski/numatim",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaksRawski/numatim path: /src/lib.rs
use serde::{Deserialize, Serialize};
use serde_json::Value;
// Number needs to be sanitized before usage.
pub fn verbatim(number: String, dict: Dict) -> Result<String, String> {
let mut number = number;
// pad with leading zeros if input is not divis... | code_fim | hard | {
"lang": "rust",
"repo": "MaksRawski/numatim",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CodeSandwich/swagger-cardano-poligon path: /examples/client.rs
#![allow(missing_docs, unused_variables, trivial_casts)]
extern crate Cardano Node API;
#[allow(unused_extern_crates)]
extern crate futures;
#[allow(unused_extern_crates)]
extern crate swagger;
#[allow(unused_extern_crates)]
extern ... | code_fim | hard | {
"lang": "rust",
"repo": "CodeSandwich/swagger-cardano-poligon",
"path": "/examples/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some("ApiV1NodeSettingsGet") => {
let result = core.run(client.api_v1_node_settings_get());
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
},
Some("ApiV1NextUpdateGet") => {
let... | code_fim | hard | {
"lang": "rust",
"repo": "CodeSandwich/swagger-cardano-poligon",
"path": "/examples/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jpbougie/aoc2019 path: /src/bin/03.rs
use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let mut lines = stdin.lock().lines();
let l1 = lines.next().unwrap().unwrap();
let l2 = lines.next().unwrap().unwrap();
println!("Part 1: {}", run(&l1, &l2).unwrap());
... | code_fim | hard | {
"lang": "rust",
"repo": "jpbougie/aoc2019",
"path": "/src/bin/03.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> },
Move::Down(dist) => {
for i in 1..=dist {
pos = PointWithStep{point: (orig.point.0 - i, orig.point.1), steps: orig.steps + i as usize};
points.push(pos);
}
}
}
pos
}
}
imp... | code_fim | hard | {
"lang": "rust",
"repo": "jpbougie/aoc2019",
"path": "/src/bin/03.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ThomasZumsteg/project-euler path: /problem_0050.rs
#[macro_use]
extern crate clap;
use common::set_log_level;
use common::primes::Primes;
use log::info;
use std::sync::{Arc, RwLock};
use threadpool::ThreadPool;
fn main() {
let args = clap_app!(app =>
(about: "Solve Project Euler Pr... | code_fim | hard | {
"lang": "rust",
"repo": "ThomasZumsteg/project-euler",
"path": "/problem_0050.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let primes: Arc<Vec<usize>> = Arc::new(Primes::new().take_while(|&p| p <= limit).collect());
let pool = ThreadPool::new(threads);
let result: Arc<RwLock<Option<(usize, usize)>>> = Arc::new(RwLock::new(None));
for t in 0..threads {
let primes = primes.clone();
let result = r... | code_fim | hard | {
"lang": "rust",
"repo": "ThomasZumsteg/project-euler",
"path": "/problem_0050.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlexNav73/rusty_dam path: /web_app/src/controllers/home.rs
use rocket_contrib::Template;
use rocket::response::Redirect;
use APIKey;
<|fim_suffix|>#[get("/", rank = 2)]
fn index_anon() -> Redirect {
Redirect::to("/security/login")
}<|fim_middle|>#[derive(Serialize)]
struct Conte... | code_fim | hard | {
"lang": "rust",
"repo": "AlexNav73/rusty_dam",
"path": "/web_app/src/controllers/home.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[get("/", rank = 2)]
fn index_anon() -> Redirect {
Redirect::to("/security/login")
}<|fim_prefix|>// repo: AlexNav73/rusty_dam path: /web_app/src/controllers/home.rs
use rocket_contrib::Template;
use rocket::response::Redirect;
use APIKey;
#[derive(Serialize)]
struct Content {
mess... | code_fim | medium | {
"lang": "rust",
"repo": "AlexNav73/rusty_dam",
"path": "/web_app/src/controllers/home.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: google/tock-on-titan path: /third_party/ansi_term/src/windows.rs
/// Enables ANSI code support on Windows 10.
///
/// This uses Windows API calls to alter the properties of the console that
/// the program is running in.
///
/// https://msdn.microsoft.com/en-us/library/windows/desktop/mt638... | code_fim | medium | {
"lang": "rust",
"repo": "google/tock-on-titan",
"path": "/third_party/ansi_term/src/windows.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // VT processing not already enabled?
if console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0 {
// https://docs.microsoft.com/en-us/windows/console/setconsolemode
SetConsoleMode(std_out_handle, console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
le... | code_fim | hard | {
"lang": "rust",
"repo": "google/tock-on-titan",
"path": "/third_party/ansi_term/src/windows.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn expr_return_none_or_err(
smbl: Symbol,
cx: &LateContext<'_>,
expr: &Expr<'_>,
cond_expr: &Expr<'_>,
err_sym: Option<Symbol>,
) -> bool {
match peel_blocks_with_stmt(expr).kind {
ExprKind::Ret(Some(ret_expr)) => expr_return_none_or_err(smbl, cx, ret_expr, cond_expr, err_s... | code_fim | hard | {
"lang": "rust",
"repo": "lukas-code/rust-clippy",
"path": "/clippy_lints/src/question_mark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukas-code/rust-clippy path: /clippy_lints/src/question_mark.rs
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::higher;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::ty::is_type_diagnostic_item;
use clippy_utils::{
eq_expr_value, get_parent_node... | code_fim | hard | {
"lang": "rust",
"repo": "lukas-code/rust-clippy",
"path": "/clippy_lints/src/question_mark.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if_chain! {
if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else }) = higher::IfLet::hir(cx, expr);
if !is_else_clause(cx.tcx, expr);
if let PatKind::TupleStruct(ref path1, [field], ddpos) = let_pat.kind;
if ddpos.as_opt_usize().is_none();
if let PatK... | code_fim | hard | {
"lang": "rust",
"repo": "lukas-code/rust-clippy",
"path": "/clippy_lints/src/question_mark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zellij-org/zellij path: /zellij-client/src/unit/stdin_tests.rs
use super::input_loop;
use crate::stdin_ansi_parser::StdinAnsiParser;
use crate::stdin_loop;
use zellij_utils::anyhow::Result;
use zellij_utils::data::{Direction, InputMode, Palette};
use zellij_utils::input::actions::Action;
use zel... | code_fim | hard | {
"lang": "rust",
"repo": "zellij-org/zellij",
"path": "/zellij-client/src/unit/stdin_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unimplemented!()
}
fn unset_raw_mode(&self, _fd: RawFd) -> Result<(), nix::Error> {
unimplemented!()
}
fn get_stdout_writer(&self) -> Box<dyn io::Write> {
let fake_stdout_writer = FakeStdoutWriter::new(self.stdout_buffer.clone());
Box::new(fake_stdout_writer... | code_fim | hard | {
"lang": "rust",
"repo": "zellij-org/zellij",
"path": "/zellij-client/src/unit/stdin_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
pub fn move_focus_left_in_normal_mode() {
let stdin_events = vec![
(
commands::MOVE_FOCUS_LEFT_IN_NORMAL_MODE.to_vec(),
InputEvent::Key(KeyEvent {
key: KeyCode::Char('h'),
modifiers: Modifiers::ALT,
}),
),
... | code_fim | hard | {
"lang": "rust",
"repo": "zellij-org/zellij",
"path": "/zellij-client/src/unit/stdin_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lein1013/wallet.rs path: /bindings/nodejs/native/src/types.rs
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use iota_wallet::client::{Api, BrokerOptions, ClientOptions, Node};
use serde::Deserialize;
use url::Url;
use std::{collections::HashMap, time::Duration};
#[der... | code_fim | hard | {
"lang": "rust",
"repo": "lein1013/wallet.rs",
"path": "/bindings/nodejs/native/src/types.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !options.node_sync_enabled {
client_builder = client_builder.with_node_sync_disabled();
}
client_builder = bind_client_option!(client_builder, options.request_timeout, with_request_timeout);
for (api, timeout) in options.api_timeout {
client_bui... | code_fim | hard | {
"lang": "rust",
"repo": "lein1013/wallet.rs",
"path": "/bindings/nodejs/native/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut client_builder = Self::builder()
.with_node_pool_urls(
&options
.node_pool_urls
.iter()
.map(|url| url.as_str())
.collect::<Vec<&str>>()[..],
)
.unwrap()
... | code_fim | hard | {
"lang": "rust",
"repo": "lein1013/wallet.rs",
"path": "/bindings/nodejs/native/src/types.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SomeTiramisu/SubsUtils path: /uuencode/ruuencode.rs
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
//println!("{:?}", args);
let path = Path::new(&args[1]);
//let path = Path::new("/home/g... | code_fim | hard | {
"lang": "rust",
"repo": "SomeTiramisu/SubsUtils",
"path": "/uuencode/ruuencode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match buf.get(i) {
Some(&x) => x,
None => 0,
}
}
fn byte_encode(x: u8) -> u8 {
(x&63)+33
}
fn print_buf(buf: &Vec<u8>) {
let n = buf.len();
for i in 0..n {
print!("{}", buf[i] as char);
if ((i+1)%80) == 0 && i != 0 {
print!("\n");
};
};
}<|fim_prefix|>// repo: SomeTira... | code_fim | hard | {
"lang": "rust",
"repo": "SomeTiramisu/SubsUtils",
"path": "/uuencode/ruuencode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn uuencode(buf: &Vec<u8>) -> Vec<u8> {
let mut ebuf: Vec<u8> = Vec::new();
let n = buf.len();
let m = match n%3 {
1 => n+2,
2 => n+1,
_ => n,
};
for i in (0..m).step_by(3) {
let x1 = get_or_zero(buf, i) as u32;
let x2 = get_or_zero(buf, i+1) as u32;
let x3 = get_or_zero(buf, i+2... | code_fim | hard | {
"lang": "rust",
"repo": "SomeTiramisu/SubsUtils",
"path": "/uuencode/ruuencode.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.