text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>le_id: Option<String>,
},
Market {
time: String,
product_id: String,
sequence: usize,
order_id: String,
reason: Reason,
side: OrderSide,
},
}<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /src/exchange/coinbase/model/websocket/done.rs
use rus... | code_fim | hard | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/src/exchange/coinbase/model/websocket/done.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KaitaoQiu/openlimits path: /src/exchange/coinbase/model/websocket/done.rs
use rust_decimal::prelude::Decimal;
use serde::Deserialize;
use super::OrderSide;
use super::Reason;
use super::shared::string_to_decimal;
#[derive(Deserialize, Debug, Clone)]
#[serde(untagged)]
pub <|fim_suffix|>
... | code_fim | hard | {
"lang": "rust",
"repo": "KaitaoQiu/openlimits",
"path": "/src/exchange/coinbase/model/websocket/done.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // println!("total_weight: {}, total_weighted_measure: {}", total_weight, total_weighted_measure);
// println!("Weights: {:?}", neuron.synapses.iter().map(|syn| *syn.weight.borrow()).collect::<Vec<f32>>());
total_weighted_measure_vec.push(total_weighted_measure);
... | code_fim | hard | {
"lang": "rust",
"repo": "DGeisz/prototype_ae",
"path": "/src/neurology.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DGeisz/prototype_ae path: /src/neurology.rs
use mccm::{MnistNetwork, MnistNeuron, MNIST_SIDE};
use std::cell::RefCell;
use std::rc::Rc;
use std::path::Path;
use std::fs::File;
use std::io::Write;
struct Synapse {
measure: RefCell<f32>,
weight: RefCell<f32>,
}
impl Synapse {
fn new(... | code_fim | hard | {
"lang": "rust",
"repo": "DGeisz/prototype_ae",
"path": "/src/neurology.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // println!("Weights: {:?}", neuron.synapses.iter().map(|syn| *syn.weight.borrow()).collect::<Vec<f32>>());
total_weighted_measure_vec.push(total_weighted_measure);
total_weight_vec.push(total_weight);
}
let weighted_average_vec = total_weight_vec
... | code_fim | hard | {
"lang": "rust",
"repo": "DGeisz/prototype_ae",
"path": "/src/neurology.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /src/commands/settings.rs
//! The module that implements the `wasmtime settings` command.
use anyhow::{anyhow, Result};
use clap::Parser;
use serde::{ser::SerializeMap, Serialize};
use std::collections::BTreeMap;
use std::str::FromStr;
use wasmtime_environ::{Comp... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/src/commands/settings.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add_setting(&mut self, setting: Setting) {
let collection = match setting.kind {
SettingKind::Enum => &mut self.enums,
SettingKind::Num => &mut self.nums,
SettingKind::Bool => &mut self.bools,
SettingKind::Preset => &mut self.presets,
... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/src/commands/settings.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_4() {
assert_eq!(Solution::is_match("adceb".to_string(), "*a*b".to_string()), true);
}
#[test]
fn test_5() {
assert_eq!(Solution::is_match("acdcb".to_string(), "a*c?b".to_string()), false);
}
#[test]
fn test_6() {
assert_eq!(Solutio... | code_fim | hard | {
"lang": "rust",
"repo": "dmitry-pechersky/algorithms",
"path": "/leetcode/44_Wildcard_Matching.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::is_match("acdcb".to_string(), "a*c?b".to_string()), false);
}
#[test]
fn test_6() {
assert_eq!(Solution::is_match("".to_string(), "***".to_string()), true);
}
}<|fim_prefix|>// repo: dmitry-pechersky/algorithms path: /leetcode/44_Wildcard_Matching.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "dmitry-pechersky/algorithms",
"path": "/leetcode/44_Wildcard_Matching.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmitry-pechersky/algorithms path: /leetcode/44_Wildcard_Matching.rs
use std::collections::HashSet;
struct Solution {}
impl Solution {
pub fn is_match(s: String, p: String) -> bool {
let s: Vec<char> = s.chars().collect();
let p: Vec<char> = p.chars().collect();
let ... | code_fim | hard | {
"lang": "rust",
"repo": "dmitry-pechersky/algorithms",
"path": "/leetcode/44_Wildcard_Matching.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn cbc_pad(msg: &[u8]) -> Vec<u8> {
let mut padded = msg.to_vec();
if msg.len() % 16 == 0 {
padded.append(&mut vec![16 as u8; 16]);
} else {
let padding_len = 16 - msg.len() % 16;
padded.append(&mut vec![padding_len as u8; padding_len as usize]);
}
padded
}<|fim... | code_fim | hard | {
"lang": "rust",
"repo": "alxiong/cryptopal",
"path": "/challenges/src/bin/chal49.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alxiong/cryptopal path: /challenges/src/bin/chal49.rs
use challenges::chal49::*;
use challenges::random_bytes;
fn main() {
println!("🔓 Challenge 49");
variable_iv_attack();
extension_attack();
}
// attack idea: with a previously signed (msg, mac) using iv of zero,
// then a forged... | code_fim | hard | {
"lang": "rust",
"repo": "alxiong/cryptopal",
"path": "/challenges/src/bin/chal49.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input: [usize; 0] = [];
for size in 0 .. 4 {
let output = FadingWindows::new(&input, size).collect::<Vec<_>>();
let expect: Vec<&[usize]> = Vec::new();
assert_eq!(output, expect);
}
}
#[test]
fn fading_windows_singleton() {
... | code_fim | hard | {
"lang": "rust",
"repo": "DougAnderson444/deno-autosuggest",
"path": "/rust/core/src/utils/fading_windows.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let size = 3;
let input: [usize; 5] = [10, 20, 30, 40, 50];
let expect: [&[usize]; 5] = [&[10, 20, 30], &[20, 30, 40], &[30, 40, 50], &[40, 50], &[50]];
let output = FadingWindows::new(&input, size).collect::<Vec<_>>();
assert_eq!(output, expect);
}
#[test... | code_fim | hard | {
"lang": "rust",
"repo": "DougAnderson444/deno-autosuggest",
"path": "/rust/core/src/utils/fading_windows.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DougAnderson444/deno-autosuggest path: /rust/core/src/utils/fading_windows.rs
use std::cmp::min;
#[derive(Debug)]
pub struct FadingWindows<'a, T: 'a> {
v: &'a [T],
size: usize,
}
impl<'a, T: 'a> FadingWindows<'a, T> {
pub fn new(v: &'a [T], size: usize) -> Self {
if size =... | code_fim | hard | {
"lang": "rust",
"repo": "DougAnderson444/deno-autosuggest",
"path": "/rust/core/src/utils/fading_windows.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niteshnicholas/programming-languages path: /rust-lang/rust-simple-scraper/src/main.rs
use reqwest;
//use select;
use select::document::Document;
use select::predicate::{Class, Name, Predicate};
use scraper::{Selector, Html};
fn main() -> Result<(), Box<std::error::Error>> {
<|fim_suffix|> le... | code_fim | medium | {
"lang": "rust",
"repo": "niteshnicholas/programming-languages",
"path": "/rust-lang/rust-simple-scraper/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Copy the items to the directory where they will be hosted
// - The out_dir will likely be different in your project
// let out_dir = std::path::Path::new(&env::var("CARGO_MANIFEST_DIR")?)
// .parent().unwrap()
// .parent().unwrap()
// .parent().unwrap()
// .j... | code_fim | hard | {
"lang": "rust",
"repo": "sotrh/learn-wgpu",
"path": "/code/beginner/tutorial9-models/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sotrh/learn-wgpu path: /code/beginner/tutorial9-models/build.rs
use anyhow::*;
use fs_extra::copy_items;
use fs_extra::dir::CopyOptions;
use std::env;
fn main() -> Result<()> {
<|fim_suffix|> // Copy the items to the directory where they will be hosted
// - The out_dir will likely be dif... | code_fim | hard | {
"lang": "rust",
"repo": "sotrh/learn-wgpu",
"path": "/code/beginner/tutorial9-models/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn f<T>(val: T) {
*Box::new_in(val, &Global);
}<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/94835.rs
#![feature(allocator_api)]
use std::alloc::Global;
<|fim_middle|>fn main() {
// f(()) // no ICE
f(32); // ICE
}
| code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/glacier",
"path": "/fixed/94835.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/94835.rs
#![feature(allocator_api)]
use std::alloc::Global;
fn main() {
<|fim_suffix|>pub fn f<T>(val: T) {
*Box::new_in(val, &Global);
}<|fim_middle|> // f(()) // no ICE
f(32); // ICE
}
| code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/glacier",
"path": "/fixed/94835.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/glacier path: /fixed/94835.rs
#![feature(allocator_api)]
use std::alloc::Global;
<|fim_suffix|>pub fn f<T>(val: T) {
*Box::new_in(val, &Global);
}<|fim_middle|>fn main() {
// f(()) // no ICE
f(32); // ICE
}
| code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/glacier",
"path": "/fixed/94835.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> text.push(next_block.char);
self.x += 1;
}
self.step();
return Some(ScreenDifference {
x: change_x,
y: change_y,
text,
fg: new_block.fg,
... | code_fim | hard | {
"lang": "rust",
"repo": "LPGhatguy/magic-school-bus",
"path": "/src/virtual_screen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LPGhatguy/magic-school-bus path: /src/virtual_screen.rs
use crate::{
terminal_context::{Color, TerminalContext},
virtual_screen_buffer::VirtualScreenBuffer,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ScreenCell {
pub fg: Color,
pub bg: Color,
pub char: char,
... | code_fim | hard | {
"lang": "rust",
"repo": "LPGhatguy/magic-school-bus",
"path": "/src/virtual_screen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn summoner_by_name(
name: String,
region: Region,
client: &Client,
key: &String,
) -> Result<SummonerDTO, reqwest::Error> {
let url = format!("{}{}{}", region.as_str(), SUMMONER_BY_NAME, name);
let data = client
.get(&url)
.header(KEY, key)
.send(... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/chaotic-analyzer",
"path": "/src/riot/api/summoner.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TriedWorks/chaotic-analyzer path: /src/riot/api/summoner.rs
use crate::models::riot::summoner::SummonerDTO;
use crate::riot::api::{KEY, SUMMONER_BY_ID, SUMMONER_BY_NAME};
use crate::types::region::Region;
use reqwest::Client;
<|fim_suffix|>pub async fn summoner_by_name(
name: String,
re... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/chaotic-analyzer",
"path": "/src/riot/api/summoner.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruggeri/fourier2 path: /src/lib/core/scale.rs
use super::pitch::Pitch;
pub fn scale_for_octave(octave: i32) -> Vec<Pitch> {
vec![
format!("A.{}", octave).parse().unwrap(),
format!("A#{}", octave).parse().unwrap(),
format!("B.{}", octave).parse().unwrap(),
for... | code_fim | medium | {
"lang": "rust",
"repo": "ruggeri/fourier2",
"path": "/src/lib/core/scale.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pps: Vec<Pitch> = Vec::new();
for octave in 0..8 {
pps.extend(scale_for_octave(octave));
}
_PPS_OPTION = Some(pps);
piano_pitches()
}
}<|fim_prefix|>// repo: ruggeri/fourier2 path: /src/lib/core/scale.rs
use super::pitch::Pitch;
pub fn sca... | code_fim | medium | {
"lang": "rust",
"repo": "ruggeri/fourier2",
"path": "/src/lib/core/scale.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CasualX/pak path: /examples/readme1.rs
fn main() {
let key = &[13, 42];
// Create the editor object to create PAK files in memory.
let mut edit = pak::MemoryEditor::new();
// This file contains 65 bytes filled with `0xCF`.
let data = &[0xCF; 65];
<|fim_suffix|> // Print the PAK file its... | code_fim | hard | {
"lang": "rust",
"repo": "CasualX/pak",
"path": "/examples/readme1.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Print the PAK file itself.
print!("The RAW data:\n\n```\n{:x?}\n```\n", pak);
// Create the reader object to inspect PAK files in memory.
let read = pak::MemoryReader::from_blocks(&pak, key);
// Find the file created earlier.
let desc = read.find(b"sub/foo").unwrap();
// Read its contents into ... | code_fim | medium | {
"lang": "rust",
"repo": "CasualX/pak",
"path": "/examples/readme1.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Roang-zero1/aoc2020-rust path: /src/day05.rs
use std::collections::HashMap;
use std::str::FromStr;
#[derive(Debug, PartialEq)]
enum Direction {
Lower,
Upper,
}
impl FromStr for Direction {
type Err = ();
fn from_str(input: &str) -> Result<Direction, Self::Err> {
match input {
... | code_fim | hard | {
"lang": "rust",
"repo": "Roang-zero1/aoc2020-rust",
"path": "/src/day05.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day5, part1)]
pub fn solve_part1(boarding_passes: &str) -> u16 {
let mut max = 0;
for line in boarding_passes.lines() {
let mut rows = (0, 127);
let mut columns = (0, 7);
for direction in line.chars() {
if direction == 'F' || direction == 'B' {
//println!("rows: {},{}/{... | code_fim | hard | {
"lang": "rust",
"repo": "Roang-zero1/aoc2020-rust",
"path": "/src/day05.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cfg = samd51::ext::sercom::Config::default()
.set_mode(samd51::ext::sercom::Mode::UsartInternal)
.set_baud_clock(115_200, 48_000_000)
.set_rxpo(0x1)
.set_txpo(0x0);
SERCOM5.configure(cfg);
SERCOM5.set_enabled(true);
loop {
for _ in 0..1_000_000 ... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu-examples/bobbin-samd51-example/src/bin/serial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
for _ in 0..1_000_000 {
asm::nop();
}
PA23.toggle_output();
SERCOM5.write("Hello, World\n".as_bytes());
}
}<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu-examples/bobbin-samd51-example/src/bin/serial.rs
#![no_std]
#![no_main]
extern crat... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu-examples/bobbin-samd51-example/src/bin/serial.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu-examples/bobbin-samd51-example/src/bin/serial.rs
#![no_std]
#![no_main]
extern crate panic_abort;
use cortex_m_rt::entry;
use cortex_m::asm;
use samd51::bobbin_mcu::prelude::*;
use samd51::bobbin_hal::prelude::*;
use samd51::port::PORTB;
use samd51::sercom::SERC... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu-examples/bobbin-samd51-example/src/bin/serial.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nabrozidhs/rust-adventofcode2018 path: /day05/main.rs
use std::io;
use std::io::Read;
fn day5_part1(input: &mut String) -> u64 {
let mut index: usize = 1;
while index < input.len() {
let a = input.as_bytes()[index];
let b = input.as_bytes()[index - 1];
if a == b... | code_fim | hard | {
"lang": "rust",
"repo": "nabrozidhs/rust-adventofcode2018",
"path": "/day05/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
println!("part1 {}", day5_part1(&mut input.clone()));
println!("part2 {}", day5_part2(&input));
}<|fim_prefix|>// repo: nabrozidhs/rust-adventofcode2018 path: /day05/main.rs
use std::io;
use std::io::Read;
f... | code_fim | hard | {
"lang": "rust",
"repo": "nabrozidhs/rust-adventofcode2018",
"path": "/day05/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KMJ192/rust path: /rust_grammar/error_handling/src/main.rs
enum Result<T, E>{
Ok(T),
Err(E),
}
// enum Option<T>{
// Some(T),
// None,
// }
fn exit(x : i32){
<|fim_suffix|> let f = File::open("text.txt");
let f = match f{
Ok(file) => file,
Err(ref error) i... | code_fim | hard | {
"lang": "rust",
"repo": "KMJ192/rust",
"path": "/rust_grammar/error_handling/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn mat(x : Option<i32>){
match x{
Some(0) => panic!("panic 0"),
Some(x) => println!("{}", x),
None => println!("None"),
}
}
use std::fs::File;
use std::io::ErrorKind;
fn main(){
exit(1);
//exit(0);
mat(Some(1));
mat(None);
//mat(Some(0));
let f =... | code_fim | medium | {
"lang": "rust",
"repo": "KMJ192/rust",
"path": "/rust_grammar/error_handling/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mat(Some(1));
mat(None);
//mat(Some(0));
let f = File::open("text.txt");
let f = match f{
Ok(file) => file,
Err(ref error) if error.kind() == ErrorKind::NotFound => {
match File::create("text.txt"){
Ok(fc) => fc,
Err(e) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "KMJ192/rust",
"path": "/rust_grammar/error_handling/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/party/party_set_extra_text.rs
use language::operations::{make_param_doc, Operation, ParamInfo};
pub struct PartySetExtraTextOp;
const DOC : &str = "Allows to put extra text in party details popup. Used in Native to set status for villages o... | code_fim | medium | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/party/party_set_extra_text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct MarginOrderQuery {
pub symbol: String,
pub order_id: String,
pub orig_client_order_id: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct MarginOr... | code_fim | hard | {
"lang": "rust",
"repo": "0xA537FD/binance-rs-async",
"path": "/src/rest_model.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xA537FD/binance-rs-async path: /src/rest_model.rs
de(with = "string_or_float")]
pub qty: f64,
#[serde(skip)]
ignore: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Asks {
#[serde(with = "string_or_float")]
pub price: f64,
#[serde(with = "stri... | code_fim | hard | {
"lang": "rust",
"repo": "0xA537FD/binance-rs-async",
"path": "/src/rest_model.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// By default, buy
impl Default for OrderSide {
fn default() -> Self { Self::Buy }
}
/// Order types, the following restrictions apply
/// LIMIT_MAKER are LIMIT orders that will be rejected if they would immediately match and trade as a taker.
/// STOP_LOSS and TAKE_PROFIT will execute a MARKET orde... | code_fim | hard | {
"lang": "rust",
"repo": "0xA537FD/binance-rs-async",
"path": "/src/rest_model.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref cause) = self.cause {
return Some(cause.as_ref());
}
return None;
}
}
impl From<ReadlineError> for WrappedError {
fn from(err: ReadlineError) -> Self {
Self::with_cause("Readline Error!", Box::new(err))
}
}
impl From<io::Error> for ... | code_fim | hard | {
"lang": "rust",
"repo": "zaphar/nock-repl",
"path": "/src/errors.rs",
"mode": "spm",
"license": "Artistic-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaphar/nock-repl path: /src/errors.rs
//! errors implements common error types.
// Copyright (2017) Jeremy A. Wall.
//
// 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... | code_fim | hard | {
"lang": "rust",
"repo": "zaphar/nock-repl",
"path": "/src/errors.rs",
"mode": "psm",
"license": "Artistic-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zfrzhangfurui/rnest path: /rnest-di/tests/value.rs
use rnest_di::Di;
#[test]
fn test_value() {
let mut di = Di::new();
<|fim_suffix|> assert_eq!(hello_msg, "Hello bob".to_string());
assert_eq!(hi_msg, "Hi bob".to_string());
}<|fim_middle|> di.register_value("name", "bob".to_strin... | code_fim | hard | {
"lang": "rust",
"repo": "zfrzhangfurui/rnest",
"path": "/rnest-di/tests/value.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(hello_msg, "Hello bob".to_string());
assert_eq!(hi_msg, "Hi bob".to_string());
}<|fim_prefix|>// repo: zfrzhangfurui/rnest path: /rnest-di/tests/value.rs
use rnest_di::Di;
#[test]
fn test_value() {
let mut di = Di::new();
<|fim_middle|> di.register_value("name", "bob".to_strin... | code_fim | hard | {
"lang": "rust",
"repo": "zfrzhangfurui/rnest",
"path": "/rnest-di/tests/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etwyniel/raytracer path: /src/vec3.rs
use std::str::FromStr;
use std::ops::{Add, Sub, Mul, Neg};
pub trait Lerp {
fn lerp(&self, dst: Self, t: f64) -> Self
where Self: ::std::marker::Sized;
fn slerp(&self, dst: Self, t: f64) -> Self
where Self: ::std::marker::Sized {
... | code_fim | hard | {
"lang": "rust",
"repo": "etwyniel/raytracer",
"path": "/src/vec3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Vec3 {x: self.x - rhs.x, y: self.y - rhs.y, z: self.z - rhs.z}
}
}
impl<T> Mul for Vec3<T> where T: Mul<Output=T> {
type Output = Vec3<T>;
fn mul(self, rhs: Vec3<T>) -> Self {
Vec3 {x: self.x * rhs.x, y: self.y * rhs.y, z: self.z * rhs.z}
}
}
pub fn solve_quadratic(eq: &V... | code_fim | hard | {
"lang": "rust",
"repo": "etwyniel/raytracer",
"path": "/src/vec3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T, O> Neg for Vec3<T> where T: Neg<Output=O> {
type Output = Vec3<O>;
fn neg(self) -> Self::Output {
Vec3{x: -self.x, y: -self.y, z: -self.z}
}
}
impl<L, R, O> Mul<R> for Vec3<L> where L: Mul<R, Output=O>, R: Copy + PartialOrd {
type Output = Vec3<O>;
fn mul(self, rhs: R)... | code_fim | hard | {
"lang": "rust",
"repo": "etwyniel/raytracer",
"path": "/src/vec3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[derive(Clone, Debug, RustcDecodable)]
pub struct Contributor {
pub id: i64,
pub screen_name: String
}
impl cmp::Eq for Contributor { }
impl cmp::PartialEq for Contributor {
fn eq(&self, other: &Contributor) -> bool { self.id == other.id }
}
#[derive(Clone, Debug, RustcDecodable)]
pub st... | code_fim | hard | {
"lang": "rust",
"repo": "pwoolcoc/tweetust",
"path": "/src/models/tweets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, RustcDecodable)]
pub struct OEmbed {
pub cache_age: String,
pub url: String,
pub provider_url: String,
pub provider_name: String,
pub author_name: String,
pub version: String,
pub author_url: String,
pub type_: String,
pub html: String,
pub he... | code_fim | hard | {
"lang": "rust",
"repo": "pwoolcoc/tweetust",
"path": "/src/models/tweets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pwoolcoc/tweetust path: /src/models/tweets.rs
use std::cmp;
use std::collections::BTreeMap;
use super::entities::{Entities, ExtendedEntities};
use super::places::Place;
use super::users::User;
#[derive(Clone, Debug, RustcDecodable)]
pub struct Tweet {
pub contributors: Option<Vec<Contributo... | code_fim | hard | {
"lang": "rust",
"repo": "pwoolcoc/tweetust",
"path": "/src/models/tweets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clardeur/ihoover-rust path: /src/main.rs
extern crate itertools;
use itertools::Itertools;
use model::Hoover;
use std::path::Path;
<|fim_suffix|>fn main() {
let input = parser::parse_file(Path::new("E:\\Workspace\\ihoover-rust\\data\\input.txt"));
let mut hoover = Hoover::new(input.gri... | code_fim | easy | {
"lang": "rust",
"repo": "clardeur/ihoover-rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = parser::parse_file(Path::new("E:\\Workspace\\ihoover-rust\\data\\input.txt"));
let mut hoover = Hoover::new(input.grid, input.position);
println!("init {:?}", hoover);
println!("run commands {:?}", input.commands);
input.commands.iter().foreach(|cmd| hoover.execute(cmd));
... | code_fim | easy | {
"lang": "rust",
"repo": "clardeur/ihoover-rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/solkit path: /src/bin/solkit/opts.rs
use std::env;
use std::process::exit;
use getopts::{Matches, Options};
const APP_NAME: &str = "Solitaire Kit";
// Options passed via commnd-line
pub(crate) struct CliOpts {
pub(crate) dark: bool,
pub(crate) filename: String,
pub(crate) ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/solkit",
"path": "/src/bin/solkit/opts.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let matches: Matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(e) => {
eprintln!("{}", e);
print_usage(&program, &opts);
exit(0);
}
};
if matches.opt_present("version") {
let version = env!("CARGO_PKG_VERSION");
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/solkit",
"path": "/src/bin/solkit/opts.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: povilasb/netsim path: /src/wire/ether.rs
use priv_prelude::*;
use future_utils;
#[derive(Clone, PartialEq)]
/// Represents an ethernet frame.
pub struct EtherFrame {
buffer: Bytes,
}
impl fmt::Debug for EtherFrame {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let pay... | code_fim | hard | {
"lang": "rust",
"repo": "povilasb/netsim",
"path": "/src/wire/ether.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the frame's sender MAC address.
pub fn source_mac(&self) -> MacAddr {
MacAddr::from_bytes(&self.buffer[6..12])
}
/// Get the frame's destination MAC address.
pub fn dest_mac(&self) -> MacAddr {
MacAddr::from_bytes(&self.buffer[0..6])
}
/// Get the fram... | code_fim | hard | {
"lang": "rust",
"repo": "povilasb/netsim",
"path": "/src/wire/ether.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Construct a new ethernet frame from the given buffer.
pub fn from_bytes(buffer: Bytes) -> EtherFrame {
EtherFrame {
buffer,
}
}
/// Get the frame's sender MAC address.
pub fn source_mac(&self) -> MacAddr {
MacAddr::from_bytes(&self.buffer[6..12]... | code_fim | hard | {
"lang": "rust",
"repo": "povilasb/netsim",
"path": "/src/wire/ether.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moziliar/duke_rust path: /src/common/msg.rs
pub static WELCOME_MESSAGE: &str = "Hello! I'm Duke\nWhat can I do for you?";
pub static INVALID_INPUT_MESSAGE: &str = "Sorry, invalid input.";
pub static BYE_MESSAGE: &str = "Bye. Hope to see you again soon!";
pub static NO_TASK_MESSAGE: &str = "Curre... | code_fim | medium | {
"lang": "rust",
"repo": "moziliar/duke_rust",
"path": "/src/common/msg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>GE: &str = "Index given is out of bound! Please try again!";
pub static REMOVED_MESSAGE: &str = "Noted. I've removed this task:";<|fim_prefix|>// repo: moziliar/duke_rust path: /src/common/msg.rs
pub static WELCOME_MESSAGE: &str = "Hello! I'm Duke\nWhat can I do for you?";
pub static INVALID_INPUT_MESSAG... | code_fim | hard | {
"lang": "rust",
"repo": "moziliar/duke_rust",
"path": "/src/common/msg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>no task available.";
pub static DONE_MESSAGE: &str = "Nice! I've marked this task as done: ";
pub static INDEX_OUT_OF_BOUND_MESSAGE: &str = "Index given is out of bound! Please try again!";
pub static REMOVED_MESSAGE: &str = "Noted. I've removed this task:";<|fim_prefix|>// repo: moziliar/duke_rust path:... | code_fim | medium | {
"lang": "rust",
"repo": "moziliar/duke_rust",
"path": "/src/common/msg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while !self.queue.is_empty() {
let amounts = self.queue[self.queue.len() - 1]
.get_products()
.iter()
.map(|&p| p.clone())
.collect();
self.result.append(&mut try_ready!(
ProductAmountGroupFutu... | code_fim | hard | {
"lang": "rust",
"repo": "vlopes11/store-terminal",
"path": "/src/cart/fut.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.result.append(&mut try_ready!(
ProductAmountGroupFuture::new(amounts).poll()
));
self.queue.pop();
}
Ok(Async::Ready(try_ready!(ProductAmountGroupFuture::new(
(*self.result).to_vec()
)
.poll())))
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "vlopes11/store-terminal",
"path": "/src/cart/fut.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vlopes11/store-terminal path: /src/cart/fut.rs
use crate::prelude::{
Cart, CartItem, CartItemProduct, ErrorVariant, ProductAmount, ProductAmountGroupFuture,
};
use futures::prelude::*;
use futures::try_ready;
pub struct CartGroupFuture {
queue: Vec<Box<dyn CartItem>>,
result: Vec<Pr... | code_fim | hard | {
"lang": "rust",
"repo": "vlopes11/store-terminal",
"path": "/src/cart/fut.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
K: Eq + Hash + std::fmt::Debug,
F: Fn(&A) -> K,
G: Fn(&A) -> HashSet<K>,
{
// very simple (warning: n^2) topological sort (_not_ tarjan)
// keeps popping items out of a vec in passes until it makes a whole pass without
// popping any off, in this case where we cannot make pro... | code_fim | hard | {
"lang": "rust",
"repo": "edwardgeorge/avocado-build-helper",
"path": "/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edwardgeorge/avocado-build-helper path: /src/types.rs
use serde::{Deserialize, Serialize};
use serde_json::{from_reader, Value};
use std::collections::{BinaryHeap, HashSet};
use std::fs::File;
use std::hash::Hash;
use std::path::Path;
use std::vec::Vec;
use thiserror::Error;
#[derive(Debug, Err... | code_fim | hard | {
"lang": "rust",
"repo": "edwardgeorge/avocado-build-helper",
"path": "/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.rs
// aux-build:const-stability-attribute-implies.rs
#![crate_type = "lib"]
<|fim_suffix|>extern crate const_stability_attribute_implies;
use const_stability_attribute_implies::{foo, foobar};
pub co... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern crate const_stability_attribute_implies;
use const_stability_attribute_implies::{foo, foobar};
pub const fn bar() -> u32 {
foo(); // no error - stable
foobar(); //~ ERROR `foobar` is not yet stable as a const fn
0
}
pub const VAR: u32 = bar();<|fim_prefix|>// repo: rust-lang/rust pat... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut assoc = std::collections::HashMap::new();
assoc.insert("hoge".to_string(), yojson_rs::value::Value::Null);
assoc.insert("fuga".to_string(), yojson_rs::value::Value::Null);
assert_eq!(
yojson_rs::parser::parse(r#"{hoge : null, "fuga": null}"#),
Ok(yojson_rs::value::Value... | code_fim | medium | {
"lang": "rust",
"repo": "puripuri2100/yojson-rs",
"path": "/tests/null.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: puripuri2100/yojson-rs path: /tests/null.rs
extern crate yojson_rs;
#[cfg(test)]
mod tests {
#[test]
fn check_null() {
let mut assoc = std::collections::HashMap::new();
assoc.insert("hoge".to_string(), yojson_rs::value::Value::Null);
assert_eq!(
yojson_rs::parser::parse("{... | code_fim | hard | {
"lang": "rust",
"repo": "puripuri2100/yojson-rs",
"path": "/tests/null.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justanotherdot/ray-tracer path: /rust/src/bin/circle_demo.rs
use ray_tracer::canvas::Canvas;
use ray_tracer::color::Color;
use ray_tracer::coordinate::Point;
use ray_tracer::ppm::Ppm;
use ray_tracer::ray::{Ray, Sphere};
use ray_tracer::transformation::Transformation;
use std::fs::File;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "justanotherdot/ray-tracer",
"path": "/rust/src/bin/circle_demo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ray_strike_color = Color::new(1., 1., 1.);
let mut s = Sphere::new(0);
s.set_transform(
Transformation::new()
.translate(0., 0.0, 0.)
//.scale(0.5, 1., 1.)
//.rotate_z(std::f64::consts::PI / 4.)
.build(),
);
let ray_origin = ... | code_fim | hard | {
"lang": "rust",
"repo": "justanotherdot/ray-tracer",
"path": "/rust/src/bin/circle_demo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mannerism/rustIntro path: /src/references.rs
#[allow(warnings)]
pub fn run() {
example1();
example2();
}
fn example1() {
let var_a = String::from("Howdy!");
// let mut var_b = &var_a; // Error: var_b doesn't own var_a
let var_b = &var_a;
let var_c = &var_a;
<|fim_suffix|> let va... | code_fim | medium | {
"lang": "rust",
"repo": "mannerism/rustIntro",
"path": "/src/references.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}, {}, {:?}", var_a, var_b, mass_data);
}
#[allow(warnings)]
fn heavy_calc(_param: &Vec<&String>) -> i64 {
//Some heavy duty calcs performed here that utilize available cores of my computer
14
}<|fim_prefix|>// repo: mannerism/rustIntro path: /src/references.rs
#[allow(warnings)]
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "mannerism/rustIntro",
"path": "/src/references.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kitech/qt.rs path: /src/widgets/qsizegrip.rs
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qsizegrip.h
// dst-file: /src/widgets/qsizegrip.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate li... | code_fim | hard | {
"lang": "rust",
"repo": "kitech/qt.rs",
"path": "/src/widgets/qsizegrip.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
// proto: const QMetaObject * QSizeGrip::metaObject();
impl<'a> /*trait*/ QSizeGrip_metaObject<QMetaObject> for () {
fn metaObject(self , rsthis: & QSizeGrip) -> QMetaObject {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK9QSizeGrip10metaObjectEv()};
let mut ret = un... | code_fim | hard | {
"lang": "rust",
"repo": "kitech/qt.rs",
"path": "/src/widgets/qsizegrip.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/advent-of-code-3 path: /crates/wasm/src/lib.rs
extern crate js_sys;
extern crate wasm_bindgen;
use advent_of_code::solve_raw;
#[cfg(feature = "visualization")]
use advent_of_code_painter::drawer::CommandBufferPainter;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsValue;
fn as_string... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/advent-of-code-3",
"path": "/crates/wasm/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen]
pub fn solve(
year: &JsValue,
day: &JsValue,
part: &JsValue,
input: &str,
) -> Result<String, JsValue> {
#[cfg(feature = "console-panic-hook")]
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
#[cfg(feature = "visualization")]
let painter = B... | code_fim | medium | {
"lang": "rust",
"repo": "iCodeIN/advent-of-code-3",
"path": "/crates/wasm/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rde_json::to_string(attribute).unwrap())
}<|fim_prefix|>// repo: stricaud/sightingdb path: /src/db_log.rs
use crate::attribute::Attribute;
pub fn l<|fim_middle|>og_attribute(path: &str, attribute: &Attribute) {
log::info!("{} | {}", path, se | code_fim | medium | {
"lang": "rust",
"repo": "stricaud/sightingdb",
"path": "/src/db_log.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stricaud/sightingdb path: /src/db_log.rs
use crate::attribute::Attribute;
pub fn l<|fim_suffix|>bute) {
log::info!("{} | {}", path, serde_json::to_string(attribute).unwrap())
}<|fim_middle|>og_attribute(path: &str, attribute: &Attri | code_fim | easy | {
"lang": "rust",
"repo": "stricaud/sightingdb",
"path": "/src/db_log.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stevepentland/cargo-benchcmp path: /src/benchmark.rs
use std::cmp;
use std::str::FromStr;
use prettytable::Row;
use regex::Regex;
/// Two sets of benchmarks that are comparable but haven't been paired up yet.
#[derive(Clone, Debug)]
pub struct Benchmarks {
old: Vec<Benchmark>,
new: Vec... | code_fim | hard | {
"lang": "rust",
"repo": "stevepentland/cargo-benchcmp",
"path": "/src/benchmark.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Comparison {
/// Convert this comparison to a formatted row useful for printing.
///
/// The columns of the row are as follows: the name of the benchmark being
/// compared, the old measurement, the new measurement, the measurement
/// difference and the percent measurement differ... | code_fim | hard | {
"lang": "rust",
"repo": "stevepentland/cargo-benchcmp",
"path": "/src/benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> left == left_reconstructed && right == right_reconstructed
}
fn missing_correct(left: Vec<usize>, right: Vec<usize>) -> bool {
let mut left = left;
let mut right = right;
left.sort();
right.sort();
... | code_fim | hard | {
"lang": "rust",
"repo": "stevepentland/cargo-benchcmp",
"path": "/src/benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Resolve using the package.json "main" or "browser" keys.
fn resolve_package_entry(
&self,
pkg_dir: &Path,
pkg_path: &Path,
) -> Result<Option<PathBuf>, Error> {
let _tracing = if cfg!(debug_assertions) {
Some(
tracing::span!(
... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_loader/src/resolvers/node.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = File::open(pkg_path)?;
let reader = BufReader::new(file);
let pkg: PackageJson = serde_json::from_reader(reader)
.context(format!("failed to deserialize {}", pkg_path.display()))?;
let main_fields = match self.target_env {
TargetEnv::Node... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_loader/src/resolvers/node.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_loader/src/resolvers/node.rs
t pkg = p.join(PACKAGE);
if pkg.is_file() {
return Some(p.to_path_buf());
}
parent = p.parent();
}
None
}
pub fn to_absolute_path(path: &Path) -> Result<PathBuf, Error> {
let abso... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_loader/src/resolvers/node.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let docs = self.db.get()?;
let mut order = Order::for_drink(order.drink_id, self.idgen.generate());
docs.save(&mut order)?;
debug!("Saved {:?}", order);
info!("Order placed: {}", order.meta.id);
Ok(order.meta.id)
}
}
impl<M: r2d2::ManageConnection<Connec... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/rustbucks",
"path": "/app/src/orders/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cstorey/rustbucks path: /app/src/orders/mod.rs
use anyhow::Result;
use log::*;
use r2d2::Pool;
use crate::{
barista::PrepareDrink,
menu::Drink,
services::{Commandable, Queryable, Request},
};
use infra::{
ids::{Id, IdGen},
persistence::{Storage, StoragePending},
};
mod mode... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/rustbucks",
"path": "/app/src/orders/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Eq, PartialEq)]
pub struct QueryOrder {
pub order_id: Id<Order>,
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct OrderStatus {
pub order_id: Id<Order>,
pub is_made: bool,
}
#[derive(Debug)]
pub struct Orders<M: r2d2::ManageConnection> {
db: Pool<M>,
idgen: I... | code_fim | hard | {
"lang": "rust",
"repo": "cstorey/rustbucks",
"path": "/app/src/orders/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add(self, other: Self) -> Self::Output {
match self {
Self::Integer(integer_1) => match other {
Self::Integer(integer_2) => integer_1
.add(integer_2)
.map(|(integer, operator)| (Self::Integer(integer), operator)),
... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zinc-compiler/src/semantic/element/constant/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prz23/zinc path: /zinc-compiler/src/semantic/element/constant/mod.rs
n and(self, other: Self) -> Result<(Self, GeneratorExpressionOperator), Error> {
match self {
Self::Boolean(constant_1) => match other {
Self::Boolean(constant_2) => Ok((
... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zinc-compiler/src/semantic/element/constant/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prz23/zinc path: /zinc-compiler/src/semantic/element/constant/mod.rs
od string;
pub mod structure;
pub mod tuple;
pub mod unit;
use std::fmt;
use std::ops::Add;
use std::ops::BitAnd;
use std::ops::BitOr;
use std::ops::BitXor;
use std::ops::Div;
use std::ops::Mul;
use std::ops::Neg;
use std::ops... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zinc-compiler/src/semantic/element/constant/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlgerber/pkmake path: /src/unit_tests/flavor_test.rs
use super::*;
#[test]
fn from_vanilla() {
let vans = vec!["^", "vanilla", "Vanilla", "VANILLA"];
for van in vans {
let result = Flavor::from_str(van);
assert_eq!(result.unwrap(), Flavor::Vanilla);
}
}
#[test]
fn f... | code_fim | hard | {
"lang": "rust",
"repo": "jlgerber/pkmake",
"path": "/src/unit_tests/flavor_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fails = vec!["1foo", "foo bar", "bla_&^^", "FOO_!@#$%^&*()"];
for fail in fails {
let result = Flavor::from_str(fail);
assert!(result.is_err());
}
}<|fim_prefix|>// repo: jlgerber/pkmake path: /src/unit_tests/flavor_test.rs
use super::*;
#[test]
fn from_vanilla() {
le... | code_fim | hard | {
"lang": "rust",
"repo": "jlgerber/pkmake",
"path": "/src/unit_tests/flavor_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vals = vec!["foo", "bar"];
for val in vals {
let result = Flavor::from(val).unwrap();
assert_eq!(result, Flavor::Named(val.to_string()));
}
assert_eq!(Flavor::from("^").unwrap(), Flavor::Vanilla);
assert_eq!(Flavor::from("Vanilla").unwrap(), Flavor::Vanilla);
}
#[te... | code_fim | hard | {
"lang": "rust",
"repo": "jlgerber/pkmake",
"path": "/src/unit_tests/flavor_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lu-zero/rust-code-analysis path: /src/macros.rs
#[macro_export]
macro_rules! mk_checker {
( $name:ident, $( $type:ident ),* ) => {
#[inline(always)]
#[allow(unused_variables)]
fn $name(node: &Node) -> bool {
let typ = node.kind_id();
false
... | code_fim | hard | {
"lang": "rust",
"repo": "lu-zero/rust-code-analysis",
"path": "/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl TSLanguage for $code {
type BaseLang = $camel;
fn get_lang() -> LANG {
LANG::$camel
}
fn get_language() -> Language {
unsafe { $name() }
}
fn get_lang... | code_fim | hard | {
"lang": "rust",
"repo": "lu-zero/rust-code-analysis",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hdlproject/rust-simple-webserver path: /src/covid19/presenter.rs
use actix_web::{web, get, HttpRequest, HttpResponse, Responder, Error};
use futures::future::{ready, Ready};
use serde::{Serialize, Deserialize};
use crate::config;
use crate::covid19::model::{Covid19Repo, Covid19Data};
<|fim_suf... | code_fim | hard | {
"lang": "rust",
"repo": "hdlproject/rust-simple-webserver",
"path": "/src/covid19/presenter.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.