text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: superdump/building-blocks path: /crates/building_blocks_core/src/axis.rs
use super::{Point3i, PointN};
/// Either the X or Y axis.
#[derive(Clone, Copy)]
pub enum Axis2 {
X = 0,
Y = 1,
}
impl Axis2 {
/// The index for a point's component on this axis.
pub fn index(&self) -> usi... | code_fim | hard | {
"lang": "rust",
"repo": "superdump/building-blocks",
"path": "/crates/building_blocks_core/src/axis.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Axis3Permutation {
pub fn even_with_normal_axis(axis: Axis3) -> Self {
match axis {
Axis3::X => Axis3Permutation::XYZ,
Axis3::Y => Axis3Permutation::YZX,
Axis3::Z => Axis3Permutation::ZXY,
}
}
pub fn odd_with_normal_axis(axis: Axis3) ->... | code_fim | hard | {
"lang": "rust",
"repo": "superdump/building-blocks",
"path": "/crates/building_blocks_core/src/axis.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn odd_with_normal_axis(axis: Axis3) -> Self {
match axis {
Axis3::X => Axis3Permutation::XZY,
Axis3::Y => Axis3Permutation::YXZ,
Axis3::Z => Axis3Permutation::ZYX,
}
}
pub fn sign(&self) -> i32 {
match self {
Axis3Pe... | code_fim | hard | {
"lang": "rust",
"repo": "superdump/building-blocks",
"path": "/crates/building_blocks_core/src/axis.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn object() {
unimplemented!();
}<|fim_prefix|>// repo: entropic-dev/dstopic path: /src/fetch.rs
use cacache;
use reqwest;
<|fim_middle|>pub async fn package() {
unimplemented!();
}
pub async fn version() {
unimplemented!();
}
| code_fim | medium | {
"lang": "rust",
"repo": "entropic-dev/dstopic",
"path": "/src/fetch.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: entropic-dev/dstopic path: /src/fetch.rs
use cacache;
use reqwest;
<|fim_suffix|>pub async fn version() {
unimplemented!();
}
pub async fn object() {
unimplemented!();
}<|fim_middle|>pub async fn package() {
unimplemented!();
}
| code_fim | easy | {
"lang": "rust",
"repo": "entropic-dev/dstopic",
"path": "/src/fetch.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vincent-Carrier/chestnut path: /uci/src/fen.rs
use crate::bridge::from_sq;
use base::piece::Piece;
use base::piece::PieceKind;
use base::moves::Side;
use base::piece::PieceKind::King;
use base::piece::PieceKind::Queen;
use base::prelude::*;
use vampirc_uci::UciFen;
pub fn uci_fen(state: &State)... | code_fim | hard | {
"lang": "rust",
"repo": "Vincent-Carrier/chestnut",
"path": "/uci/src/fen.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use base::prelude::*;
use super::*;
#[test]
fn fen_string_initial_state() {
assert_eq!(
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
fen_string(&State::new())
);
assert_eq!(
"rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQ... | code_fim | hard | {
"lang": "rust",
"repo": "Vincent-Carrier/chestnut",
"path": "/uci/src/fen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rights = &state.castling_rights;
// ITERATE THROUGH THE MAP TWICE!! LIVE LIKE THERE'S NO TOMORROW!!
if rights.iter().count() == 0 {
string.push('-');
} else {
for (&(color, side), &has_right) in rights.iter() {
if has_right {
let piece = Piece { kind: kind(side), color }... | code_fim | hard | {
"lang": "rust",
"repo": "Vincent-Carrier/chestnut",
"path": "/uci/src/fen.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmoak3/turbine path: /src/net/tcp_server.rs
extern crate rand;
extern crate crypto;
extern crate rustc_serialize;
extern crate postgres;
extern crate chrono;
// use std::os;
// use std::sync;
use std::net::{TcpListener, TcpStream};
use std::thread;
fn start_server(){
let listener = TcpList... | code_fim | hard | {
"lang": "rust",
"repo": "jmoak3/turbine",
"path": "/src/net/tcp_server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn connect_node(){
}
fn disconnect_node(){
}
fn check_timeout(){
}
fn connected_nodes(){
}<|fim_prefix|>// repo: jmoak3/turbine path: /src/net/tcp_server.rs
extern crate rand;
extern crate crypto;
extern crate rustc_serialize;
extern crate postgres;
extern crate chrono;
<|fim_middle|>// use st... | code_fim | hard | {
"lang": "rust",
"repo": "jmoak3/turbine",
"path": "/src/net/tcp_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/num-traits/tests/cast.rs
/
/
!
Tests
of
num_traits
:
:
cast
.
#
!
[
no_std
]
#
[
cfg
(
feature
=
"
std
"
)
]
#
[
macro_use
]
extern
crate
std
;
extern
crate
num_traits
;
use
num_traits
:
:
cast
:
:
*
;
use
num_traits
:
:
Bounded
;
use
core
:
:
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/num-traits/tests/cast.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>ax
+
1
)
)
;
}
Equal
=
>
{
assert_eq
!
(
Some
(
t
:
:
MAX
)
cast
:
:
<
f
t
>
(
f
:
:
MAX
)
)
;
}
Less
=
>
{
assert_eq
!
(
Some
(
f
:
:
MAX
as
t
)
cast
:
:
<
f
t
>
(
f
:
:
MAX
)
)
;
}
}
}
test_edge
(
)
;
}
)
+
}
}
#
[
test
]
fn
cast_int_to_int_edge_cases
(
)
{
use
core
:
:
cmp
:
:
Ordering
:
:
*
;
macro_ru... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/num-traits/tests/cast.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
pub fn test_whether_it_compiles() {}<|fim_prefix|>// repo: kellerkindt/asn1rs path: /tests/inner_tag_resolver.rs
use asn1rs::prelude::*;
asn_to_rust!(
"InnerEnumerated DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Other ::= SEQUENCE {
field INTEGER
}
SomeSeq ::= SEQU... | code_fim | easy | {
"lang": "rust",
"repo": "kellerkindt/asn1rs",
"path": "/tests/inner_tag_resolver.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kellerkindt/asn1rs path: /tests/inner_tag_resolver.rs
use asn1rs::prelude::*;
asn_to_rust!(
"InnerEnumerated DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Other ::= SEQUENCE {
field INTEGER
}
<|fim_suffix|> END"
);
#[test]
pub fn test_whether_it_compiles() {}<|fim_m... | code_fim | medium | {
"lang": "rust",
"repo": "kellerkindt/asn1rs",
"path": "/tests/inner_tag_resolver.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> END"
);
#[test]
pub fn test_whether_it_compiles() {}<|fim_prefix|>// repo: kellerkindt/asn1rs path: /tests/inner_tag_resolver.rs
use asn1rs::prelude::*;
asn_to_rust!(
"InnerEnumerated DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
<|fim_middle|> Other ::= SEQUENCE {
field INTEGER
... | code_fim | medium | {
"lang": "rust",
"repo": "kellerkindt/asn1rs",
"path": "/tests/inner_tag_resolver.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sitegui/scrawl path: /src/lib.rs
//! # Scrawl
//! A library for opening a file for editing in a text editor and capturing the result as a String
#![deny(
missing_docs,
missing_debug_implementations,
missing_copy_implementations,
trivial_casts,
trivial_numeric_casts,
unsta... | code_fim | hard | {
"lang": "rust",
"repo": "sitegui/scrawl",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// With opens a text buffer with the contents of the provided String in an editor. Returns a Result<String> with the edited contents.
///
/// # Example
/// ```no_run
/// # use scrawl::error::ScrawlError;
/// # fn main() -> Result<(), ScrawlError> {
/// let output = scrawl::with("Hello World!")?;
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "sitegui/scrawl",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn create_stream_config(
stream_type: &str,
default_config: &SupportedStreamConfig,
buffer_size: u32,
sample_rate: Option<SampleRate>,
) -> StreamConfig {
info!("Default {stream_type} stream config: {default_config:?}");
let buffer_size = match default_config.buffer_size() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Woyten/tune",
"path": "/microwave/src/audio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> stream_type: &str,
default_config: &SupportedStreamConfig,
buffer_size: u32,
sample_rate: Option<SampleRate>,
) -> StreamConfig {
info!("Default {stream_type} stream config: {default_config:?}");
let buffer_size = match default_config.buffer_size() {
SupportedBufferSize::Ra... | code_fim | hard | {
"lang": "rust",
"repo": "Woyten/tune",
"path": "/microwave/src/audio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Woyten/tune path: /microwave/src/audio.rs
use std::{iter, sync::Arc};
use chrono::Local;
use cpal::{
traits::{DeviceTrait, HostTrait, StreamTrait},
BufferSize, Device, FromSample, Sample, SampleFormat, SampleRate, SizedSample, Stream,
StreamConfig, SupportedBufferSize, SupportedStre... | code_fim | hard | {
"lang": "rust",
"repo": "Woyten/tune",
"path": "/microwave/src/audio.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Iterator for Tokenizer<'a> {
type Item = Token<'a>;
fn next(&mut self) -> Option<Self::Item> {
if self.separator_index >= self.separators.len() {
return Some(self.remainder);
}
let separator = self.separators[self.separator_index];
self.separato... | code_fim | hard | {
"lang": "rust",
"repo": "graysonarts/podlog",
"path": "/src/tokenize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: graysonarts/podlog path: /src/tokenize.rs
type Token<'a> = &'a str;
pub struct TokenResult<'a> {
pub token: Token<'a>,
pub remainder: &'a str,
}
#[derive(Debug)]
pub struct Tokenizer<'a> {
pub remainder: &'a str,
pub separators: &'static [char],
pub separator_index: usize,... | code_fim | hard | {
"lang": "rust",
"repo": "graysonarts/podlog",
"path": "/src/tokenize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(token.token)
}
}
pub fn next_token<'a>(data: &'a str, sep: char) -> TokenResult<'a> {
let v: Vec<&str> = data.splitn(2, sep).collect();
TokenResult {
token: v[0],
remainder: v[1],
}
}<|fim_prefix|>// repo: graysonarts/podlog path: /src/tokenize.rs
type Toke... | code_fim | hard | {
"lang": "rust",
"repo": "graysonarts/podlog",
"path": "/src/tokenize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if segment.start.1 == segment.end.1 {
for x in range(segment.start.0, segment.end.0) {
if inc_cell(&mut grid, Point(x, segment.start.1)) == 2 {
count_overlap += 1;
}
}
}
}
count_overlap
}
fn part2(segments: &Vec<Segment>) -> u64 {
let mut grid = Vec::<Vec<u8>>::new();
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "Hazurl/adventofcode",
"path": "/2021/src/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if a < b {
b - a
} else {
a - b
}
}
fn cell_from_abs_range(from: usize, to: usize, d: usize) -> usize {
if from < to {
from + d
} else {
from - d
}
}
fn part1(segments: &Vec<Segment>) -> u64 {
let mut grid = Vec::<Vec<u8>>::new();
let mut count_overlap = 0;
for segment in segments {
... | code_fim | hard | {
"lang": "rust",
"repo": "Hazurl/adventofcode",
"path": "/2021/src/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hazurl/adventofcode path: /2021/src/day5.rs
use crate::utility;
use itertools::*;
use std::slice::Iter;
use std::vec::Vec;
#[derive(Clone, Debug)]
struct Point(usize, usize);
#[derive(Clone, Debug)]
struct Segment {
start: Point,
end: Point,
}
fn parse_segment(str: &String) -> Segment {
le... | code_fim | hard | {
"lang": "rust",
"repo": "Hazurl/adventofcode",
"path": "/2021/src/day5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rcc.ahbenr.modify(|_, w| w.iopden().enabled());
rcc.ahbrstr.modify(|_, w| w.iopdrst().set_bit());
rcc.ahbrstr.modify(|_, w| w.iopdrst().clear_bit());
}<|fim_prefix|>// repo: take44444/stm32f3discovery-7_seg_led path: /src/gpio.rs
use stm32f30x::RCC;
pub fn activate_gpioa() {
let rcc = un... | code_fim | hard | {
"lang": "rust",
"repo": "take44444/stm32f3discovery-7_seg_led",
"path": "/src/gpio.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: take44444/stm32f3discovery-7_seg_led path: /src/gpio.rs
use stm32f30x::RCC;
pub fn activate_gpioa() {
let rcc = unsafe { &*RCC::ptr() }; // 1073876992
<|fim_suffix|>pub fn activate_gpiod() {
let rcc = unsafe { &*RCC::ptr() }; // 1073876992
rcc.ahbenr.modify(|_, w| w.iopden().enabl... | code_fim | medium | {
"lang": "rust",
"repo": "take44444/stm32f3discovery-7_seg_led",
"path": "/src/gpio.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wwposkernel/OperatingSystem path: /src/lib/src/ia_32e/paging/mod.rs
///! 提供了内存分页功能
mod page;
mod page_table;<|fim_suffix|>eTableEntry, PageTable, ENTRY_COUNT};
pub use page_ops::{PageOffset, PageIndex};<|fim_middle|>
mod page_ops;
pub use page_table::{Pag | code_fim | easy | {
"lang": "rust",
"repo": "wwposkernel/OperatingSystem",
"path": "/src/lib/src/ia_32e/paging/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>eTableEntry, PageTable, ENTRY_COUNT};
pub use page_ops::{PageOffset, PageIndex};<|fim_prefix|>// repo: wwposkernel/OperatingSystem path: /src/lib/src/ia_32e/paging/mod.rs
///! 提供了内存分页功能
mod page;
mod page_table;<|fim_middle|>
mod page_ops;
pub use page_table::{Pag | code_fim | easy | {
"lang": "rust",
"repo": "wwposkernel/OperatingSystem",
"path": "/src/lib/src/ia_32e/paging/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Keats/validator path: /validator_derive/src/lit.rs
use quote::quote;
use validator_types::ValueOrPath;
pub fn lit_to_string(lit: &syn::Lit) -> Option<String> {
match *lit {
syn::Lit::Str(ref s) => Some(s.value()),
_ => None,
}
}
pub fn lit_to_int(lit: &syn::Lit) -> Opti... | code_fim | hard | {
"lang": "rust",
"repo": "Keats/validator",
"path": "/validator_derive/src/lit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn option_to_tokens<T: quote::ToTokens>(opt: &Option<T>) -> proc_macro2::TokenStream {
match opt {
Some(ref t) => quote!(::std::option::Option::Some(#t)),
None => quote!(::std::option::Option::None),
}
}
pub fn value_or_path_to_tokens<T>(value: &ValueOrPath<T>) -> proc_macro2:... | code_fim | hard | {
"lang": "rust",
"repo": "Keats/validator",
"path": "/validator_derive/src/lit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut manifest = FlowManifest::new(test_meta_data());
for function in functions {
manifest.add_function(function);
}
manifest
}
fn test_submission(functions: Vec<RuntimeFunction>) -> Submission {
Submission::new(
test_manifest(func... | code_fim | hard | {
"lang": "rust",
"repo": "andrewdavidmackenzie/flow",
"path": "/flowr/src/lib/checks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewdavidmackenzie/flow path: /flowr/src/lib/checks.rs
use error_chain::bail;
use log::error;
use flowcore::errors::Result;
use flowcore::model::runtime_function::RuntimeFunction;
use crate::block::Block;
use crate::run_state::{RunState, State};
fn runtime_error(state: &RunState, job_id: us... | code_fim | hard | {
"lang": "rust",
"repo": "andrewdavidmackenzie/flow",
"path": "/flowr/src/lib/checks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Elena-Qiu/InferSim path: /src/utils/mod.rs
pub mod app_config;
mod batcher;
mod box_iter;
mod error;
pub mod float;
pub mod logging;
pub mod panic;
pub mod prelude {
// for now `use super as utils` does not work
pub use super::super::utils;
<|fim_suffix|>pub use batcher::Batcher;
pub u... | code_fim | medium | {
"lang": "rust",
"repo": "Elena-Qiu/InferSim",
"path": "/src/utils/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use batcher::Batcher;
pub use box_iter::{BoxIterator, IntoBoxIter};<|fim_prefix|>// repo: Elena-Qiu/InferSim path: /src/utils/mod.rs
pub mod app_config;
mod batcher;
mod box_iter;
mod error;
pub mod float;
pub mod logging;
pub mod panic;
<|fim_middle|>pub mod prelude {
// for now `use super as u... | code_fim | hard | {
"lang": "rust",
"repo": "Elena-Qiu/InferSim",
"path": "/src/utils/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Getters
#[inline]
pub fn correlation_id(&self) -> i64 {
unsafe { (*self.flyweight.m_struct).correlation_id }
}
#[inline]
pub fn channel_status_indicator_id(&self) -> i32 {
unsafe { (*self.flyweight.m_struct).channel_status_indicator_id }
}
}<|fim_prefix|>//... | code_fim | medium | {
"lang": "rust",
"repo": "UnitedTraders/aeron-rs",
"path": "/src/command/subscription_ready_flyweight.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UnitedTraders/aeron-rs path: /src/command/subscription_ready_flyweight.rs
/*
* Copyright 2020 UT OVERSEAS INC
*
* 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": "UnitedTraders/aeron-rs",
"path": "/src/command/subscription_ready_flyweight.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const SUBSCRIPTION_READY_LENGTH: Index = std::mem::size_of::<SubscriptionReadyDefn>() as Index;
pub(crate) struct SubscriptionReadyFlyweight {
flyweight: Flyweight<SubscriptionReadyDefn>,
}
impl SubscriptionReadyFlyweight {
pub fn new(buffer: AtomicBuffer, offset: Index) -> Self {
Se... | code_fim | hard | {
"lang": "rust",
"repo": "UnitedTraders/aeron-rs",
"path": "/src/command/subscription_ready_flyweight.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ikuz/camkes path: /apps/hellorust/components/main/src/run.rs
//
// Copyright 2018, Data61
// Commonwealth Scientific and Industrial Research Organisation (CSIRO)
// ABN 41 687 119 230.
//
// This software may be distributed and modified according to the terms of
// the BSD 2-Clause license. Note... | code_fim | medium | {
"lang": "rust",
"repo": "ikuz/camkes",
"path": "/apps/hellorust/components/main/src/run.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[panic_implementation]
#[no_mangle]
pub extern fn panic(_info: &PanicInfo) -> ! {
loop{}
}<|fim_prefix|>// repo: ikuz/camkes path: /apps/hellorust/components/main/src/run.rs
//
// Copyright 2018, Data61
// Commonwealth Scientific and Industrial Research Organisation (CSIRO)
// ABN 41 687 119 230.
//
/... | code_fim | hard | {
"lang": "rust",
"repo": "ikuz/camkes",
"path": "/apps/hellorust/components/main/src/run.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> AddNoteMsg::SubmitResponse(data) => {
log::info!("submitted, response code received {:?}", data);
true
}
AddNoteMsg::AddTag(tag_name) => {
log::info!("adding tag {:?}", tag_name);
self.tags.push(tag_name);... | code_fim | hard | {
"lang": "rust",
"repo": "infogulch/openmemex",
"path": "/frontend/src/add_note.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infogulch/openmemex path: /frontend/src/add_note.rs
use serde::{Deserialize, Serialize};
use serde_json::json;
use wasm_bindgen::prelude::*;
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::{
format::{Json, Nothing},
prelude::*,
utils::*,
};
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "infogulch/openmemex",
"path": "/frontend/src/add_note.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Struct representing an error, which implements the
/// [`Fail`](https://docs.rs/failure/0.1.1/failure/trait.Fail.html) trait
/// from [failure](https://github.com/rust-lang-nursery/failure)
#[derive(Fail, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Des... | code_fim | hard | {
"lang": "rust",
"repo": "tmcw/argonautica",
"path": "/argonautica-rs/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tmcw/argonautica path: /argonautica-rs/src/error.rs
use std::fmt;
use ErrorKind;
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"argonautica::Error {{ kind: argonautica::ErrorKind::{:?}, display: {:?} }}",
... | code_fim | hard | {
"lang": "rust",
"repo": "tmcw/argonautica",
"path": "/argonautica-rs/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_serialize::<Error>();
}
#[cfg(feature = "serde")]
#[test]
fn test_deserialize() {
use serde;
fn assert_deserialize<'de, T: serde::Deserialize<'de>>() {}
assert_deserialize::<Error>();
}
}<|fim_prefix|>// repo: tmcw/argonautica path: /argonautica... | code_fim | hard | {
"lang": "rust",
"repo": "tmcw/argonautica",
"path": "/argonautica-rs/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use path::*;
pub use scalar::*;
pub use ser::*;
pub use values::*;<|fim_prefix|>// repo: or17191/liquid-rust path: /liquid-value/src/lib.rs
//! Liquid Value type.
#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![warn(unused_extern_crates)]
#[macro_use]
extern crate serde;
extern cr... | code_fim | medium | {
"lang": "rust",
"repo": "or17191/liquid-rust",
"path": "/liquid-value/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Liquid Processing Errors.
pub mod error {
pub use liquid_error::*;
}
pub use path::*;
pub use scalar::*;
pub use ser::*;
pub use values::*;<|fim_prefix|>// repo: or17191/liquid-rust path: /liquid-value/src/lib.rs
//! Liquid Value type.
#![warn(missing_docs)]
#![warn(missing_debug_implementation... | code_fim | easy | {
"lang": "rust",
"repo": "or17191/liquid-rust",
"path": "/liquid-value/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: or17191/liquid-rust path: /liquid-value/src/lib.rs
//! Liquid Value type.
#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![warn(unused_extern_crates)]
<|fim_suffix|>pub mod map;
mod path;
mod scalar;
mod ser;
mod values;
/// Liquid Processing Errors.
pub mod error {
pub u... | code_fim | medium | {
"lang": "rust",
"repo": "or17191/liquid-rust",
"path": "/liquid-value/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_eg_animal_lifetime() {
let brahms = eg_animal_lifetime::Cat {name: String::from("Brahms"), age: 3, .. eg_animal_lifetime::Cat::new() };
let chopin = eg_animal_lifetime::Cat {name: String::from("Chopin"), age: 4, .. eg_animal_lifetime::Cat::new() };
let result = eg_animal_lifetime::oldes... | code_fim | medium | {
"lang": "rust",
"repo": "codetojoy/talk_peidevs_rust",
"path": "/src/rust/sandbox/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: codetojoy/talk_peidevs_rust path: /src/rust/sandbox/src/main.rs
/*
mod eg_lifetime;
fn run_eg_lifetime() {
let p = eg_lifetime::Person {name: String::from("Mozart"), birth_year: 1956, .. eg_lifetime::Person::new() };
let s = String::from("5150");
let t = String::from("Van Halen");
... | code_fim | medium | {
"lang": "rust",
"repo": "codetojoy/talk_peidevs_rust",
"path": "/src/rust/sandbox/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chenenjie/sample_rust path: /src/bin/highfunction1.rs
fn main() {
println!("3 + 1 = {}", process(3, inc));
println!("3 + 1 = {}", process(3, dec));
}
<|fim_suffix|>fn process<F>(n: i32, func: F) -> i32
where F: Fn(i32) -> i32{
func(n)
}<|fim_middle|>fn inc(n: i32) -> i32 {
... | code_fim | medium | {
"lang": "rust",
"repo": "chenenjie/sample_rust",
"path": "/src/bin/highfunction1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where F: Fn(i32) -> i32{
func(n)
}<|fim_prefix|>// repo: chenenjie/sample_rust path: /src/bin/highfunction1.rs
fn main() {
println!("3 + 1 = {}", process(3, inc));
println!("3 + 1 = {}", process(3, dec));
}
<|fim_middle|>
fn inc(n: i32) -> i32 {
n + 1
}
fn dec(n: i32) -> i32 {
n... | code_fim | medium | {
"lang": "rust",
"repo": "chenenjie/sample_rust",
"path": "/src/bin/highfunction1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Plugin for SQLPackage {
fn name(&self) -> &str {
PACKAGE_NAME
}
#[allow(unused_variables)]
fn load(&self, mgr: &mut PluginManager) -> Void {
void_ok
}
}<|fim_prefix|>// repo: lianhuiwang/tokamak path: /src/sql/lib.rs
extern crate common;
use common::err::{Void, void_ok};
use comm... | code_fim | medium | {
"lang": "rust",
"repo": "lianhuiwang/tokamak",
"path": "/src/sql/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lianhuiwang/tokamak path: /src/sql/lib.rs
extern crate common;
use common::err::{Void, void_ok};
use common::plugin::{Plugin, PluginManager};
const PACKAGE_NAME: &'static str = "sql";
pub struct SQLPackage;
impl Plugin for SQLPackage {
fn name(&self) -> &str {
<|fim_suffix|> #[allow(unuse... | code_fim | easy | {
"lang": "rust",
"repo": "lianhuiwang/tokamak",
"path": "/src/sql/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<::std::num::ParseFloatError> for Error {
fn from(error: ::std::num::ParseFloatError) -> Error {
Error::ParseFloatError(error)
}
}
impl From<::std::num::ParseIntError> for Error {
fn from(error: ::std::num::ParseIntError) -> Error {
Error::ParseIntError(error)
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "randomPoison/gunship-rs",
"path": "/lib/parse-obj/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: randomPoison/gunship-rs path: /lib/parse-obj/src/lib.rs
use std::path::Path;
use std::slice;
use std::str::FromStr;
pub type Point = (f32, f32, f32, f32);
pub type Vector3 = (f32, f32, f32);
/// A parsed OBJ file.
///
/// TODO: Add a specialized implementation for `Debug` that does a better jo... | code_fim | hard | {
"lang": "rust",
"repo": "randomPoison/gunship-rs",
"path": "/lib/parse-obj/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skpub/puzzle path: /src/board.rs
pub struct board(Vec<Vec<u8>>);
impl board {
pub fn<|fim_suffix|> Vec::with_capacity(n)
}
board(v)
}
}<|fim_middle|> init(n: usize) -> board {
let mut v = Vec::with_capacity(n);
for i in 0..n {
v[i] = | code_fim | medium | {
"lang": "rust",
"repo": "skpub/puzzle",
"path": "/src/board.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>capacity(n);
for i in 0..n {
v[i] = Vec::with_capacity(n)
}
board(v)
}
}<|fim_prefix|>// repo: skpub/puzzle path: /src/board.rs
pub struct board(Vec<Vec<u8>>);
impl board {
pub fn<|fim_middle|> init(n: usize) -> board {
let mut v = Vec::with_ | code_fim | easy | {
"lang": "rust",
"repo": "skpub/puzzle",
"path": "/src/board.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ils_avx2::*;
#[cfg(all(feature = "neon", target_arch = "aarch64"))]
pub use crate::unsafe_utils_neon::*;<|fim_prefix|>// repo: makepad/makepad path: /libs/zune-jpeg/src/unsafe_utils.rs
#[cfg(all(feature = "x86", any(target_arch = "x86",<|fim_middle|> target_arch = "x86_64")))]
pub use crate::unsafe_ut | code_fim | easy | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/libs/zune-jpeg/src/unsafe_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: makepad/makepad path: /libs/zune-jpeg/src/unsafe_utils.rs
#[cfg(all(feature = "x86", any(target_arch = "x86", target_arch = "x86_64")))]
pub use crate::unsafe_ut<|fim_suffix|> = "aarch64"))]
pub use crate::unsafe_utils_neon::*;<|fim_middle|>ils_avx2::*;
#[cfg(all(feature = "neon", target_arch | code_fim | easy | {
"lang": "rust",
"repo": "makepad/makepad",
"path": "/libs/zune-jpeg/src/unsafe_utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jhagans3/practical-machine-learning-with-rust path: /supervised-learning/src/bin/rustymachine-regression.rs
use rand::seq::SliceRandom;
use rand::thread_rng;
use rusty_machine;
use rusty_machine::analysis::score::neg_mean_squared_error;
use rusty_machine::learning::lin_reg::LinRegressor;
use rus... | code_fim | hard | {
"lang": "rust",
"repo": "jhagans3/practical-machine-learning-with-rust",
"path": "/supervised-learning/src/bin/rustymachine-regression.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run() -> Result<(), Box<dyn Error>> {
// Get all the data
let filename = "data/housing.csv";
let mut data = get_boston_records_from_file(&filename); // file must be in the folder data
// shuffle the data.
data.shuffle(&mut thread_rng());
// separate out to train and test d... | code_fim | hard | {
"lang": "rust",
"repo": "jhagans3/practical-machine-learning-with-rust",
"path": "/supervised-learning/src/bin/rustymachine-regression.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sherretten/Rust-HW2-RSA path: /src/lib.rs
use toy_rsa_lib::*;
use std::convert::{TryInto};
pub const EXP: u64 = 65_537;
pub fn genkey() -> (u32, u32) {
// let mut p: u32 = 0;
// let mut q: u32 = 0;
// let mut a: u64 = 0;
<|fim_suffix|>pub fn lambda(p: u32, q: u32) -> u64 {
lcm(... | code_fim | medium | {
"lang": "rust",
"repo": "sherretten/Rust-HW2-RSA",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn decrypt(key: (u32, u32), msg: u64) -> u32 {
let d: u64 = modinverse(EXP, lambda(key.0, key.1).into()); // inverse of lambda p,q mod E
let n: u64 = (key.0 as u64) * (key.1 as u64);
modexp(msg, d, n).try_into().expect("Overflow")
}<|fim_prefix|>// repo: sherretten/Rust-HW2-RSA path: /src... | code_fim | medium | {
"lang": "rust",
"repo": "sherretten/Rust-HW2-RSA",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn encrypt(key: u64, msg: u32) -> u64 {
modexp(msg as u64, EXP, key)
}
pub fn decrypt(key: (u32, u32), msg: u64) -> u32 {
let d: u64 = modinverse(EXP, lambda(key.0, key.1).into()); // inverse of lambda p,q mod E
let n: u64 = (key.0 as u64) * (key.1 as u64);
modexp(msg, d, n).try_into(... | code_fim | hard | {
"lang": "rust",
"repo": "sherretten/Rust-HW2-RSA",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etoledom/rust_practice path: /04_mortgage_calculator/src/main.rs
mod mortgage;
extern crate utilities;
fn main() {
let principal = utilities::read_number_input::read_float("principal: ");
let interest_rate = utilities::read_number_input::read_float("interest_r<|fim_suffix|>mortgage::cal... | code_fim | medium | {
"lang": "rust",
"repo": "etoledom/rust_practice",
"path": "/04_mortgage_calculator/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mortgage::calculate(principal, interest_rate, payments as i32);
println!("Mortgage: {}", result);
}<|fim_prefix|>// repo: etoledom/rust_practice path: /04_mortgage_calculator/src/main.rs
mod mortgage;
extern crate utilities;
fn main() {
let principal = utilities::read_number_input::read_float("p... | code_fim | medium | {
"lang": "rust",
"repo": "etoledom/rust_practice",
"path": "/04_mortgage_calculator/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DavidDevoogdt/BlackHoleSimulator path: /src/curved_space.rs
a[1], momenta[2], momenta[3]],
);
ret[0][0] = coordinates[0];
ret[1][0] = momenta[0];
for i in 1..4 {
ret[0][i] = coor[i - 1];
ret[1][i] = mom[i - 1];
}
ret
... | code_fim | hard | {
"lang": "rust",
"repo": "DavidDevoogdt/BlackHoleSimulator",
"path": "/src/curved_space.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_delta(&self, coor: &[f64; 4]) -> f64 {
coor[1].powi(2) - self.r_s * coor[1] + self.a.powi(2)
}
}
impl<'a> Metric<'a> for KerrMetric {
type SpecificSpaceObject = KerrObject<'a>;
fn g_lower(&self, x0: u8, x1: u8, coor: &[f64; 4]) -> f64 {
match (x0, x1) {
... | code_fim | hard | {
"lang": "rust",
"repo": "DavidDevoogdt/BlackHoleSimulator",
"path": "/src/curved_space.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DavidDevoogdt/BlackHoleSimulator path: /src/curved_space.rs
let mut_mom = self.get_mut_momenta_patch();
mut_mom[1] = mom[0];
mut_mom[2] = mom[1];
mut_mom[3] = mom[2];
self.coordinate_patch = (self.coordinate_patch + 1) % 2;
self.reset_killing_const... | code_fim | hard | {
"lang": "rust",
"repo": "DavidDevoogdt/BlackHoleSimulator",
"path": "/src/curved_space.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ption<std::string::String>,
) -> Self {
self.inner = self.inner.set_reaction_user_arn(input);
self
}
/// <p>An enumeration token that, when provided in a request, returns the next batch of the results. </p>
pub fn next_token(mut self, inp: impl Into<... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/codecommit/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>t_max_results(input);
self
}
}
#[derive(std::fmt::Debug)]
pub struct ListTagsForResource<
C = smithy_client::erase::DynConnector,
M = aws_hyper::AwsMiddleware,
R = smithy_client::retry::Standard,
> {
handle: std::sync::Arc<super::Handle<C... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/codecommit/src/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/codecommit/src/client.rs
handle,
inner: Default::default(),
}
}
pub async fn send(
self,
) -> std::result::Result<
crate::output::OverridePullRequestApprovalRulesOutput,
smith... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/codecommit/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrigofvc/threshold-accepting-tsp path: /src/heuristics/threshold_accepting.rs
use crate::heuristics::state::State as State;
/**
* Threshold Accepting for TSP.
* Return the best solution found.
*/
pub fn threshold_accepting(initial_state: State, iterations: u32, mut temperature: f64, decrement... | code_fim | hard | {
"lang": "rust",
"repo": "rodrigofvc/threshold-accepting-tsp",
"path": "/src/heuristics/threshold_accepting.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_batch(temperature: f64, initial: State, iterations: u32) -> (f64, State) {
let mut c : u32 = 0;
let mut r : f64 = 0.0;
let mut attemps = iterations * 2;
let mut current = initial;
while c < iterations && attemps > 0 {
let (neighbor, (i,j)) = current.get_neighbor();
... | code_fim | hard | {
"lang": "rust",
"repo": "rodrigofvc/threshold-accepting-tsp",
"path": "/src/heuristics/threshold_accepting.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewjensen/pact_elixir path: /native/pact_elixir_bindings/src/lib.rs
use libc::c_char;
use std::ffi::CStr;
use std::str;
#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
a + b
}
<|fim_suffix|> str_slice.to_string()
}
rustler::init!("Elixir.Pact", [add, greet, version]);<|fim_middle|>#... | code_fim | hard | {
"lang": "rust",
"repo": "andrewjensen/pact_elixir",
"path": "/native/pact_elixir_bindings/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rustler::init!("Elixir.Pact", [add, greet, version]);<|fim_prefix|>// repo: andrewjensen/pact_elixir path: /native/pact_elixir_bindings/src/lib.rs
use libc::c_char;
use std::ffi::CStr;
use std::str;
#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
a + b
}
#[rustler::nif]
fn greet(place: &str) -> Str... | code_fim | medium | {
"lang": "rust",
"repo": "andrewjensen/pact_elixir",
"path": "/native/pact_elixir_bindings/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> str_slice.to_string()
}
rustler::init!("Elixir.Pact", [add, greet, version]);<|fim_prefix|>// repo: andrewjensen/pact_elixir path: /native/pact_elixir_bindings/src/lib.rs
use libc::c_char;
use std::ffi::CStr;
use std::str;
#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
a + b
}
#[rustler::nif]... | code_fim | medium | {
"lang": "rust",
"repo": "andrewjensen/pact_elixir",
"path": "/native/pact_elixir_bindings/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: atuinsh/atuin path: /atuin-client/src/import/zsh_histdb.rs
// import old shell history from zsh-histdb!
// automatically hoover up all that we can find
// As far as i can tell there are no version numbers in the histdb sqlite DB, so we're going based
// on the schema from 2022-05-01
//
// I hav... | code_fim | hard | {
"lang": "rust",
"repo": "atuinsh/atuin",
"path": "/atuin-client/src/import/zsh_histdb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let imported = History::import()
.timestamp(DateTime::from_utc(histdb_item.start_time, Utc))
.command(
String::from_utf8(histdb_item.argv)
.unwrap_or_else(|_e| String::from(""))
.trim_end()
.to_stri... | code_fim | hard | {
"lang": "rust",
"repo": "atuinsh/atuin",
"path": "/atuin-client/src/import/zsh_histdb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn hist_from_db_conn(pool: Pool<sqlx::Sqlite>) -> Result<Vec<HistDbEntry>> {
let query = "select history.id,history.start_time,history.duration,places.host,places.dir,commands.argv from history left join commands on history.command_id = commands.rowid left join places on history.place_id = place... | code_fim | hard | {
"lang": "rust",
"repo": "atuinsh/atuin",
"path": "/atuin-client/src/import/zsh_histdb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // open newly saved image
let children: Vec<std::process::Child> = vec![
Command::new("xdg-open")
.arg(image_name)
.spawn()
.unwrap_or_else(|err| panic!("Unable to open {} image / {}", image_name, err)),
Command::new("xdg-open")
.arg(... | code_fim | hard | {
"lang": "rust",
"repo": "bergercookie/cv-detectors-rs",
"path": "/examples/detect.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bergercookie/cv-detectors-rs path: /examples/detect.rs
use cv_detectors::{FASTDetector, ImgCoords, KeypointDetector};
use image::open;
use std::env;
use std::process::Command;
use std::vec::Vec;
#[macro_use]
extern crate timeit;
pub fn main() {
let mut detector = FASTDetector::default();
... | code_fim | hard | {
"lang": "rust",
"repo": "bergercookie/cv-detectors-rs",
"path": "/examples/detect.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use HirRelationExpr::Get;
use HirScalarExpr::*;
match self {
Column(i) => write!(
f,
"#{}{}",
(0..i.level).map(|_| '^').collect::<String>(),
i.column
),
Parameter(i) => write!(f, "${... | code_fim | hard | {
"lang": "rust",
"repo": "nisarhassan12/materialize",
"path": "/src/sql/src/plan/explain/text.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for HirScalarExpr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use HirRelationExpr::Get;
use HirScalarExpr::*;
match self {
Column(i) => write!(
f,
"#{}{}",
(0..i.level).map(|_| '^').c... | code_fim | hard | {
"lang": "rust",
"repo": "nisarhassan12/materialize",
"path": "/src/sql/src/plan/explain/text.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/sql/src/plan/explain/text.rs
//! default, can be turned off with `WITH(raw_syntax)`).
use itertools::Itertools;
use std::fmt;
use mz_expr::virtual_syntax::{AlgExcept, Except};
use mz_expr::{Id, WindowFrame};
use mz_ore::str::{separated, IndentLike};
use ... | code_fim | hard | {
"lang": "rust",
"repo": "nisarhassan12/materialize",
"path": "/src/sql/src/plan/explain/text.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ZK-crypto
// TODO: ZK-crypto does not validate point is on the curve so we can only test it on valid bytes.
let mut data_array = [0u8; 96];
data_array.copy_from_slice(data);
let zkcrypto_g2 = G2Affine::from_compressed_unchecked(&data_array).unwrap();
asse... | code_fim | hard | {
"lang": "rust",
"repo": "kirk-baird/bls-fuzz",
"path": "/fuzz/fuzz_targets/fuzz_differential_serde_g2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kirk-baird/bls-fuzz path: /fuzz/fuzz_targets/fuzz_differential_serde_g2.rs
#![no_main]
use libfuzzer_sys::fuzz_target;
use milagro_bls::Signature as MilagroSignature;
use blst::min_pk::Signature as BlstSignature;
use bls12_381::G2Affine;
fuzz_target!(|data: &[u8]| {
// BLST
let blst_g2 ... | code_fim | hard | {
"lang": "rust",
"repo": "kirk-baird/bls-fuzz",
"path": "/fuzz/fuzz_targets/fuzz_differential_serde_g2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fangyi-zhou/advent-of-code-2019 path: /src/day2.rs
#[aoc_generator(day2)]
pub fn input_generator(input: &str) -> Vec<i32> {
input.split(',').map(|x| x.parse().unwrap()).collect()
}
fn set_mode(input: &mut [i32], noun: i32, verb: i32) {
input[1] = noun;
input[2] = verb;
}
fn set_pro... | code_fim | hard | {
"lang": "rust",
"repo": "fangyi-zhou/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day2, part1)]
pub fn solve_part1(input: &[i32]) -> i32 {
let mut input = input.to_owned();
set_program_alarm(input.as_mut());
run(input.as_mut())
}
#[aoc(day2, part2)]
pub fn solve_part2(input: &[i32]) -> i32 {
for noun in 0..99 {
for verb in 0..99 {
let mut work... | code_fim | hard | {
"lang": "rust",
"repo": "fangyi-zhou/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run(input: &mut [i32]) -> i32 {
let mut pc: usize = 0;
loop {
let opcode = input[pc];
match opcode {
1 | 2 => {
let operand1 = input[input[pc + 1] as usize];
let operand2 = input[input[pc + 2] as usize];
let dest = inpu... | code_fim | medium | {
"lang": "rust",
"repo": "fangyi-zhou/advent-of-code-2019",
"path": "/src/day2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, FromDao)]
pub struct Role {
pub role_name: String,
}<|fim_prefix|>// repo: weiznich/rustorm path: /src/db_auth/mod.rs
use chrono::{DateTime, Utc};
use rustorm_codegen::FromDao;
use serde::{Deserialize, Serialize};
<|fim_middle|>#[allow(unused)]
mod previlege;
... | code_fim | hard | {
"lang": "rust",
"repo": "weiznich/rustorm",
"path": "/src/db_auth/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: weiznich/rustorm path: /src/db_auth/mod.rs
use chrono::{DateTime, Utc};
use rustorm_codegen::FromDao;
use serde::{Deserialize, Serialize};
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize, FromDao)]
pub struct Role {
pub role_name: String,
}<|fim_middle|>#[allow(unused)]
mod previlege;
... | code_fim | hard | {
"lang": "rust",
"repo": "weiznich/rustorm",
"path": "/src/db_auth/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rogression::RatioProgressionTrait;
pub use set_effect::SetEffect;
pub use vector_affector::VectorAffectorF1;
pub use vector_affector::VectorAffectorF2;
pub use wait_affector::WaitAffector;<|fim_prefix|>// repo: jadestrong/pandadoodle-rust-wasm path: /src/engine/effect/mod.rs
pub mod chained_effect;
pub m... | code_fim | medium | {
"lang": "rust",
"repo": "jadestrong/pandadoodle-rust-wasm",
"path": "/src/engine/effect/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jadestrong/pandadoodle-rust-wasm path: /src/engine/effect/mod.rs
pub mod chained_effect;
pub mod effect;
pub mod effect_manager;
pub mod ratio_progression;
pub mod set_effect;
pub mod vector_affector;
pub mod wait_affector;
pub use chained_effect::Chai<|fim_suffix|>rogression::RatioProgressionT... | code_fim | hard | {
"lang": "rust",
"repo": "jadestrong/pandadoodle-rust-wasm",
"path": "/src/engine/effect/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_progression::ExpProgression;
pub use ratio_progression::ExpTransProgression;
pub use ratio_progression::LinearProgression;
pub use ratio_progression::QuadraticProgression;
pub use ratio_progression::RatioProgressionTrait;
pub use set_effect::SetEffect;
pub use vector_affector::VectorAffectorF1;
pub use v... | code_fim | medium | {
"lang": "rust",
"repo": "jadestrong/pandadoodle-rust-wasm",
"path": "/src/engine/effect/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skzitz/emu6502-rust path: /src/memory.rs
use core::fmt;
use std::fmt::Debug;
use crate::rom::ROM;
use crate::format_memory;
pub trait Memory {
fn get_address(&self, address: u16) -> u8;
fn set_address(&mut self, address: u16, byte: u8) -> bool;
}
/// Full memory space from 0 to 0xffff,... | code_fim | hard | {
"lang": "rust",
"repo": "skzitz/emu6502-rust",
"path": "/src/memory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn load_into_mem(&mut self, rom: &ROM, pc: u16) {
let mut pc = pc;
for rom_address in 0..rom.size {
self.memory[pc as usize] = rom.memory[rom_address as usize];
pc += 1;
}
}
}<|fim_prefix|>// repo: skzitz/emu6502-rust path: /src/memory.rs
use co... | code_fim | hard | {
"lang": "rust",
"repo": "skzitz/emu6502-rust",
"path": "/src/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = format_memory(&self.memory[0..(self.size as usize)], 24);
write!(f, "{}", s)
}
}
impl FullMemory {
pub fn new() -> FullMemory {
FullMemory {
memory: [0; 0x10000],
size: 0x0080,
}
}
pub fn load_into_mem(&mut self, rom: &ROM,... | code_fim | hard | {
"lang": "rust",
"repo": "skzitz/emu6502-rust",
"path": "/src/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.