text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl<S> ServerTransport for SgxTrustedTlsTransport<S>
where
S: rustls::Session,
{
fn serve<U, V, X>(&mut self, service: X) -> Result<()>
where
U: Serialize + std::fmt::Debug,
V: for<'de> Deserialize<'de> + std::fmt::Debug,
X: TeaclaveService<V, U>,
{
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "z1queue/incubator-teaclave",
"path": "/rpc/src/transport.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shahin/nextbus path: /src/routes.rs
use client;
use error_chain::ChainedError;
use errors::*;
use serde_json;
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct Routes {
#[serde(rename = "route")]
pub routes: Vec<Route>,
}
#[derive(Serialize, Deserialize... | code_fim | medium | {
"lang": "rust",
"repo": "shahin/nextbus",
"path": "/src/routes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_routes(agency: String) -> Result<()> {
let routes = _get_routes(&agency)?;
let routes_json = serde_json::to_string(&routes).unwrap();
println!("{}", routes_json);
Ok(())
}
#[allow(dead_code)]
pub fn get_route_tags(agency: &String) -> Result<Vec<String>> {
let route_list = _... | code_fim | hard | {
"lang": "rust",
"repo": "shahin/nextbus",
"path": "/src/routes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehennes775/bbcmd path: /src/ebom_op/entry.rs
use crate::ebom_op::key::Key;
use crate::sch::complex::Complex;
use crate::refdes_op::refdes::Refdes;
use crate::scd::part::Part;
use crate::scd::drawing::Drawing;
use regex::Regex;
use std::fmt::{Debug, Formatter, Error};
/// Contains a line entry ... | code_fim | hard | {
"lang": "rust",
"repo": "ehennes775/bbcmd",
"path": "/src/ebom_op/entry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the filename of the specification control drawing (SCD)
pub fn scd(&self) -> &str
{
&self.key.scd()
}
/// Returns the value of the components in this entry, or an empty string if none
pub fn value(&self) -> &str
{
match &self.key.value
{
... | code_fim | hard | {
"lang": "rust",
"repo": "ehennes775/bbcmd",
"path": "/src/ebom_op/entry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut refdes_list = self.refdes().collect::<Vec<_>>();
refdes_list.sort();
let refdes_string = refdes_list.iter()
.map(|r| r.to_string())
.collect::<Vec<_>>()
.join(",");
writeln!(writer, " {}", &refdes_string)?;
for ... | code_fim | hard | {
"lang": "rust",
"repo": "ehennes775/bbcmd",
"path": "/src/ebom_op/entry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
squawk: self.squawk,
callsign: replace_if!(is_valid_callsign(&self.callsign), callsign),
is_on_ground: self.is_on_ground,
latitude: replace_if!(self.latitude == 0.0 && update_space, latitude),
longitude: replace_if!(self.longitude ... | code_fim | hard | {
"lang": "rust",
"repo": "sejo21/vrclivetraffic",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sejo21/vrclivetraffic path: /src/util.rs
use std::collections::HashMap;
use lazy_static::lazy_static;
use regex::Regex;
use crate::error::Error;
lazy_static! {
static ref AIRLINE_REGEX: Regex = Regex::new(r"([A-z]{3})\d+").unwrap();
static ref CALLSIGN_REGEX: Regex = Regex::new(r"[A-Z... | code_fim | hard | {
"lang": "rust",
"repo": "sejo21/vrclivetraffic",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AircraftData {
pub fn is_airline(&self) -> bool {
AIRLINE_REGEX.is_match(&self.callsign)
}
pub fn get_airline(&self) -> Option<&str> {
Some(AIRLINE_REGEX.captures(&self.callsign)?.get(1)?.as_str())
}
pub fn combine_with(self, rhs: Self) -> Self {
let upda... | code_fim | hard | {
"lang": "rust",
"repo": "sejo21/vrclivetraffic",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// `PrefabData` for loading control tags on an `Entity`
//
// Will always load a `FlyControlTag`
// #[derive(Debug, Default, Clone, Deserialize, Serialize)]
// pub struct ControlTagPrefab {
// /// Place `ArcBallControlTag` on the `Entity`
// pub arc_ball: Option<(usize, f32)>,
// }
//
// impl<'a> ... | code_fim | hard | {
"lang": "rust",
"repo": "Blisto91/amethyst",
"path": "/amethyst_controls/src/components.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Blisto91/amethyst path: /amethyst_controls/src/components.rs
use amethyst_core::ecs::*;
use derive_new::new;
use serde::{Deserialize, Serialize};
/// Add this to a camera if you want it to be a fly camera.
/// You need to add the FlyControlBundle or the required systems for it to work.
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "Blisto91/amethyst",
"path": "/amethyst_controls/src/components.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn display_at(&self, index: usize) -> Option<&Self::Out> {
self.get(index)
}
}
fn show_first(c: impl DisplayCollection) {
match c.display_at(0) {
Some(x) => println!("First: {}", x),
None => println!("Nothing :/"),
}
}
#[allow(clippy::needless_borrow)]
#[rustfmt::... | code_fim | medium | {
"lang": "rust",
"repo": "auto-impl-rs/auto_impl",
"path": "/examples/refs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: auto-impl-rs/auto_impl path: /examples/refs.rs
use std::fmt::Display;
use auto_impl::auto_impl;
/// This trait can be implemented for all reference or pointer types: &, &mut,
/// Box, Rc and Arc.
///
/// This attribute expands to the following impl (not exactly this code, but
/// equivalent, s... | code_fim | medium | {
"lang": "rust",
"repo": "auto-impl-rs/auto_impl",
"path": "/examples/refs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// TODO: CheckerHandle differs in purpose from NotifierHandle despite sharing a similar name, have
// a think about a better way to describe it.
/// Contains a [`JoinHandle`] to be awaited when starting the main loop for the application.
pub struct CheckerHandle {
pub join_handle: JoinHandle<()>,
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "ollyswanson/ruok",
"path": "/src/checker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ollyswanson/ruok path: /src/checker.rs
//! # Checker
//!
//! Periodically make an HTTP GET request to each [`Service`]. If the service responds with 200 OK
//! then the service is considered to be up, otherwise it is considered to be down. If the
//! [`Status`] of the service has changed then a ... | code_fim | hard | {
"lang": "rust",
"repo": "ollyswanson/ruok",
"path": "/src/checker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn run(&mut self) {
while let Some(msg) = self.receiver.recv().await {
match msg {
CheckerMsg::CheckService(name) => {
self.check_service(name);
}
}
}
}
fn check_service(&self, name: &'static str... | code_fim | hard | {
"lang": "rust",
"repo": "ollyswanson/ruok",
"path": "/src/checker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>= {
const MASK: bool = true;
const OFFSET: u8 = 24;
((self.bits >> OFFSET) & MASK as u32) != 0
};
MINPWR_DC_HALFCLKR { bits }
}
#[doc = "Bit 27 - Ajust delay to reduce ground noise"]
#[inline]
pub fn misc_delay_timing(&self) -> MISC_DELAY... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/dcdc/reg3/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/dcdc/reg3/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::REG3 {
#[doc = r" Modifies the contents of the register"]
#[inline]
... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/dcdc/reg3/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dancespiele/yew_assets path: /app/yew_assets/src/components/nav_assets.rs
use yew::prelude::*;
pub enum Msg {}
/// # NavAssets
///
/// Add a svg NavIcon
///
/// ## Feature
/// nav_assets
///
/// ## Example
/// ```rust
/// use yew::prelude::*;
/// use yew_assets::{NavAssets, NavIcon};
///
/// p... | code_fim | hard | {
"lang": "rust",
"repo": "dancespiele/yew_assets",
"path": "/app/yew_assets/src/components/nav_assets.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_externallink(
size: (String, String),
view_box: (String, String, String, String),
fill: String,
class_name: String,
id: String,
) -> Html {
html! {
<svg xmlns="http://www.w3.org/2000/svg" witdh=size.0 height=size.1 viewBox=format!("{} {} {} {}",
view_box.... | code_fim | hard | {
"lang": "rust",
"repo": "dancespiele/yew_assets",
"path": "/app/yew_assets/src/components/nav_assets.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qnighy/webp-rs-old path: /src/utils/thread_utils.rs
use std::os::raw::*;
#[allow(dead_code)]
#[allow(non_camel_case_types)]
#[repr(C)]
pub(crate) enum WebPWorkerStatus {
NOT_OK = 0, // object is unusable
OK, // ready to work
WORK, // busy finishing the current task
}
... | code_fim | medium | {
"lang": "rust",
"repo": "qnighy/webp-rs-old",
"path": "/src/utils/thread_utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
pub(crate) struct WebPWorker {
pub(crate) impl_: *mut c_void, // platform-dependent implementation worker details
pub(crate) status_: WebPWorkerStatus,
pub(crate) hook: WebPWorkerHook, // hook to call
pub(crate) data1: *mut c_void, // first argument passed to 'hook'
pub(cr... | code_fim | medium | {
"lang": "rust",
"repo": "qnighy/webp-rs-old",
"path": "/src/utils/thread_utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct ST7<T1, T2>(T1, T2);
impl ST7<i32, usize> {
fn ctor() -> Self {
Self(1, 2)
}
fn pattern(self) -> Self {
match self {
Self(x, y) => Self(x, y),
}
}
}
fn main() {
let v1 = ST1::ctor();
v1.pattern();
let v2 = ST2::ctor(10);
v2.pa... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ST6(1)
}
fn type_alias(self) {
let Self(_x) = match self { Self(x) => Self(x) };
let _opt: Option<Self> = Some(0).map(Self);
}
}
struct ST7<T1, T2>(T1, T2);
impl ST7<i32, usize> {
fn ctor() -> Self {
Self(1, 2)
}
fn pattern(self) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs
// run-pass
#![allow(dead_code)]
use std::fmt::Display;
struct ST1(i32, i32);
impl ST1 {
fn new() -> Self {
ST1(0, 1)
}
fn ctor() -> Self {
Self(1,2) // Self as a constru... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/rfcs/rfc-2302-self-struct-ctor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn v4(&self) -> Option<&Socket> {
match *self {
Sockets::V4(ref socket) => Some(socket),
Sockets::Both { ref v4, .. } => Some(v4),
Sockets::V6(_) => None,
}
}
fn v6(&self) -> Option<&Socket> {
match *self {
Sockets::V4(_)... | code_fim | hard | {
"lang": "rust",
"repo": "kingoflolz/tokio-ping",
"path": "/src/ping.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Receiver<Message> {
socket: Socket,
state: PingState,
buffer: [u8; 2048],
error_sender: mpsc::Sender<Error>,
_phantom: ::std::marker::PhantomData<Message>,
}
trait ParseReply {
fn reply_payload(data: &[u8]) -> Result<Option<&[u8]>, Error>;
}
impl ParseReply for IcmpV4 {
... | code_fim | hard | {
"lang": "rust",
"repo": "kingoflolz/tokio-ping",
"path": "/src/ping.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kingoflolz/tokio-ping path: /src/ping.rs
use std::io;
use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr};
use std::sync::Arc;
use std::time::{Instant, Duration};
use futures::{Async, Future, Poll, Stream};
use futures::sync::{oneshot, mpsc};
use rand::random;
use parking_lot::Mu... | code_fim | hard | {
"lang": "rust",
"repo": "kingoflolz/tokio-ping",
"path": "/src/ping.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.length * &self.width
}
fn volume(&self) -> f64 {
0.0
}
}
pub struct Sphere { pub radius: f64 }
impl Figure for Sphere {
fn area(&self) -> f64 {
0.0
}
fn volume(&self) -> f64 {
(std::f64::consts::PI * &self.radius.powf(3.0) * 4.0) / 3.0
}... | code_fim | medium | {
"lang": "rust",
"repo": "FedOken/rust_pr1",
"path": "/src/libs/geometry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FedOken/rust_pr1 path: /src/libs/geometry.rs
pub trait Figure {
fn area(&self) -> f64;
fn volume(&self) -> f64;
}
pub struct Circle { pub radius: f64 }
impl Figure for Circle {
fn area(&self) -> f64 {
std::f64::consts::PI * &self.radius.powf(2.0)
}
fn volume(&self) ... | code_fim | medium | {
"lang": "rust",
"repo": "FedOken/rust_pr1",
"path": "/src/libs/geometry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> false
}
fn view(&self) -> Html {
html! {
<div id = "header">
<h1>{ "RO Engine Config Browser" }</h1>
</div>
}
}
}<|fim_prefix|>// repo: al2me6/engine-config-browser path: /engine-config-browser/src/components/header.rs
use yew::... | code_fim | medium | {
"lang": "rust",
"repo": "al2me6/engine-config-browser",
"path": "/engine-config-browser/src/components/header.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: al2me6/engine-config-browser path: /engine-config-browser/src/components/header.rs
use yew::prelude::*;
pub struct Header {}
impl Component for Header {
type Message = ();
type Properties = ();
fn create(_props: Self::Properties, _link: ComponentLink<Self>) -> Self {
Heade... | code_fim | medium | {
"lang": "rust",
"repo": "al2me6/engine-config-browser",
"path": "/engine-config-browser/src/components/header.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Any state event stub (state event without a `room_id`, as returned in `/sync` responses)
pub type AnyStateEventStub = StateEventStub<AnyStateEventContent>;
/// Any stripped state event stub (stripped-down state event, as returned for rooms the user has
/// been invited to in `/sync` responses)
pub ty... | code_fim | hard | {
"lang": "rust",
"repo": "jmeyers35/ruma",
"path": "/ruma-events/src/enums.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmeyers35/ruma path: /ruma-events/src/enums.rs
use ruma_events_macros::event_content_enum;
use serde::{Deserialize, Serialize};
use crate::{
event_kinds::{
BasicEvent, EphemeralRoomEvent, MessageEvent, MessageEventStub, StateEvent, StateEventStub,
StrippedStateEventStub, ToD... | code_fim | hard | {
"lang": "rust",
"repo": "jmeyers35/ruma",
"path": "/ruma-events/src/enums.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kornelski/rust-rgb path: /src/internal/rgba.rs
use core::fmt;
use crate::alt::*;
use crate::RGB;
use crate::RGBA;
use super::pixel::*;
impl<T> RGBA<T> {
#[inline(always)]
/// Convenience function for creating a new pixel
/// The order of arguments is R,G,B,A
pub const fn new(r: ... | code_fim | hard | {
"lang": "rust",
"repo": "kornelski/rust-rgb",
"path": "/src/internal/rgba.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
r: other.r,
g: other.g,
b: other.b,
a: 0xFFFF,
}
}
}
}
}
impl<T, A> RGBA<T, A> {
/// Provide a mutable view of only RGB components (leaving out alpha).
//... | code_fim | hard | {
"lang": "rust",
"repo": "kornelski/rust-rgb",
"path": "/src/internal/rgba.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abonander/rust_dct path: /src/algorithm/type6and7_naive.rs
use rustfft::Length;
use ::{DCT6, DCT7, DST6, DST7, DCT6And7, DST6And7};
use common;
/// Naive O(n^2 ) DCT Type 6 and DCT Type 7 implementation
///
/// ~~~
/// // Computes a naive DCT6 and DCT7 of size 23
/// use rustdct::{DCT6, DCT7};... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/rust_dct",
"path": "/src/algorithm/type6and7_naive.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: common::DCTnum> DST6And7Naive<T> {
/// Creates a new DST6 and DST7 context that will process signals of length `len`
pub fn new(len: usize) -> Self {
let constant_factor = std::f64::consts::PI / (len * 2 + 1) as f64;
let twiddles: Vec<T> = (0..len*4 + 2)
.map(|... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/rust_dct",
"path": "/src/algorithm/type6and7_naive.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn cgroup_free(cgroup: *mut *mut CGroup);
fn cgroup_free_controllers(cgroup: *mut *mut CGroup);
}
#[derive(Debug)]
pub struct Controller {
controller: *mut CGroupController,
}
#[derive(Debug)]
pub struct Group<'a> {
name: &'a str,
cgroup: *mut CGroup,
}
impl<'a> Group<'a> {
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "rthomas/rust-cgroups",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rthomas/rust-cgroups path: /src/lib.rs
extern crate libc;
use std::ffi::CString;
use std::os::raw::c_char;
// libcgroup pointers.
enum CGroup {}
enum CGroupController {}
#[link(name = "cgroup")]
extern "C" {
fn cgroup_init() -> i32;
fn cgroup_new_cgroup(s: *const c_char) -> *mut CGrou... | code_fim | hard | {
"lang": "rust",
"repo": "rthomas/rust-cgroups",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Martins3/ACM path: /leetcode/0/58.rs
/**
* 1. add one space at the end
* 2. multiple space act like just one
*
*/
pub fn length_of_last_word(s: String) -> i32 {
let bytes = s.as_bytes();
let mut l = 0;
let mut r = 0;
let mut len = 0;
let mut last_is_space = true;
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "Martins3/ACM",
"path": "/leetcode/0/58.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn main() {
println!("{}", length_of_last_word("a".to_string()));
}<|fim_prefix|>// repo: Martins3/ACM path: /leetcode/0/58.rs
/**
* 1. add one space at the end
* 2. multiple space act like just one
*
*/
<|fim_middle|>pub fn length_of_last_word(s: String) -> i32 {
let bytes = s.as_bytes(... | code_fim | hard | {
"lang": "rust",
"repo": "Martins3/ACM",
"path": "/leetcode/0/58.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if r - l != 0{
r - l
}else{
len
}
}
pub fn main() {
println!("{}", length_of_last_word("a".to_string()));
}<|fim_prefix|>// repo: Martins3/ACM path: /leetcode/0/58.rs
/**
* 1. add one space at the end
* 2. multiple space act like just one
*
*/
<|fim_middle|>pub fn le... | code_fim | hard | {
"lang": "rust",
"repo": "Martins3/ACM",
"path": "/leetcode/0/58.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/num-traits/src/float.rs
fn mul_add(self, a: Self, b: Self) -> Self;
fn recip(self) -> Self;
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/num-traits/src/float.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn integer_decode(self) -> (u64, i16, i8) {
$decode(self)
}
#[inline]
fn fract(self) -> Self {
self - Float::trunc(self)
}
#[inline]
fn log(self, base: Self) -> Self {
self.ln() / base.ln()
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/num-traits/src/float.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/num-traits/src/float.rs
#[inline]
fn ceil(self) -> Self {
let f = self.fract();
if f.is_nan() || f.is_zero() {
self
} else if self > Self::zero() {
self - f + Self::one()
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-comments-removed",
"path": "/third_party/rust/num-traits/src/float.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magnesie/magnes-ie-orchestrateur path: /src/clusters/mod.rs
//! Contains the clusters manager as well as all the clusters implementations
pub mod clusters_manager;
pub use clusters_manager::*;
<|fim_suffix|>pub mod cluster_error;
pub use cluster_error::*;
pub mod local_photogrammetry;
pub use... | code_fim | easy | {
"lang": "rust",
"repo": "magnesie/magnes-ie-orchestrateur",
"path": "/src/clusters/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod local_photogrammetry;
pub use local_photogrammetry::*;
pub mod grid5000_struct;
pub use grid5000_struct::*;
pub mod grid5000;
pub use grid5000::*;<|fim_prefix|>// repo: magnesie/magnes-ie-orchestrateur path: /src/clusters/mod.rs
//! Contains the clusters manager as well as all the clusters impl... | code_fim | medium | {
"lang": "rust",
"repo": "magnesie/magnes-ie-orchestrateur",
"path": "/src/clusters/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod grid5000;
pub use grid5000::*;<|fim_prefix|>// repo: magnesie/magnes-ie-orchestrateur path: /src/clusters/mod.rs
//! Contains the clusters manager as well as all the clusters implementations
<|fim_middle|>pub mod clusters_manager;
pub use clusters_manager::*;
pub mod cluster;
pub use cluster::*... | code_fim | hard | {
"lang": "rust",
"repo": "magnesie/magnes-ie-orchestrateur",
"path": "/src/clusters/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type LeafHashParamsVar = <LeafHashGadget as CRHGadget<LeafHash, ConstraintF>>::ParametersVar;
pub type TwoToOneHashParamsVar =
<TwoToOneHashGadget as TwoToOneCRHGadget<TwoToOneHash, ConstraintF>>::ParametersVar;
pub type ConstraintF = ark_ed_on_bls12_381::Fq;<|fim_prefix|>// repo: mimoo/r1cs-tuto... | code_fim | hard | {
"lang": "rust",
"repo": "mimoo/r1cs-tutorial",
"path": "/merkle-tree-example/src/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mimoo/r1cs-tutorial path: /merkle-tree-example/src/common.rs
use ark_crypto_primitives::crh::constraints::{CRHGadget, TwoToOneCRHGadget};
use ark_crypto_primitives::crh::injective_map::constraints::{
PedersenCRHCompressorGadget, TECompressorGadget,
};
use ark_crypto_primitives::crh::{
in... | code_fim | hard | {
"lang": "rust",
"repo": "mimoo/r1cs-tutorial",
"path": "/merkle-tree-example/src/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrl00/urijudge_online path: /rusturi/beginner/uri1012/src/main.rs
use std::io::stdin;
static PI: f64 = 3.14159;
fn get_input() -> (f64, f64, f64) {
let mut lin = String::new();
stdin().read_line(&mut lin).expect("failed to read input");
let ans: Vec<f64> = lin
.split_whites... | code_fim | hard | {
"lang": "rust",
"repo": "mrl00/urijudge_online",
"path": "/rusturi/beginner/uri1012/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("QUADRADO: {:.3}", self.area())
}
}
struct Rectangle {
A: f64,
B: f64,
}
impl Area for Rectangle {
fn area(self) -> f64 {
self.A * self.B
}
fn show_area(self) {
println!("RETANGULO: {:.3}", self.area())
}
}
fn main() {
let (A, B, C) = ge... | code_fim | hard | {
"lang": "rust",
"repo": "mrl00/urijudge_online",
"path": "/rusturi/beginner/uri1012/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn show_area(self) {
println!("RETANGULO: {:.3}", self.area())
}
}
fn main() {
let (A, B, C) = get_input();
Triangle { A, C }.show_area();
Circle { C }.show_area();
Trapeze { A, B, C }.show_area();
Square { B }.show_area();
Rectangle { A, B }.show_area();
}<|fim_pr... | code_fim | hard | {
"lang": "rust",
"repo": "mrl00/urijudge_online",
"path": "/rusturi/beginner/uri1012/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> extern "C" fn get_identity_key_pair(
public_data: *mut SignalBufferPtr,
private_data: *mut SignalBufferPtr,
user_data: *mut c_void,
) -> c_int {
println!("get_identity_key_pair {:?} {:?}", public_data, private_data);
let data: Rc<TestStoreData> = unsafe { Rc... | code_fim | hard | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/support/libsignal-sys/src/session_builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 10allday-kai/api-daemon path: /support/libsignal-sys/src/session_builder.rs
if unsafe {
let p_k_p = match pre_key_public {
Some(key) => create_ec_public_key(&ctxt, key),
None => ::std::ptr::null_mut(),
};
let sp_k_p = cre... | code_fim | hard | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/support/libsignal-sys/src/session_builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 10allday-kai/api-daemon path: /support/libsignal-sys/src/session_builder.rs
nsafe {
let mut key_pair: KeyPairPtr = null_mut(); //ec_key_pair *key_pair;
let _result = curve_generate_key_pair(ctxt.native(), &mut key_pair);
let public_key = ec_key_pair_get_public(key_pair);... | code_fim | hard | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/support/libsignal-sys/src/session_builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
for x in l.iter() {
for c in 0..4 {
for i in 0..(7 - c * 2) {
// top
let _ = sense_hat.set_pixel(i + c, c, *x);
// bottom
let _ = sense_hat.set_pixel(7 - i - c, 7 - c, *x);... | code_fim | hard | {
"lang": "rust",
"repo": "CodeGradox/sensehat-rs",
"path": "/examples/spiral.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CodeGradox/sensehat-rs path: /examples/spiral.rs
extern crate sensehat;
use sensehat::*;
use std::time::Duration;
use std::thread::sleep;
fn main() {
<|fim_suffix|> let r = (255, 0, 0);
let g = (0, 255, 0);
let b = (0, 0, 255);
let w = (255, 255, 255);
let l = [... | code_fim | hard | {
"lang": "rust",
"repo": "CodeGradox/sensehat-rs",
"path": "/examples/spiral.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csmoe/crater path: /src/server/mod.rs
use arc_cell::ArcCell;
use config::Config;
use futures::{self, Future, Stream};
use futures_cpupool::CpuPool;
use handlebars::Handlebars;
use hyper::{self, Get, Post, StatusCode};
use hyper::header::{ContentLength, ContentType};
use hyper::server::{Http, Req... | code_fim | hard | {
"lang": "rust",
"repo": "csmoe/crater",
"path": "/src/server/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.router.recognize(req.path()) {
Ok(Match { handler, params }) => handler(self, req, params),
Err(_) => self.error(StatusCode::NotFound),
}
}
}
macro_rules! route {
($router:ident, $path:expr, $method:ident, $($handler:tt)* ) => (
$router.a... | code_fim | hard | {
"lang": "rust",
"repo": "csmoe/crater",
"path": "/src/server/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
fn main() {
let num1 : i32 = 1;
let num2 : i32 = 2;
let c = Container(num1, num2);
c.contains(&num1, &num2);
difference(c);
}<|fim_prefix|>// repo: arun11299/Rust-Practice path: /after_assoc_types.rs
// A container for two integers
struct Container(i32, i32);
trait Contains {
... | code_fim | hard | {
"lang": "rust",
"repo": "arun11299/Rust-Practice",
"path": "/after_assoc_types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arun11299/Rust-Practice path: /after_assoc_types.rs
// A container for two integers
struct Container(i32, i32);
trait Contains {
/// Define generic types which methods would be able to reuse
type A;
type B;
///
fn contains(&self, &Self::A, &Self::B) -> bool;
///
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "arun11299/Rust-Practice",
"path": "/after_assoc_types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Capture {
mouse: false,
keyboard: false,
}
}
}
type DefaultBar = Bar<i32>;
#[test]
fn test_lenses() {
let mut gui = Gui::new(NoDrawer, &mut ());
gui.insert_in_root_with_alias(Bar::<i32>::new(0), "abc".to_string());
gui.access("abc").chain(DefaultBar... | code_fim | hard | {
"lang": "rust",
"repo": "Ploppz/gui",
"path": "/gui/tests/derive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ploppz/gui path: /gui/tests/derive.rs
use gui::{lens::*, *};
/*
#[derive(LensInternal, Debug)]
struct Foo {
#[lens]
a: i32,
#[lens]
b: String,
}
impl Interactive for Foo {
fn captures(&self) -> Capture {
Capture {
mouse: false,
keyboard: false... | code_fim | medium | {
"lang": "rust",
"repo": "Ploppz/gui",
"path": "/gui/tests/derive.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Lens, Debug)]
pub struct Bar<T> {
#[lens]
a: i32,
#[lens]
b: String,
t: T,
}
impl<T> Bar<T> {
pub fn new(t: T) -> Self {
Bar {
a: 0,
b: "hey".into(),
t,
}
}
}
impl<T: Send + Sync + std::fmt::Debug + 'static> Interacti... | code_fim | medium | {
"lang": "rust",
"repo": "Ploppz/gui",
"path": "/gui/tests/derive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evaporei/design-patterns path: /structural/bridge/rust/src/main.rs
extern crate bridge;
use bridge::Shape;
use bridge::Circle;
use bridge::RedCircle;
use bridge::GreenCircle;
<|fim_suffix|> let red_circle = Circle::new(10, 100, 100, Box::new(RedCircle));
let green_circle = Circle::new(1... | code_fim | easy | {
"lang": "rust",
"repo": "evaporei/design-patterns",
"path": "/structural/bridge/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let red_circle = Circle::new(10, 100, 100, Box::new(RedCircle));
let green_circle = Circle::new(10, 100, 100, Box::new(GreenCircle));
red_circle.draw();
green_circle.draw();
}<|fim_prefix|>// repo: evaporei/design-patterns path: /structural/bridge/rust/src/main.rs
extern crate bridge;
u... | code_fim | easy | {
"lang": "rust",
"repo": "evaporei/design-patterns",
"path": "/structural/bridge/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0207_course_schedule/recursive_dfs_2.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::convert::TryInto;
impl Solution {
fn is_acyclic(graph: &[Vec<i3... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0207_course_schedule/recursive_dfs_2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> states[node as usize] = 1;
for &next in &graph[node as usize] {
let state = states[next as usize];
if if state == 0 {
!Self::is_acyclic(graph, next, states)
} else {
state == 1
} {
return fals... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0207_course_schedule/recursive_dfs_2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexanderkjall/adventofcode2020 path: /src/day7.rs
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::{alpha1, digit1};
use nom::combinator::map_res;
use nom::sequence::tuple;
use nom::IResult;
use petgraph::graph::DiGraph;
use petgraph::matrix_graph::NodeIndex;
u... | code_fim | hard | {
"lang": "rust",
"repo": "alexanderkjall/adventofcode2020",
"path": "/src/day7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(9, rules.len());
let (graph, nodes) = rules_to_graph(&rules);
let result_1 = calc_ways_to_colour("shiny gold", &graph, &nodes);
assert_eq!(4, result_1);
}
#[test]
fn test_part2() {
let input = "shiny gold bags contain 2 dark red bags.
dark red bags contain 2 dark orange b... | code_fim | hard | {
"lang": "rust",
"repo": "alexanderkjall/adventofcode2020",
"path": "/src/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rules
}
fn rules_to_graph(
rules: &HashMap<String, BagRule>,
) -> (DiGraph<String, u32>, HashMap<String, NodeIndex<u32>>) {
let mut ret = DiGraph::<String, u32>::new();
let mut nodes = HashMap::<String, NodeIndex<u32>>::new();
for rule in rules.values() {
if !nodes.contains_k... | code_fim | hard | {
"lang": "rust",
"repo": "alexanderkjall/adventofcode2020",
"path": "/src/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgottschlag/fernsprechapparat path: /src/gpio/mod.rs
//! Types for GPIO input/output.
use std::time::Duration;
#[allow(dead_code)]
pub mod sim;
pub mod sysfs;
/// Single GPIO input pin with support for interrupts.
pub trait InputPin {
/// Type of the corresponding output pin (see `InputPi... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/fernsprechapparat",
"path": "/src/gpio/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Waits for a pin value change interrupt or until a timeout expires.
///
/// The function either returns the number of the pin which triggered the
/// interrupt or `None` if the timeout expired.
fn wait_timeout(&self, timeout: Duration) -> Option<u64>;
/// Returns the number of p... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/fernsprechapparat",
"path": "/src/gpio/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/dyn-star/dispatch-on-pin-mut.rs
// run-pass
// edition:2021
// check-run-results
#![feature(dyn_star)]
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
<|fim_suffix|>async fn async_main() {
foo(Box::pin(a... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/dyn-star/dispatch-on-pin-mut.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let mut fut = async_main();
// Poll loop, just to test the future...
let waker = noop_waker();
let ctx = &mut Context::from_waker(&waker);
loop {
match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
Poll::Pending => {}
Poll::Ready(()) ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/dyn-star/dispatch-on-pin-mut.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/isle/isle/src/codegen.rs
"{}pub fn {}<C: Context>(",
&ctx.indent, sig.func_name
)?;
writeln!(ctx.out, "{} ctx: &mut C,", &ctx.indent)?;
for (i, &ty) in sig.param_tys.iter().enumerate() ... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/isle/isle/src/codegen.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ty in &self.typeenv.types {
match ty {
&Type::Enum {
name,
is_extern,
is_nodebug,
ref variants,
pos,
..
} if !is_extern => {
... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/isle/isle/src/codegen.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
ctx: &mut BodyContext<W>,
source: BindingId,
constraint: Constraint,
) -> std::fmt::Result {
if let Constraint::Variant { .. } = constraint {
if !ctx.is_ref.contains(&source) {
write!(ctx.out, "&")?;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "bytecodealliance/wasmtime",
"path": "/cranelift/isle/isle/src/codegen.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_cwnd(&mut self, cwnd: u32) {
self.cwnd = f64::from(cwnd);
}
fn increase(&mut self, m: &GenericCongAvoidMeasurements) {
// increase cwnd by 1 / cwnd per packet
self.cwnd += f64::from(self.mss) * (f64::from(m.acked) / self.cwnd);
}
fn reduction(&mut self,... | code_fim | medium | {
"lang": "rust",
"repo": "StanfordSNR/portus",
"path": "/ccp_generic_cong_avoid/src/reno.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: StanfordSNR/portus path: /ccp_generic_cong_avoid/src/reno.rs
use GenericCongAvoidAlg;
use GenericCongAvoidMeasurements;
pub struct Reno {
mss: u32,
init_cwnd: f64,
cwnd: f64,
}
impl GenericCongAvoidAlg for Reno {
fn name() -> String {
String::from("reno")
}
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "StanfordSNR/portus",
"path": "/ccp_generic_cong_avoid/src/reno.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nervosnetwork/ckb path: /error/src/util.rs
//! Error-related macros
/// Compare two errors.
///
/// NOTE: Used for testing only!
#[doc(hidden)]
#[macro_export]
macro_rules! assert_error_eq {
($left:expr, $right:expr) => {
assert_eq!(
Into::<$crate::Error>::into($left).to... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/error/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl $error_kind {
#[doc = $comment_because]
pub fn because<E>(self, reason: E) -> $error
where
E: ::std::error::Error + Send + Sync + 'static,
{
$error {
kind: self,
inner: reas... | code_fim | hard | {
"lang": "rust",
"repo": "nervosnetwork/ckb",
"path": "/error/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: roynalnaruto/core path: /crates/primitives/src/bytes/rlp.rs
use super::Bytes;
use alloy_rlp::{Decodable, Encodable};
impl Encodable for Bytes {
fn length(&self) -> usize {
<|fim_suffix|>impl Decodable for Bytes {
fn decode(buf: &mut &[u8]) -> Result<Self, alloy_rlp::DecodeError> {
... | code_fim | medium | {
"lang": "rust",
"repo": "roynalnaruto/core",
"path": "/crates/primitives/src/bytes/rlp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Decodable for Bytes {
fn decode(buf: &mut &[u8]) -> Result<Self, alloy_rlp::DecodeError> {
Ok(Self(bytes::Bytes::decode(buf)?))
}
}<|fim_prefix|>// repo: roynalnaruto/core path: /crates/primitives/src/bytes/rlp.rs
use super::Bytes;
use alloy_rlp::{Decodable, Encodable};
impl Encodab... | code_fim | easy | {
"lang": "rust",
"repo": "roynalnaruto/core",
"path": "/crates/primitives/src/bytes/rlp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ayroblu/rust-playground-cli path: /src/modules/functions.rs
pub fn show_functions() {
println!("Structures can be class like, by implementing static or instance methods");
show_struct_impl();
println!("\nClosures");
show_closures();
println!("\nGenerics Traits and Impl");
... | code_fim | hard | {
"lang": "rust",
"repo": "ayroblu/rust-playground-cli",
"path": "/src/modules/functions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn first(&self) -> i32; // Doesn't explicitly require `A` or `B`.
fn last(&self) -> i32; // Doesn't explicitly require `A` or `B`.
}
#[allow(dead_code)]
fn difference<C>(container: &C) -> i32
where
C: Contains,
{
container.last() - container.first()
}
use std::marker::PhantomData;
use std... | code_fim | hard | {
"lang": "rust",
"repo": "ayroblu/rust-playground-cli",
"path": "/src/modules/functions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustviz/rustviz path: /src/svg_generator/svg_frontend/line_styles.rs
pub enum LineStyle {
OwnerLine,
RefValueLine,
RefDataLine,
}
pub enum OwnerLine {
// what is the owner's current status?
Solid, // you can assign to, write and read from this owner
Hollow, // you... | code_fim | hard | {
"lang": "rust",
"repo": "rustviz/rustviz",
"path": "/src/svg_generator/svg_frontend/line_styles.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// NOTE that the style coincide with OwnerLine, but we use the data structure to distinguish the semantics internally
pub enum RefDataLine {
// can you change the data this reference points to? I.e. you might need to dereference multiple times
Solid, // we can r/w data
Hollow, // can o... | code_fim | hard | {
"lang": "rust",
"repo": "rustviz/rustviz",
"path": "/src/svg_generator/svg_frontend/line_styles.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // This will show up as a colorful line
Reassignable, // this ref is declared as
// mut ref = &x;
// or
// mut ref = &mut x;
// and currently no second-level reference is bor... | code_fim | hard | {
"lang": "rust",
"repo": "rustviz/rustviz",
"path": "/src/svg_generator/svg_frontend/line_styles.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tesaguri/oauth1-request-rs path: /oauth1-request/src/serializer.rs
//! Low-level machinery to convert a `Request` to a signature or a URI query/form string.
doc_auto_cfg! {
pub mod auth;
#[cfg(feature = "test")]
pub mod recorder;
pub mod urlencode;
}
doc_auto_cfg! {
pub use... | code_fim | hard | {
"lang": "rust",
"repo": "tesaguri/oauth1-request-rs",
"path": "/oauth1-request/src/serializer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Appends `oauth_version` parameter to the `Authorization` header.
///
/// This must be called exactly once in a serialization process.
fn serialize_oauth_version(&mut self);
/// Finalizes the serialization and returns the serialized value.
fn end(self) -> Self::Output;
}
/// A... | code_fim | hard | {
"lang": "rust",
"repo": "tesaguri/oauth1-request-rs",
"path": "/oauth1-request/src/serializer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Clone, Debug)]
struct AssertImpl<'a>(
#[cfg(feature = "hmac-sha1")] Authorizer<'a, HmacSha1, String>,
Authorizer<'a, Plaintext<String>, String>,
);
impl<S: Sign> Sign for InspectSign<S> {
type Signature = S::Signature;
fn get_signature_method_name... | code_fim | hard | {
"lang": "rust",
"repo": "tesaguri/oauth1-request-rs",
"path": "/oauth1-request/src/serializer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = String::new();
while self.current().is_alphanumeric() || self.current() == '_' {
s.push(self.current());
try!(self.bump());
}
match &s[0..] {
"and" => Ok(self.token(TT::And)),
"break" => Ok(self.token(TT::Break)),
"do" => Ok(self.token(... | code_fim | hard | {
"lang": "rust",
"repo": "aswyk/oxidation",
"path": "/oxidation/src/lexer/reader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aswyk/oxidation path: /oxidation/src/lexer/reader.rs
use std::char;
use parser::tokens::{Token, TokenType as TT};
use lexer::result::{LexerResult, LexerError};
use lexer::stringsource::StringSource;
pub trait Reader {
fn next_token(&mut self) -> LexerResult<Token>;
fn peek_token(... | code_fim | hard | {
"lang": "rust",
"repo": "aswyk/oxidation",
"path": "/oxidation/src/lexer/reader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AsRef<[u8]> for Sound {
fn as_ref(&self) -> &[u8] {
&self.0
}
}<|fim_prefix|>// repo: chaynabors/gear path: /src/sound.rs
// Copyright 2021 Chay Nabors.
use std::convert::AsRef;
use std::fs::File;
use std::io::Read;
use std::io::{self,};
use std::path::Path;
use std::sync::Arc;
<|f... | code_fim | hard | {
"lang": "rust",
"repo": "chaynabors/gear",
"path": "/src/sound.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chaynabors/gear path: /src/sound.rs
// Copyright 2021 Chay Nabors.
use std::convert::AsRef;
use std::fs::File;
use std::io::Read;
use std::io::{self,};
use std::path::Path;
use std::sync::Arc;
use crate::Loadable;
pub struct Sound(Arc<Vec<u8>>);
<|fim_suffix|> pub(crate) fn decoder(self: ... | code_fim | medium | {
"lang": "rust",
"repo": "chaynabors/gear",
"path": "/src/sound.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
Self: Sized,
{
let mut buf = vec![];
let mut file = File::open(path)?;
file.read_to_end(&mut buf)?;
Ok(Sound(Arc::new(buf)))
}
}
impl AsRef<[u8]> for Sound {
fn as_ref(&self) -> &[u8] {
&self.0
}
}<|fim_prefix|>// repo: chaynabors/... | code_fim | hard | {
"lang": "rust",
"repo": "chaynabors/gear",
"path": "/src/sound.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sink.set_volume(0.25);
Self {
sink,
changed_target_buffer: Arc::new(RwLock::new(None)),
target_buffer: Arc::clone(&buffer),
changed_time: Arc::new(RwLock::new(None)),
time: Arc::new(RwLock::new(0.0)),
speed: Arc::new(R... | code_fim | hard | {
"lang": "rust",
"repo": "OTOMariK/yee_player",
"path": "/src/buffer_player.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.