text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: AndrewKvalheim/rust-exercises path: /rna-transcription/src/sequence.rs
use std::convert::{TryFrom, TryInto};
#[derive(Debug, PartialEq)]
pub struct Sequence<T>(pub Vec<T>);
impl<'a, T: 'a> Sequence<T> {
pub fn to_base<U: From<&'a T>>(&'a self) -> Sequence<U> {
Sequence(self.0.iter(... | code_fim | hard | {
"lang": "rust",
"repo": "AndrewKvalheim/rust-exercises",
"path": "/rna-transcription/src/sequence.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shourai/xidlehook path: /xidlehook-daemon/src/socket/models.rs
use std::{collections::BTreeSet, time::Duration};
use serde::{Deserialize, Serialize};
pub type TimerId = u16;
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum Filter {
All,
Selected(BTreeSet<TimerId>),... | code_fim | hard | {
"lang": "rust",
"repo": "Shourai/xidlehook",
"path": "/xidlehook-daemon/src/socket/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize, Serialize)]
pub struct Control {
#[serde(default)]
pub timer: Filter,
pub action: Action,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Query {
#[serde(default)]
pub timer: Filter,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type", r... | code_fim | hard | {
"lang": "rust",
"repo": "Shourai/xidlehook",
"path": "/xidlehook-daemon/src/socket/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum Message {
Add(Add),
Control(Control),
ResetIdle,
StopTimers,
Query(Query),
}
#[derive(Debug, Deserialize, Serialize)]
pub struct QueryResult {
pub timer: TimerId,
pub time: Durat... | code_fim | hard | {
"lang": "rust",
"repo": "Shourai/xidlehook",
"path": "/xidlehook-daemon/src/socket/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/sfv/src/test_serializer.rs
=
Item
:
:
with_params
(
17
.
into
(
)
item2_param
)
;
let
inner_list_item1_param
=
Parameters
:
:
from_iter
(
vec
!
[
(
"
in1_p
"
.
to_owned
(
)
BareItem
:
:
Boolean
(
false
)
)
]
)
;
let
inner_list_item1
=
Item
:
:... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/sfv/src/test_serializer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
.
clear
(
)
;
Serializer
:
:
serialize_string
(
"
"
&
mut
buf
)
?
;
assert_eq
!
(
"
\
"
\
"
"
&
buf
)
;
Ok
(
(
)
)
}
#
[
test
]
fn
serialize_string_errors
(
)
-
>
Result
<
(
)
Box
<
dyn
Error
>
>
{
let
mut
buf
=
String
:
:
new
(
)
;
assert_eq
!
(
Err
(
"
serialize_string
:
not
a
visible
character
"
)
Ser... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/sfv/src/test_serializer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
buf
)
?
;
assert_eq
!
(
"
*
a_fg
*
"
&
buf
)
;
buf
.
clear
(
)
;
Serializer
:
:
serialize_key
(
"
key1
"
&
mut
buf
)
?
;
assert_eq
!
(
"
key1
"
&
buf
)
;
buf
.
clear
(
)
;
Serializer
:
:
serialize_key
(
"
ke
-
y
.
1
"
&
mut
buf
)
?
;
assert_eq
!
(
"
ke
-
y
.
1
"
&
buf
)
;
Ok
(
(
)
)
}
#
[
test
]
fn
seria... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/sfv/src/test_serializer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_encoder_position(&self, hardtune_enabled: bool) -> i8 {
if !hardtune_enabled {
return match self.style {
PitchStyle::Narrow => self.knob_position * 2,
PitchStyle::Wide => self.knob_position,
};
}
(self.knob_pos... | code_fim | hard | {
"lang": "rust",
"repo": "GoXLR-on-Linux/goxlr-utility",
"path": "/profile/src/components/pitch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GoXLR-on-Linux/goxlr-utility path: /profile/src/components/pitch.rs
use std::collections::HashMap;
use std::io::Write;
use std::os::raw::c_float;
use enum_map::{Enum, EnumMap};
use strum::{EnumIter, EnumProperty, IntoEnumIterator};
use anyhow::{anyhow, Result};
use quick_xml::events::{BytesEnd... | code_fim | hard | {
"lang": "rust",
"repo": "GoXLR-on-Linux/goxlr-utility",
"path": "/profile/src/components/pitch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxbot/serenity.rs path: /src/model/misc.rs
use super::{
ChannelId,
Channel,
Emoji,
Member,
RoleId,
Role,
UserId,
User,
IncidentStatus,
EmojiIdentifier
};
use ::internal::prelude::*;
use std::str::FromStr;
use std::result::Result as StdResult;
use ::utils;... | code_fim | hard | {
"lang": "rust",
"repo": "foxbot/serenity.rs",
"path": "/src/model/misc.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> utils::parse_role(s).ok_or_else(|| ()).map(RoleId)
}
}
impl EmojiIdentifier {
/// Generates a URL to the emoji's image.
#[cfg(feature="methods")]
#[inline]
pub fn url(&self) -> String {
format!(cdn!("/emojis/{}.png"), self.id)
}
}
impl FromStr for EmojiIdentifier ... | code_fim | hard | {
"lang": "rust",
"repo": "foxbot/serenity.rs",
"path": "/src/model/misc.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FromStr for Instruction {
type Err = ParseInstructionError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
static MASK_RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"mask = ([0-9X]{36})").unwrap()
});
static MEM_RE: Lazy<Regex> = Lazy::new(|| {
... | code_fim | hard | {
"lang": "rust",
"repo": "sbaldwin621/adventofcode2020",
"path": "/day14/mask/src/program.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Error for ParseInstructionError { }
fn apply_mask(value: u64, high_mask: u64, low_mask: u64) -> u64 {
let high_masked = value | high_mask;
let masked = !(!high_masked | low_mask);
masked
}
#[cfg(test)]
mod tests {
use super::*;
// mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0... | code_fim | hard | {
"lang": "rust",
"repo": "sbaldwin621/adventofcode2020",
"path": "/day14/mask/src/program.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbaldwin621/adventofcode2020 path: /day14/mask/src/program.rs
use std::collections::HashMap;
use std::error::Error;
use std::fmt::Display;
use std::str::FromStr;
use once_cell::sync::Lazy;
use regex::Regex;
// mask = 0010011010X1000100X101011X10010X1010
// mem[57319] = 8001842
// mem[29943] = ... | code_fim | hard | {
"lang": "rust",
"repo": "sbaldwin621/adventofcode2020",
"path": "/day14/mask/src/program.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lol3rrr/free_access path: /free_access/src/allocator/pool.rs
//! This represents the Pool implementation for the Allocation-Pool
//!
//! # Strucure
//! The Pool consists of a doubly-linked List of Nodes, which will never be
//! deallocated to make sure that we never access a removed Node.
//! In... | code_fim | hard | {
"lang": "rust",
"repo": "Lol3rrr/free_access",
"path": "/free_access/src/allocator/pool.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let data_ptr = current.data.get() as *mut T;
unsafe { data_ptr.write(data) };
current.phase.store(phase, atomic::Ordering::Release);
current
.state
.store(State::Set.to_u8(), a... | code_fim | hard | {
"lang": "rust",
"repo": "Lol3rrr/free_access",
"path": "/free_access/src/allocator/pool.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match fork() {
Ok(ForkResult::Parent { child, .. }) => {
println!("Parent: Child has pid: {}", child);
}
Ok(ForkResult::Child) => {
let stdout_fd = stdout().as_raw_fd();
println!("Child: stdout fd is: {}", stdout_fd);
close(stdout... | code_fim | hard | {
"lang": "rust",
"repo": "swidoff/ostep-homework",
"path": "/cpu-api/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swidoff/ostep-homework path: /cpu-api/src/main.rs
use std::env;
use std::process::exit;
use std::thread::sleep;
use std::time::Duration;
use nix::fcntl::{OFlag, open};
use nix::sys::stat::Mode;
use nix::sys::wait::{waitpid, wait};
use nix::unistd::{fork, ForkResult, write, execv, close, pipe, ... | code_fim | hard | {
"lang": "rust",
"repo": "swidoff/ostep-homework",
"path": "/cpu-api/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn add_grade(&mut self, grade: f32){
self.grades.push(grade);
}
}
fn main() {
let mut student = Student { grades: vec![2., 3., 4.]};
let final_grade = match Some(student.mean()) {
Some(x) if x < 1.5 => Grade::One,
Some(x) if x < 2.5 => Grade::Two,
Some... | code_fim | hard | {
"lang": "rust",
"repo": "robertmmarek/rust-practice",
"path": "/chapter_4/task_4/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robertmmarek/rust-practice path: /chapter_4/task_4/src/main.rs
use std::vec;
#[derive(Debug)]
enum Grade{
One,
Two,
Three,
Four,
Five,
}
struct Student{
grades: vec::Vec<f32>
}
impl Student{
pub fn mean(&self) -> f32{
let mut ret = 0.0;
for el in s... | code_fim | medium | {
"lang": "rust",
"repo": "robertmmarek/rust-practice",
"path": "/chapter_4/task_4/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Orchaldir/rusted-arena path: /rusted-arena/src/game/rpg/check.rs
use mockall::*;
use rand::{thread_rng, RngCore};
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone, Debug, PartialEq)]
pub enum CheckResult {
Success(u32),
Failure(u32),
}
#[automock]
pub trait Checker {
fn chec... | code_fim | hard | {
"lang": "rust",
"repo": "Orchaldir/rusted-arena",
"path": "/rusted-arena/src/game/rpg/check.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unimplemented!();
}
#[inline]
fn try_fill_bytes(&mut self, _: &mut [u8]) -> Result<(), Error> {
unimplemented!();
}
}
#[test]
fn test() {
assert_check(0, 0, 1, 1, Success(0));
assert_check(1, 0, 1, 1, Success(1));
... | code_fim | hard | {
"lang": "rust",
"repo": "Orchaldir/rusted-arena",
"path": "/rusted-arena/src/game/rpg/check.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn main() {
//aotc_main::compile("experiment/mochijson.kernel.term");
aotc_main::compile("experiment/mochijson2.kernel.term");
// unsafe {
// // Set up a context, module and builder in that context.
// let mut cgen = Codegen::new();
// let m = cgen.new_module("erl_test");
//
// let f = ... | code_fim | medium | {
"lang": "rust",
"repo": "kvakvs/ErlangAoT",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvakvs/ErlangAoT path: /src/main.rs
//! Construct a function that does nothing in LLVM IR.
extern crate llvm_sys as llvm;
//use llvm::core as ll;
//use erl_aotc::codegen::Codegen;
extern crate erl_shared;
extern crate erl_aotc;
//extern crate erl_runtime;
<|fim_suffix|>// unsafe {
// // ... | code_fim | medium | {
"lang": "rust",
"repo": "kvakvs/ErlangAoT",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //aotc_main::compile("experiment/mochijson.kernel.term");
aotc_main::compile("experiment/mochijson2.kernel.term");
// unsafe {
// // Set up a context, module and builder in that context.
// let mut cgen = Codegen::new();
// let m = cgen.new_module("erl_test");
//
// let f = cgen.new_fun(... | code_fim | medium | {
"lang": "rust",
"repo": "kvakvs/ErlangAoT",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let uncommented_line = &self.trimmed_text[0..uncommented_line_len];
let mut index_in_uncommented_line = 0;
let elements = uncommented_line.split(constant::TAG_PREFIX);
for element in elements {
let token = element.trim_end();
if token.is_empty() {
... | code_fim | hard | {
"lang": "rust",
"repo": "mmitteregger/gherkin-rust",
"path": "/lib/src/line.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn ignores_empty_tag() {
assert!(get_line_tags("@").unwrap().is_empty(),);
}
#[test]
fn ignores_empty_tags() {
assert!(get_line_tags("@@").unwrap().is_empty(),);
}
#[test]
fn finds_tags_trim_whitespace() {
assert_eq!(
get_line_t... | code_fim | hard | {
"lang": "rust",
"repo": "mmitteregger/gherkin-rust",
"path": "/lib/src/line.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mmitteregger/gherkin-rust path: /lib/src/line.rs
use crate::constant;
use crate::{Error, Location, Result};
#[derive(Debug, Clone)]
pub struct Line {
text: String,
trimmed_text: String,
ident: u32,
line: u32,
}
#[derive(PartialEq, Eq, Hash, Debug, Clone)]
pub struct LineSpan {
... | code_fim | hard | {
"lang": "rust",
"repo": "mmitteregger/gherkin-rust",
"path": "/lib/src/line.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: felix-d/exercism path: /rust/raindrops/src/lib.rs
pub fn raindrops(drops: u32) -> String {
let mut result = String::new();
<|fim_suffix|> match result.as_ref() {
"" => drops.to_string(),
_ => result
}
}<|fim_middle|> if drops % 3 == 0 { result.push_str("Pling"); }
if drops % 5 =... | code_fim | medium | {
"lang": "rust",
"repo": "felix-d/exercism",
"path": "/rust/raindrops/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match result.as_ref() {
"" => drops.to_string(),
_ => result
}
}<|fim_prefix|>// repo: felix-d/exercism path: /rust/raindrops/src/lib.rs
pub fn raindrops(drops: u32) -> String {
let mut result = String::new();
<|fim_middle|> if drops % 3 == 0 { result.push_str("Pling"); }
if drops % 5 =... | code_fim | medium | {
"lang": "rust",
"repo": "felix-d/exercism",
"path": "/rust/raindrops/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matrix-org/matrix-rust-sdk path: /crates/matrix-sdk-crypto/src/types/events/secret_send.rs
// Copyright 2022 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtai... | code_fim | hard | {
"lang": "rust",
"repo": "matrix-org/matrix-rust-sdk",
"path": "/crates/matrix-sdk-crypto/src/types/events/secret_send.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.secret.zeroize();
}
}
impl Drop for SecretSendContent {
fn drop(&mut self) {
self.zeroize()
}
}
impl std::fmt::Debug for SecretSendContent {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SecretSendContent")
.... | code_fim | hard | {
"lang": "rust",
"repo": "matrix-org/matrix-rust-sdk",
"path": "/crates/matrix-sdk-crypto/src/types/events/secret_send.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nemo157/msgio-rs path: /src/codec.rs
use std::io::{self, Cursor};
use bytes::{BigEndian, Buf, BufMut, Bytes, BytesMut};
use varmint::{len_usize_varint, ReadVarInt, WriteVarInt};
use tokio_io::codec::{Decoder, Encoder};
#[derive(Copy, Clone, Debug)]
pub enum Prefix {
VarInt,
BigEndianU3... | code_fim | hard | {
"lang": "rust",
"repo": "Nemo157/msgio-rs",
"path": "/src/codec.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
let data_len = item.len() + self.1.len();
dst.reserve(data_len + self.0.encoded_len(data_len));
self.0.encode(data_len, dst)?;
dst.put(item);
self.1.encode(dst);
Ok((... | code_fim | hard | {
"lang": "rust",
"repo": "Nemo157/msgio-rs",
"path": "/src/codec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Prefix::VarInt => len_usize_varint(len),
Prefix::BigEndianU32 => 4,
}
}
}
impl Suffix {
fn len(self) -> usize {
match self {
Suffix::None => 0,
Suffix::NewLine => 1,
}
}
fn validate(self, src: &[... | code_fim | hard | {
"lang": "rust",
"repo": "Nemo157/msgio-rs",
"path": "/src/codec.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GGist/bip-rs path: /bip_peer/src/protocol/extension.rs
use std::io::{self, Write};
use bytes::Bytes;
use message::{ExtendedMessage, PeerExtensionProtocolMessage};
use protocol::{PeerProtocol, NestedPeerProtocol};
/// Protocol for `BEP 10` peer extensions.
pub struct PeerExtensionProtocol<P> {... | code_fim | hard | {
"lang": "rust",
"repo": "GGist/bip-rs",
"path": "/bip_peer/src/protocol/extension.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where W: Write {
match self.their_extended_msg {
Some(ref extended_msg) => PeerExtensionProtocolMessage::write_bytes(message, writer, extended_msg, &mut self.custom_protocol),
None => Err(io::Error::new(io::ErrorKind::Other, "Extension Message Sent... | code_fim | hard | {
"lang": "rust",
"repo": "GGist/bip-rs",
"path": "/bip_peer/src/protocol/extension.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> PeerExtensionProtocolMessage::<P>::bytes_needed(bytes)
}
fn parse_bytes(&mut self, bytes: Bytes) -> io::Result<Self::ProtocolMessage> {
match self.our_extended_msg {
Some(ref extended_msg) => PeerExtensionProtocolMessage::parse_bytes(bytes, extended_msg, &mut self.cust... | code_fim | hard | {
"lang": "rust",
"repo": "GGist/bip-rs",
"path": "/bip_peer/src/protocol/extension.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/* handle hardware interrupt */
fn interrupt(irq: IRQ)
{
match irq.cause
{
/* handle our scheduler's timer */
IRQCause::KernelTimer =>
{
scheduler::timer_irq();
},
_ => { klog!("Unhandled harwdare interrupt: {:?}", irq.cause) }
}
/* clea... | code_fim | hard | {
"lang": "rust",
"repo": "orb1t/diosix",
"path": "/src/kernel/irq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: orb1t/diosix path: /src/kernel/irq.rs
/* diosix machine kernel code for handling hardware interrupts and software exceptions
*
* (c) Chris Williams, 2018.
*
* See LICENSE for usage and copying.
*/
use scheduler;
/* platform-specific code must implement all this */
use platform;
use platfo... | code_fim | hard | {
"lang": "rust",
"repo": "orb1t/diosix",
"path": "/src/kernel/irq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: svmnotn/upgraded-pancake path: /server/src/test.rs
use crate::rocket;
use rocket::{http::ContentType, local::Client};
use upgraded_pancake::{Table, TableResult};
const SIMPLE_TEST_DATA: &str = include_str!("../../test_data/simple/value_single.json");
#[test]
fn can_add_table() {
let client... | code_fim | hard | {
"lang": "rust",
"repo": "svmnotn/upgraded-pancake",
"path": "/server/src/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut res = client
.put("/table/test")
.header(ContentType::JSON)
.body(include_str!("../../test_data/errors/range/duplicate.json"))
.dispatch();
let value = serde_json::from_str::<serde_json::Value>(
&res.body_string().expect("Failed to get a Body"),
... | code_fim | hard | {
"lang": "rust",
"repo": "svmnotn/upgraded-pancake",
"path": "/server/src/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SoaFloat2 {
pub fn min(&self, _b: &SoaFloat2) -> SoaFloat2 {
return SoaFloat2::load(SimdFloat4::min(&self.x, _b.x), SimdFloat4::min(&self.y, _b.y));
}
}
//--------------------------------------------------------------------------------------------------
impl SoaFloat4 {
// Return... | code_fim | hard | {
"lang": "rust",
"repo": "yangfengzzz/vox_render-rs",
"path": "/src/soa_float.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yangfengzzz/vox_render-rs path: /src/soa_float.rs
y: SimdFloat4::one(),
};
}
}
//--------------------------------------------------------------------------------------------------
#[derive(Clone, Copy)]
pub struct SoaFloat3 {
pub x: SimdFloat4,
pub y: SimdFloat4,
pu... | code_fim | hard | {
"lang": "rust",
"repo": "yangfengzzz/vox_render-rs",
"path": "/src/soa_float.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yangfengzzz/vox_render-rs path: /src/soa_float.rs
dInt4::and(&x, y);
}
#[inline]
pub fn eq(&self, other: &Self) -> SimdInt4 {
let x = SimdFloat4::cmp_eq(&self.x, other.x);
let y = SimdFloat4::cmp_eq(&self.y, other.y);
return SimdInt4::and(&x, y);
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "yangfengzzz/vox_render-rs",
"path": "/src/soa_float.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tremor-rs/tremor-runtime path: /tremor-script/src/std_lib/url.rs
// Copyright 2020-2021, The Tremor Team
//
// 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 | medium | {
"lang": "rust",
"repo": "tremor-rs/tremor-runtime",
"path": "/tremor-script/src/std_lib/url.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn shook_endecode_smoke_test() {
let d = fun("url", "decode");
let e = fun("url", "encode");
let v = Value::from("snot badger");
assert_val!(e(&[&v]), "snot%20badger");
let v = Value::from("%22snot%20badger%22");
assert_val!(d(&[&v]), r#""s... | code_fim | medium | {
"lang": "rust",
"repo": "tremor-rs/tremor-runtime",
"path": "/tremor-script/src/std_lib/url.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>dx,
if task.priority < 26 {
(b'A' + task.priority) as char
} else {
' '
},
task.subject
);
}
}<|fim_prefix|>// repo: elinorbgr/giskard path: /src/bin/giskard/commands/ls.rs
use giskard::TaskFile;
pub struct Args ... | code_fim | medium | {
"lang": "rust",
"repo": "elinorbgr/giskard",
"path": "/src/bin/giskard/commands/ls.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elinorbgr/giskard path: /src/bin/giskard/commands/ls.rs
use giskard::TaskFile;
pub struct Args {}
pub fn run(file: TaskFile, _args: Args) {
for (idx, task) in file.tasks() {
println!(
"{:>4} ({}) {}",
i<|fim_suffix|> } else {
' '
... | code_fim | medium | {
"lang": "rust",
"repo": "elinorbgr/giskard",
"path": "/src/bin/giskard/commands/ls.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.error()
}
}
#[test]
fn test_failing_mock_stream_read() {
let mut s = FailingMockStream::new(ErrorKind::BrokenPipe, "The dog ate the ethernet cable", 1);
let mut v = [0; 4];
let error = s.read(v.as_mut()).unwrap_err();
assert_eq!(error.kind(), ErrorKind::BrokenPipe);
a... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uu/od/src/mockstream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uutils/coreutils path: /src/uu/od/src/mockstream.rs
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// https://github.com/lazy-bitfield/rust-mockstream/pull/2
... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uu/od/src/mockstream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut c = Cursor::new(&b"abcd"[..])
.chain(FailingMockStream::new(
ErrorKind::Interrupted,
"Interrupted",
5,
))
.chain(Cursor::new(&b"ABCD"[..]));
let mut v = [0; 8];
c.read_exact(v.as_mut()).unwrap();
assert_eq!(v, [0x61, 0x62... | code_fim | hard | {
"lang": "rust",
"repo": "uutils/coreutils",
"path": "/src/uu/od/src/mockstream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_none_prices() {
let prices = vec![];
assert_eq!(max_profit(prices), 0);
}
#[test]
fn test_only_one_price() {
let prices = vec![42];
assert_eq!(max_profit(prices), 0);
}
#[test]
fn test_not_increased_again() {
let pri... | code_fim | hard | {
"lang": "rust",
"repo": "huangjj27/leetcode-SAO",
"path": "/src/problems/problem121.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: huangjj27/leetcode-SAO path: /src/problems/problem121.rs
/// # 121. Best Time to Buy and Sell Stock
///
/// Say you have an array for which the ith element is the price of
/// a given stock on day i. If you were only permitted to complete at most
/// one transaction (i.e., buy one and sell one s... | code_fim | medium | {
"lang": "rust",
"repo": "huangjj27/leetcode-SAO",
"path": "/src/problems/problem121.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: derrickbaldwin/euler-project path: /rust/problem_78/src/lib.rs
/*
Problem 78:
Let p(n) represent the number of different ways in which n coins can
be separated into piles. For example, five coins can be separated
into piles in exactly seven different ways, so p(5)=7.
OOOOO
OOOO ... | code_fim | medium | {
"lang": "rust",
"repo": "derrickbaldwin/euler-project",
"path": "/rust/problem_78/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn pent_positive(x: i64) -> usize {
let r = x * (3 * x - 1) / 2;
r as usize
}
fn pent_negative(x: i64) -> usize {
let r = - x * (3 * - x - 1) / 2;
r as usize
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: derric... | code_fim | hard | {
"lang": "rust",
"repo": "derrickbaldwin/euler-project",
"path": "/rust/problem_78/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error("Template not found at {:?}", _0)]
TemplateNotFoundAt(PathBuf),
}<|fim_prefix|>// repo: ascii-dresden/asciii path: /src/document_export/error.rs
use thiserror::Error;
use std::path::PathBuf;
<|fim_middle|>#[derive(Error, Debug)]
pub enum ExportError {
#[error("No PDF Created")]
... | code_fim | medium | {
"lang": "rust",
"repo": "ascii-dresden/asciii",
"path": "/src/document_export/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ascii-dresden/asciii path: /src/document_export/error.rs
use thiserror::Error;
use std::path::PathBuf;
#[derive(Error, Debug)]
pub enum ExportError {
#[error("No PDF Created")]
NoPdfCreated,
<|fim_suffix|> #[error("Template not found at {:?}", _0)]
TemplateNotFoundAt(PathBuf),
... | code_fim | easy | {
"lang": "rust",
"repo": "ascii-dresden/asciii",
"path": "/src/document_export/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let attributes = generate_attributes(r#"(source = "schema.xsd", log_level="error")"#);
assert_eq!(
XmlSchemaAttribute {
log_level: log::Level::Error,
module_namespace_mappings: BTreeMap::new(),
source: "schema.xsd".to_string(),
store_generated_code: None,
... | code_fim | hard | {
"lang": "rust",
"repo": "media-io/xml-schema",
"path": "/xml_schema_derive/src/attribute.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: media-io/xml-schema path: /xml_schema_derive/src/attribute.rs
use proc_macro2::{token_stream::IntoIter, Delimiter, TokenTree};
use std::collections::BTreeMap;
use syn::Attribute;
#[derive(Debug, PartialEq, Clone)]
pub struct XmlSchemaAttribute {
pub log_level: log::Level,
pub module_namespa... | code_fim | hard | {
"lang": "rust",
"repo": "media-io/xml-schema",
"path": "/xml_schema_derive/src/attribute.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: niranjan-nagaraju/Development path: /rust/leetcode/p56_merge_intervals/src/main.rs
/*
https://leetcode.com/problems/merge-intervals/
56. Merge Intervals
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping i... | code_fim | hard | {
"lang": "rust",
"repo": "niranjan-nagaraju/Development",
"path": "/rust/leetcode/p56_merge_intervals/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod basic_tests {
use super::*;
#[test]
fn basic_tests() {
assert_eq!(Solution::merge(vec![vec![1,3], vec![2,6], vec![8,10], vec![15,18]]), vec![vec![1,6], vec![8,10], vec![15,18]]);
assert_eq!(Solution::merge(vec![vec![15,18], vec![1,3], vec![2,6], vec![8,10]]), vec![vec!... | code_fim | hard | {
"lang": "rust",
"repo": "niranjan-nagaraju/Development",
"path": "/rust/leetcode/p56_merge_intervals/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("Run program!");
assert!( Solution::merge(vec![vec![1,4], vec![1,2]]) == vec![vec![1,4]] );
}
#[cfg(test)]
mod basic_tests {
use super::*;
#[test]
fn basic_tests() {
assert_eq!(Solution::merge(vec![vec![1,3], vec![2,6], vec![8,10], vec![15,18]]), vec![vec![1,6], v... | code_fim | hard | {
"lang": "rust",
"repo": "niranjan-nagaraju/Development",
"path": "/rust/leetcode/p56_merge_intervals/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn resolve_from_cwd_dot() {
let cwd = std::env::current_dir().unwrap();
assert_eq!(resolve_from_cwd(Path::new(".")).unwrap(), cwd);
}
#[test]
fn resolve_from_cwd_parent() {
let cwd = std::env::current_dir().unwrap();
assert_eq!(resolve_from_cwd(Path::new("a/..")).unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "yamalight/deno",
"path": "/cli/fs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yamalight/deno path: /cli/fs.rs
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use std;
use std::fs::{create_dir, DirBuilder, File, OpenOptions};
use std::io::ErrorKind;
use std::io::Write;
use std::path::{Path, PathBuf};
use deno_core::ErrBox;
use rand;
use rand::Rn... | code_fim | hard | {
"lang": "rust",
"repo": "yamalight/deno",
"path": "/cli/fs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!("set dir perm to {}", perm);
builder.mode(perm & 0o777);
}
#[cfg(not(any(unix)))]
fn set_dir_permission(_builder: &mut DirBuilder, _perm: u32) {
// NOOP on windows
}
pub fn normalize_path(path: &Path) -> String {
let s = String::from(path.to_str().unwrap());
if cfg!(windows) {
// TO... | code_fim | hard | {
"lang": "rust",
"repo": "yamalight/deno",
"path": "/cli/fs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut scale: f64 = 0.25;
let (center_x, center_y): (f64, f64) = get_center(scale);
let mut frame: Vec<Color> = iter::repeat_with(|| [255, 255, 255])
.take(HEIGHT * WIDTH)
.collect();
for i in 0..COUNT {
frame = (0..WIDTH * HEIGHT)
.into_par_iter()
.map(|a| {
if b... | code_fim | hard | {
"lang": "rust",
"repo": "pop123123123/fractal-renderer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pop123123123/fractal-renderer path: /src/main.rs
extern crate image;
extern crate itertools;
extern crate palette;
extern crate pbr;
extern crate rand;
extern crate rayon;
use palette::{Hsv, Srgb};
use std::sync::RwLock;
use crate::rayon::iter::*;
use pbr::ProgressBar;
use std::iter;
mod img;
... | code_fim | hard | {
"lang": "rust",
"repo": "pop123123123/fractal-renderer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.spi.write(&buf).map_err(Error::Comm)
}
fn send_bounded_data(
&mut self,
buf: &[u8],
disp_width: usize,
upper_left: (u8, u8),
lower_right: (u8, u8),
) -> Result<(), Self::Error> {
self.dc.set_high().map_err(Error::Pin)?;
// ... | code_fim | hard | {
"lang": "rust",
"repo": "jaxter184/ssd1306",
"path": "/src/interface/spi.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaxter184/ssd1306 path: /src/interface/spi.rs
//! SSD1306 SPI interface
use hal::{self, digital::v2::OutputPin};
use super::DisplayInterface;
use crate::Error;
// TODO: Add to prelude
/// SPI display interface.
///
/// This combines the SPI peripheral and a data/command pin
pub struct SpiInte... | code_fim | hard | {
"lang": "rust",
"repo": "jaxter184/ssd1306",
"path": "/src/interface/spi.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn deserialize<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error> where D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
match Utc.datetime_from_str(&s, FORMAT) {
Ok(v) => Ok(v),
Err(_) => Utc.datetime_from_str(&s, JS_FORMAT).... | code_fim | hard | {
"lang": "rust",
"repo": "X-Ryl669/rangepoll",
"path": "/src/poll.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn serialize<S>(date: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer,
{
let s = format!("{}", date.format(FORMAT));
serializer.serialize_str(&s)
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error> where D: Des... | code_fim | hard | {
"lang": "rust",
"repo": "X-Ryl669/rangepoll",
"path": "/src/poll.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: X-Ryl669/rangepoll path: /src/poll.rs
the French voting system, that is the choice counted per voters and vote, and only the 2 best choice are kept, then the other choice value are dispatched to compute the statistics and select the highest score
#[serde(rename = "french-system")]
F... | code_fim | hard | {
"lang": "rust",
"repo": "X-Ryl669/rangepoll",
"path": "/src/poll.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn play_multisink() {
println!("playing two sounds simultaneously through separate sinks...");
let device = rodio::default_output_device().unwrap();
let sink1 = Sink::new(&device);
let sink2 = Sink::new(&device);
sink1.append(make_noise(2.0, 0.1));
sleep_ms(500);
sink2.append(S... | code_fim | hard | {
"lang": "rust",
"repo": "mbillingr/rodio-playground",
"path": "/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbillingr/rodio-playground path: /src/main.rs
extern crate rand;
extern crate rodio;
use std::f32;
use std::time::Duration;
use std::thread::sleep_ms;
use rand::prelude::*;
use rodio::{
buffer::SamplesBuffer,
dynamic_mixer::mixer,
Sink,
Source,
source::SineWave,
Spatial... | code_fim | hard | {
"lang": "rust",
"repo": "mbillingr/rodio-playground",
"path": "/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nlpia/nnsplit path: /rust_lib/examples/cli.rs
use std::env;
fn main() -> failure::Fallible<()> {
<|fim_suffix|> let input: Vec<&str> = vec![&text]; // input can consist of multiple texts to allow parallelization
println!("{:#?}", splitter.split(input));
Ok(())
}<|fim_middle|> let... | code_fim | medium | {
"lang": "rust",
"repo": "nlpia/nnsplit",
"path": "/rust_lib/examples/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input: Vec<&str> = vec![&text]; // input can consist of multiple texts to allow parallelization
println!("{:#?}", splitter.split(input));
Ok(())
}<|fim_prefix|>// repo: nlpia/nnsplit path: /rust_lib/examples/cli.rs
use std::env;
fn main() -> failure::Fallible<()> {
let text = env::a... | code_fim | easy | {
"lang": "rust",
"repo": "nlpia/nnsplit",
"path": "/rust_lib/examples/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jnkforks/CallRecorder path: /lame_wrapper/src/lib.rs
mod lame;
#[cfg(target_os = "android")]
#[allow(non_snake_case)]
pub mod android {
use crate::lame::{self, lame_global_flags};
use jni::objects::{JByteBuffer, JClass};
use jni::sys::{jfloat, jint, jlong, jshort, jstring};
use... | code_fim | hard | {
"lang": "rust",
"repo": "jnkforks/CallRecorder",
"path": "/lame_wrapper/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> lame::lame_encode_buffer_ieee_float(
lame_t,
pcm_left,
pcm_right,
num_samples,
mp3_buffer,
mp3_buffer_size,
) as jint
}
#[no_mangle]
pub unsafe extern "system" fn Java_com_redridgeapps_mp3encoder_lame_Lame... | code_fim | hard | {
"lang": "rust",
"repo": "jnkforks/CallRecorder",
"path": "/lame_wrapper/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Convert from assigned extension type to i8.
pub fn from_i8(v: i8) -> Option<ExtType> {
match v {
-1 => Some(ExtType::Timestamp),
1 => Some(ExtType::Hash),
2 => Some(ExtType::Identity),
3 => Some(ExtType::Lockbox),
_ => Non... | code_fim | hard | {
"lang": "rust",
"repo": "Cognoscan/condense_db",
"path": "/src/ext_type.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cognoscan/condense_db path: /src/ext_type.rs
/// Defines the known Ext Types that this library relies on.
///
/// `Timestamp` is defined in the msgpack standard. The remainder are types used by this library
/// for encoding cryptographic data.
#[derive(Debug,PartialEq,Eq)]
pub enum ExtType {
... | code_fim | hard | {
"lang": "rust",
"repo": "Cognoscan/condense_db",
"path": "/src/ext_type.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lestofante/Kataster path: /src/laser.rs
use super::components::*;
use super::state::*;
use bevy::prelude::*;
use bevy_rapier2d::{
na::Vector2,
rapier::{
dynamics::{RigidBody, RigidBodyBuilder},
geometry::ColliderBuilder,
// math::Point,
},
};
<|fim_suf... | code_fim | hard | {
"lang": "rust",
"repo": "lestofante/Kataster",
"path": "/src/laser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn despawn_laser_system(
mut commands: Commands,
gamestate: Res<State<AppGameState>>,
time: Res<Time>,
mut query: Query<(Entity, &mut Laser)>,
) {
if gamestate.current() == &AppGameState::Game {
for (entity, mut laser) in query.iter_mut() {
laser.despawn_timer.t... | code_fim | hard | {
"lang": "rust",
"repo": "lestofante/Kataster",
"path": "/src/laser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stewe/MasterThesis_code path: /msg-lib/src/msg_json.rs
#![allow(dead_code)]
use rustc_serialize::{ Encodable, Decodable};
use rustc_serialize::json;
use {BoolMsg, BytesMsg, BytesVecMsg, CacheMsg, DecodeError, EncodeError, MsgPolicy, SubCacheMsg,
U32Msg, U8Msg};
use {get_time_in_millis, slic... | code_fim | hard | {
"lang": "rust",
"repo": "stewe/MasterThesis_code",
"path": "/msg-lib/src/msg_json.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn u32_msg(val: u32, topic: &str, msg_policy: MsgPolicy, key: Option<[u8;16]>, time: Option<u64>)
-> Result<Vec<u8>, EncodeError> {
let msg = U32Msg { val: val };
to_json(topic, &msg, None, msg_policy, key, time)
}
pub fn bytes_msg(val: Vec<u8>, topic: &str, msg_policy: MsgPolicy, key: Option... | code_fim | hard | {
"lang": "rust",
"repo": "stewe/MasterThesis_code",
"path": "/msg-lib/src/msg_json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn sub_cache_msg(number: Option<u32>, filters: Vec<Vec<u8>>, topic: &str, msg_policy: MsgPolicy, key: Option<[u8;16]>, time: Option<u64>)
-> Result<Vec<u8>, EncodeError> {
let msg = SubCacheMsg { number: number, filters: filters};
to_json(topic, &msg, None, msg_policy, key, time)
}
pub fn to_... | code_fim | hard | {
"lang": "rust",
"repo": "stewe/MasterThesis_code",
"path": "/msg-lib/src/msg_json.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pione30/twitter2-api path: /src/domain/service/user_service.rs
use crate::domain::model::{IUserRepository, User};
use crate::error::ServiceError;
use std::sync::Arc;
<|fim_suffix|> pub fn upsert<'a>(&self, sub_id: &'a str) -> Result<usize, ServiceError> {
self.user_repository
... | code_fim | hard | {
"lang": "rust",
"repo": "pione30/twitter2-api",
"path": "/src/domain/service/user_service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn upsert<'a>(&self, sub_id: &'a str) -> Result<usize, ServiceError> {
self.user_repository
.upsert(sub_id)
.map_err(ServiceError::DbQueryFailed)
}
}<|fim_prefix|>// repo: pione30/twitter2-api path: /src/domain/service/user_service.rs
use crate::domain::model::... | code_fim | medium | {
"lang": "rust",
"repo": "pione30/twitter2-api",
"path": "/src/domain/service/user_service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Field `TORSTEN` reader - Time Out Reset Enable Bit"]
pub struct TORSTEN_R(crate::FieldReader<bool, TORSTEN_A>);
impl TORSTEN_R {
pub(crate) fn new(bits: bool) -> Self {
TORSTEN_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated value... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/i2c0/i2c_bustctl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gsuyemoto/M031AE-rs path: /src/i2c0/i2c_bustctl.rs
Target {
&mut self.0
}
}
impl From<crate::W<I2C_BUSTCTL_SPEC>> for W {
#[inline(always)]
fn from(writer: crate::W<I2C_BUSTCTL_SPEC>) -> Self {
W(writer)
}
}
#[doc = "Bus Time Out Enable Bit\n\nValue on reset: 0"]
... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/i2c0/i2c_bustctl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gsuyemoto/M031AE-rs path: /src/i2c0/i2c_bustctl.rs
{
&self.0
}
}
impl core::ops::DerefMut for W {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl From<crate::W<I2C_BUSTCTL_SPEC>> for W {
#[inline(always)]
fn from(writ... | code_fim | hard | {
"lang": "rust",
"repo": "gsuyemoto/M031AE-rs",
"path": "/src/i2c0/i2c_bustctl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>me[start_frame + 2], frame[start_frame + 3]]);
let val = u16::from_be_bytes([frame[start_frame + 4], frame[start_frame + 5]]);
let result = context::set(reg, val, &mut context::CONTEXT.lock().unwrap().holdings);
if broadcast {
return None;
} else if result.is_er... | code_fim | hard | {
"lang": "rust",
"repo": "arbitrix/rmodbus",
"path": "/src/server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arbitrix/rmodbus path: /src/server.rs
#[path = "context.rs"]
pub mod context;
/// Standard Modbus frame
///
/// As max length of Modbus frame + headers is always 256 bytes or less, the frame is a fixed [u8;
/// 256] array.
pub type ModbusFrame = [u8; 256];
/// Modbus protocol selection for fra... | code_fim | hard | {
"lang": "rust",
"repo": "arbitrix/rmodbus",
"path": "/src/server.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PolySync/nvsdk_getter path: /src/sdkm_config.rs
use std::convert::TryFrom;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use crate::error::Error;
use crate::sdkm;
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SdkmConfig {
#[ser... | code_fim | medium | {
"lang": "rust",
"repo": "PolySync/nvsdk_getter",
"path": "/src/sdkm_config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl std::default::Default for SdkmConfig {
fn default() -> Self {
Self {
main_repo_url: MAIN_REPO_URL.clone(),
pid_server: "P".to_string(),
dev_zone_server: "P".to_string(),
}
}
}<|fim_prefix|>// repo: PolySync/nvsdk_getter path: /src/sdkm_conf... | code_fim | hard | {
"lang": "rust",
"repo": "PolySync/nvsdk_getter",
"path": "/src/sdkm_config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn try_from(path: &std::path::Path) -> std::result::Result<Self, Self::Error> {
serde_json::from_reader(std::io::BufReader::new(
std::fs::File::open(path).map_err(Self::Error::from)?,
))
.map_err(Self::Error::from)
}
}
lazy_static! {
// "mainRepoURL": "http... | code_fim | medium | {
"lang": "rust",
"repo": "PolySync/nvsdk_getter",
"path": "/src/sdkm_config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for channel in &mut channels {
match channel {
GuildChannel::Category(c) => {
c.guild_id.replace(id);
}
GuildChannel::NewsThread(c) => {
c.gui... | code_fim | hard | {
"lang": "rust",
"repo": "ce3tal/twilight",
"path": "/model/src/guild/mod.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ce3tal/twilight path: /model/src/guild/mod.rs
if large.is_some() {
return Err(DeError::duplicate_field("large"));
}
large = Some(map.next_value()?);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ce3tal/twilight",
"path": "/model/src/guild/mod.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ce3tal/twilight path: /model/src/guild/mod.rs
t_message_notification_level;
mod emoji;
mod explicit_content_filter;
mod info;
mod integration;
mod integration_account;
mod integration_application;
mod integration_expire_behavior;
mod mfa_level;
mod nsfw_level;
mod partial_guild;
mod partial_memb... | code_fim | hard | {
"lang": "rust",
"repo": "ce3tal/twilight",
"path": "/model/src/guild/mod.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let onerror_callback = Closure::wrap(Box::new(move |_| {
for subs in subscribers.clone(){
linkclone.clone().respond(subs, AgentOutput::ErrorConnecting)
}
}) as Box<dyn FnMut(JsValue)>);
let ws... | code_fim | hard | {
"lang": "rust",
"repo": "deep-gaurav/dcodefront",
"path": "/crate/src/socket_agent.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.