blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
7e29a8e30f31966461dc6b65e9013893953a5aa4 | Rust | ferrous-systems/imxrt1052 | /src/gpio1/icr2/mod.rs | UTF-8 | 63,498 | 2.8125 | 3 | [] | no_license | #[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::ICR2 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
f82f145771da77de3fdb2c1caaad7deaaffdf881 | Rust | hopkinstechnocrats/FRCScouter | /src/server/mod.rs | UTF-8 | 15,515 | 2.59375 | 3 | [] | no_license | mod ping;
pub mod data;
mod network;
mod console;
use ws::listen;
use network::packet::Packet;
use data::WrappedPacket;
use std::sync::{Arc, Mutex};
use std::thread;
use chrono::offset::Utc;
use chrono::DateTime;
use data::ServerData;
/// Launches the WebSocket server. This communicates with clients and processes... | true |
7d966e55bbe40536fbe51923349139ffcfd15e32 | Rust | rust9x/rust | /src/test/ui/const-generics/issue-61522-array-len-succ.rs | UTF-8 | 552 | 2.703125 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | // revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters may not be used
impl<const COUNT: usize> M... | true |
2079f417c25de837c46f6624df8704e2ef9f19d3 | Rust | CaioSantana123/EDL2020 | /Macro/07vec.rs | UTF-8 | 378 | 3.390625 | 3 | [] | no_license | macro_rules! tvec{
($($x:expr),*) => {//criação da macro tvec
{
let mut t_vec = Vec::new();//criação do objeto Vec dentro da macro
$(t_vec.push($x);)* //repetição da instrução push(função dentro da classe Vec)
t_vec //retorna t_vec
}
};
}
fn main(){
let v = tvec!(1, 2, 3, 4, 5); //chamada ... | true |
59c6bee022682febed545500e4c9464327132707 | Rust | Matthew-Maclean/ggez-camera-test | /src/main.rs | UTF-8 | 8,748 | 2.703125 | 3 | [] | no_license | use ggez::
{
self,
Context, ContextBuilder, GameResult,
conf::{WindowSetup, WindowMode},
event::{run, EventHandler},
graphics::{self, clear, present, DrawParam, Mesh, MeshBuilder, draw},
input::{mouse::MouseButton, keyboard::{KeyCode, KeyMods}},
mint::{Point2, Vector2},
};
fn main() -> Game... | true |
6dd98269e0a174cc59db0d014dad2c93dcf18ce9 | Rust | korken89/core-mutex | /examples/sharing.rs | UTF-8 | 985 | 3.328125 | 3 | [] | no_license | // Some data used by the driver
struct DriverData;
// This is used with mutexes which can be used with reference or making copies of the Mutex
// Many will work but will not be compatible with for example RTFM
struct WrapperWithMutex<T> {
mtx: T,
driver: GenericDriver,
}
impl<T> WrapperWithMutex<T>
where
... | true |
31753ebe0dbf203f4ef8bcd4f0fb9a2e2dbd84f8 | Rust | dekellum/marked | /marked/src/logger.rs | UTF-8 | 2,591 | 3.171875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! A very simple Log output implementation for testing and any CLIs.
use std::error::Error as StdError;
use std::io::Write;
#[cfg(test)]
use std::sync::Once;
/// Conveniently compact type alias for dyn Trait `std::error::Error`.
type Flaw = Box<dyn StdError + Send + Sync + 'static>;
struct Monolog {
other: log... | true |
029f0c5aa24e14311cd55037b2292ed67493d9f3 | Rust | sporksmith/shadow | /src/main/network/packet.rs | UTF-8 | 6,368 | 2.734375 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | use std::io::Write;
use crate::cshadow as c;
use crate::utility::pcap_writer::PacketDisplay;
impl PacketDisplay for *const c::Packet {
fn display_bytes(&self, mut writer: impl Write) -> std::io::Result<()> {
assert!(!self.is_null());
let header_len: u16 = unsafe { c::packet_getHeaderSize(*self) }... | true |
5e7ff5bf4b5f1b33be84995d40d674a7ec20c1b5 | Rust | but0n/riscv-rust | /src/plic.rs | UTF-8 | 4,847 | 3.1875 | 3 | [
"MIT"
] | permissive | #[derive(Clone)]
pub enum InterruptType {
None,
KeyInput,
Timer,
Virtio
}
// Based on SiFive Interrupt Cookbook
// https://sifive.cdn.prismic.io/sifive/0d163928-2128-42be-a75a-464df65e04e0_sifive-interrupt-cookbook.pdf
pub struct Plic {
clock: u64,
irq: u32,
enabled: u64,
threshold: u32,
priorities: [u32; 10... | true |
29d346aec69537f0db4e4711271128168f0d70e9 | Rust | vaibhavantil2/third-party-api-clients | /gusto/src/admins_beta.rs | UTF-8 | 3,301 | 2.78125 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use crate::Client;
pub struct AdminsBeta {
pub client: Client,
}
impl AdminsBeta {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
AdminsBeta { client }
}
/**
* Get all the admins at a company.
*
* This function performs a `GET` to the `/v1/companie... | true |
8e6429faa09a1362cb80409cc7508e7a23c48c2d | Rust | franktea/leetcode-rust | /src/bin/0071.rs | UTF-8 | 1,068 | 3.4375 | 3 | [] | no_license | // 直接用栈就可以了
impl Solution {
pub fn simplify_path(path: String) -> String {
let mut v = Vec::new();
for s in path.split("/") {
match s {
"" | "." => {
}
".." => {
v.pop();
}
... | true |
fbe05d87b47329ddb3e8dc682555ecfff28e6255 | Rust | Lokathor/bytemuck | /derive/src/lib.rs | UTF-8 | 16,570 | 3.375 | 3 | [
"Zlib",
"Apache-2.0",
"MIT"
] | permissive | //! Derive macros for [bytemuck](https://docs.rs/bytemuck) traits.
extern crate proc_macro;
mod traits;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput, Result};
use crate::traits::{
AnyBitPattern, CheckedBitPattern, Contiguous, Derivable, NoUninit, Pod,
TransparentWrapp... | true |
f7492dd3ae55ed97d70916fa9a0411cbff9b3d4b | Rust | oharlem/exercism-rust | /proverb/src/lib.rs | UTF-8 | 666 | 2.921875 | 3 | [] | no_license | use std::iter::once;
pub fn build_proverb(list: &[&str]) -> String {
if list.len() == 0 {
return String::new();
}
list.windows(2)
.map(|pair| format!("For want of a {} the {} was lost.\n", pair[0], pair[1]))
.chain(once(format!("And all for the want of a {}.", list[0])))
.co... | true |
f6f6f7a4364a5e6548f4677aee882680161f3e82 | Rust | BookOwl/aoc2020 | /src/main.rs | UTF-8 | 766 | 2.9375 | 3 | [] | no_license | use clap::App;
use aoc2020::Part;
fn main() {
let matches = App::new("aoc2020")
.arg("<day> 'Which day's puzzles to solve'")
.arg("--part [part] 'Which part of the day's puzzles to solve, defaults to all")
.arg("--input [file] 'Which file to read the day's input from, defaults to my input'"... | true |
9f5abe6ba3ee8b0dbffd551c7607f0fdc82f8e69 | Rust | IThawk/rust-project | /rust-master/src/test/ui/functions-closures/clone-closure.rs | UTF-8 | 320 | 3.421875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
// Check that closures implement `Clone`.
#[derive(Clone)]
struct S(i32);
fn main() {
let mut a = S(5);
let mut hello = move || {
a.0 += 1;
println!("Hello {}", a.0);
a.0
};
let mut hello2 = hello.clone();
assert_eq!(6, hello2());
assert_eq!(6, hello());
}
| true |
45f317040743f0a5e685bb50a92957cee2af24b9 | Rust | Darksecond/lox | /lox-vm/src/runtime.rs | UTF-8 | 9,566 | 2.640625 | 3 | [
"BSD-3-Clause"
] | permissive | mod builtins;
use lox_bytecode::bytecode::Module;
use crate::value::Value;
use builtins::Builtins;
use super::memory::*;
use super::interner::{Symbol, Interner};
use lox_gc::{Gc, Trace, Tracer};
use crate::fiber::Fiber;
use crate::string::LoxString;
use std::collections::HashMap;
#[derive(PartialEq, Eq, Copy, Clone)... | true |
bab5277ba9aa3dc4edf63fc0a4956ec0e2feea60 | Rust | mtXTJocj/rosetta_code | /bitmap/src/main.rs | UTF-8 | 2,576 | 3.671875 | 4 | [
"Unlicense"
] | permissive | use std::fs::File;
use std::io::{BufWriter, Result, Write};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Color {
r: u8,
g: u8,
b: u8,
}
impl Color {
pub fn new(r: u8, g: u8, b: u8) -> Self {
Color { r, g, b }
}
}
pub struct Bitmap {
width: usize,
height: usize,
imag... | true |
e483c173e91c3692a0bc9bc4a098a353c7ea7332 | Rust | dsmo7206/rust_raytracer | /engine/src/light.rs | UTF-8 | 832 | 3.140625 | 3 | [] | no_license | use crate::{image::Colour, scene::Scene};
use glam::Vec3A as Vec3;
#[derive(serde::Deserialize)]
pub enum Light {
PointLight(PointLight),
}
impl Light {
pub fn visible_fraction(&self, position: Vec3, scene: &Scene) -> f32 {
match self {
Light::PointLight(inner) => inner.visible_fraction(po... | true |
1bd43ab1e0bc48b251235b200c279a7039c6da6b | Rust | maur1th/simplest-database | /src/server/mod.rs | UTF-8 | 2,563 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | use std::{str, thread};
use std::io::prelude::*;
use std::io::{Error, ErrorKind, Result};
use std::net::{TcpListener,TcpStream};
use std::sync::{Arc, Mutex};
use std::collections::HashMap;
mod set;
mod get;
#[derive(Clone)]
pub struct Index {
inner: Arc<Mutex<HashMap<String, u64>>>,
}
impl Index {
pub fn new... | true |
b6bc10a14fc7b1b015737a7ae7fecf01493565b1 | Rust | FrostMiKu/yarsg | /src/cli/new.rs | UTF-8 | 806 | 2.671875 | 3 | [] | no_license | use std::{fs, path::PathBuf};
use super::config;
use log::info;
use crate::errors::{Error, Result};
pub fn init_site_workspace(root_dir: &PathBuf, site_name: &str) -> Result<()>{
let work_dir = root_dir.join(site_name);
if let Err(_) = fs::create_dir(work_dir.as_path()) {
return Err(Error::new(
... | true |
75de4109143a376e5a9e78bddb28ee34aa92c9af | Rust | makepad/makepad | /draw/vector/bender/clipper/tests/test_simple_polygon.rs | UTF-8 | 1,215 | 2.59375 | 3 | [
"MIT"
] | permissive | use bender_clipper::{Clipper, Operation, Options};
use bender_geometry::linear_path::Command;
use bender_geometry::Point;
use bender_internal_iter::InternalIterator;
use std::iter;
#[test]
fn test_simple_polygon() {
assert_eq!(
Clipper::new()
.clip(
Operation::Union,
... | true |
dac89dc09a9450c2ea9913e812ef7775404227ea | Rust | ftsujikawa/rust-sample | /ch07/code7-14/src/main.rs | UTF-8 | 318 | 2.828125 | 3 | [] | no_license | fn main() {
let mut v = Vec::new();
println!("v.len is {}", v.len());
v.push(10);
v.push(20);
v.push(30);
println!("v.len is {}", v.len());
println!("pop is {:?}", v.pop());
println!("pop is {:?}", v.pop());
println!("pop is {:?}", v.pop());
println!("v.len is {}", v.len());
}
| true |
9970b40010e89b8102c219e1b0d8481acc651707 | Rust | rschifflin/1gam_feb2017 | /src/fsm/enemy/wander.rs | UTF-8 | 2,356 | 2.828125 | 3 | [] | no_license | use super::EnemyAi;
use rand;
use systems::physics::GRAVITY;
const IDLE_TIME: usize = 45;
const WANDER_TIME: usize = 30;
const JUMP_RATIO: f64 = 0.25;
const JUMP_YVEL: f64 = (GRAVITY.y * WANDER_TIME as f64) / -2.0;
#[derive(Debug, Copy, Clone)]
enum WanderState {
Idle,
Wandering,
}
#[derive(Debug)]
pub struct Wa... | true |
3d107991126b7559430d714ed1f24ada35275aa9 | Rust | Carterj3/w3g-info | /w3g-common/src/api/island_defense/leaderboard.rs | UTF-8 | 1,343 | 2.59375 | 3 | [
"MIT"
] | permissive | use ::pubsub::model::IdStats;
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, new)]
pub struct Builder
{
pub name: String,
pub realm: String,
pub rating: f64,
pub wins: i32,
pub losses: i32,
pub ties: i32,
}
impl Builder {
pub fn from_id_stats(stats: IdStats) -> Builder
{
... | true |
8cb725c48cafe8307acccf82097d447f47a4a5d3 | Rust | skyscribe/jira-reporter | /src/checkers/search.rs | UTF-8 | 5,262 | 2.546875 | 3 | [] | no_license | use std::clone::Clone;
use std::sync::mpsc::channel;
use std::sync::mpsc::Receiver;
use std::sync::mpsc::Sender;
use tokio_core::reactor::Core;
use hyper::StatusCode;
use serde::de::DeserializeOwned;
use crate::fetch::fetcher::{Fetcher, RequestInfo};
use crate::query::batch::Query;
use crate::query::result::{parse_qu... | true |
6dd7f8c4cbd1047d1baa4f585215681c427b14ce | Rust | Jimskapt/rust-book-fr | /FRENCH/listings/ch10-generic-types-traits-and-lifetimes/listing-10-03/src/main.rs | UTF-8 | 766 | 3.65625 | 4 | [
"Apache-2.0",
"MIT",
"Unlicense",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | // ANCHOR: here
fn le_plus_grand(liste: &[i32]) -> i32 {
let mut le_plus_grand = liste[0];
for &element in liste {
if element > le_plus_grand {
le_plus_grand = element;
}
}
le_plus_grand
}
fn main() {
let liste_de_nombres = vec![34, 50, 25, 100, 65];
let resultat ... | true |
103515a64ce06d38a22b1d40fe513a0bc43a2d1b | Rust | vicentedpsantos/rust-by-example | /src/hello_world/main.rs | UTF-8 | 124 | 2.59375 | 3 | [] | no_license | // Single Comment
/*
Multiline comment
*/
fn main() {
println!("Hello world");
println!("I'm a rustacean!");
}
| true |
e603cc28f161c29806a8f1b3bdac8e661abe839a | Rust | djg/unsafe-poke | /src/lib.rs | UTF-8 | 5,256 | 2.609375 | 3 | [] | no_license | use std::{mem, ptr, marker::PhantomData};
#[cfg(feature = "extras")]
mod euclid;
pub unsafe trait UnsafePokable {
fn poke_i8(self, v: i8) -> Self;
fn poke_i16(self, v: i16) -> Self;
fn poke_i32(self, v: i32) -> Self;
fn poke_i64(self, v: i64) -> Self;
fn poke_u8(self, v: u8) -> Self;
fn poke_u... | true |
38fca5cfc538b8508b640f1e5894215c02a88e71 | Rust | ChainSafe/serde-bin-prot | /src/ser.rs | UTF-8 | 12,601 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::error::{Error, Result};
use crate::WriteBinProtExt;
use serde::ser;
use serde::Serialize;
pub struct Serializer<W> {
writer: W,
}
impl<W> Serializer<W> {
pub fn new(writer: W) -> Self {
Self { writer }
}
}
impl<W> Serializer<W>
where
W: std::io::Write,
{
fn write(&mut self, buf... | true |
65f625637b1c87868c9ff004ad2ae5043be629e8 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/num-traits/src/ops/mul_add.rs | UTF-8 | 3,530 | 2.578125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /
/
/
Fused
multiply
-
add
.
Computes
(
self
*
a
)
+
b
with
only
one
rounding
/
/
/
error
yielding
a
more
accurate
result
than
an
unfused
multiply
-
add
.
/
/
/
/
/
/
Using
mul_add
can
be
more
performant
than
an
unfused
multiply
-
add
if
/
/
/
the
target
architecture
has
a
dedicated
fma
CPU
instruction
.
/
/
/
/
/
/
No... | true |
aecd9a2ee52ffbeeba1570bc9c270017aaf666c8 | Rust | jawm/jumpjet | /jump_jet/src/runtime/mod.rs | UTF-8 | 2,018 | 2.5625 | 3 | [] | no_license | use std::io::Read;
use std::collections::HashMap;
use parser::ModuleParser;
use parser::ParseError;
use runtime_tree::ExternalKindInstance;
use runtime_tree::Import;
use runtime_tree::ModuleTemplate;
use runtime_tree::ModuleTemplateBuilder;
#[macro_use]
pub mod exports;
pub mod language_types;
pub mod functions;
p... | true |
57d222ba2622ac5aeaeb864c19314ab9ed34a13c | Rust | wemyss/rustikub | /src/game/tile_runs/sequential.rs | UTF-8 | 4,253 | 3.171875 | 3 | [
"MIT"
] | permissive | use super::shared::*;
use game::tile::{ALL_COLORS, Color, Tile};
use std::cmp;
fn generate_sequential_runs(color: Color, length: u8, joker_count: u8) -> Vec<Vec<Tile>> {
let mut runs: Vec<Vec<Tile>> = Vec::new();
let range_length = (MAX_VALUE - length + joker_count + 1) as usize;
for i in 1..(range_length+1) {
... | true |
d5e1c3cf6d48289573e78597d6f61465472e187f | Rust | shaneutt/lumen | /lumen_runtime/src/process/spawn/options/message_queue_data.rs | UTF-8 | 814 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use std::convert::{TryFrom, TryInto};
use anyhow::Context;
use liblumen_alloc::erts::term::prelude::*;
#[derive(Clone, Copy, Debug)]
pub enum MessageQueueData {
OnHeap,
OffHeap,
}
impl Default for MessageQueueData {
fn default() -> Self {
MessageQueueData::OnHeap
}
}
impl TryFrom<Term> for ... | true |
cf0d5ab2dc75c5911c6c8974d54333bc2f8b80e1 | Rust | danielabeledo/cryptopals | /base64/src/lib.rs | UTF-8 | 4,198 | 2.65625 | 3 | [] | no_license | use std::collections::HashMap;
#[macro_use]
extern crate lazy_static;
lazy_static! {
static ref DICTIONARY_TO: HashMap<u8, char> =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
.chars()
.enumerate()
.map(|(i, c)| (i as u8, c))
.collect()... | true |
b052c6ef68f0c4aaeda69823c41435ce92675ae3 | Rust | tesseract-olap/tesseract | /tesseract-clickhouse/src/sql/aggregator.rs | UTF-8 | 14,376 | 3.34375 | 3 | [
"MIT"
] | permissive | //! Applying aggregates to measures
//!
//! This is a little complex, because some formulas are complex.
//!
//! for performance reasons, there's an aggregation at the fact table scan level,
//! and then a second aggregation when rolling up to a parent level.
//!
//! This works great for simple aggregations like sum, d... | true |
46171e44860704bf69e15ab0c0a607c75b14e8a9 | Rust | zcdziura/pumpkin | /src/safe_prime.rs | UTF-8 | 4,698 | 3.375 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | //! Generates [safe prime numbers](https://www.wikiwand.com/en/Sophie_Germain_prime).
use ramp::Int;
use rand::rngs::OsRng;
pub use common::{gen_prime, is_prime};
use common::{three, two};
use error::{Error, Result};
/// Constructs a new `SafePrime` with a size of `bit_length` bits.
///
/// This will initialize an ... | true |
6e758fe8b701c4391e15f596626ba81dc0e16a17 | Rust | pmsanford/arithmetic-coding | /src/model.rs | UTF-8 | 1,835 | 3.234375 | 3 | [] | no_license | use anyhow::{Error, Result};
#[derive(Debug, Default)]
pub struct Probability {
pub high: u32,
pub low: u32,
pub count: u32,
}
const MAX_FREQ: u32 = 0x3FFF;
pub struct Model {
cumulative_frequency: [u32; 258],
frozen: bool,
}
impl Model {
pub fn new() -> Self {
let mut cumulative_fre... | true |
63ae8bbc4ab42c1580f158ecadf990f2ef75c666 | Rust | AnneKitsune/dash-raid | /src/systems/bullet_emitter.rs | UTF-8 | 2,667 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use amethyst::core::timing::Time;
use amethyst::core::{GlobalTransform, Transform};
use amethyst::ecs::{Entities, Read, ReadExpect, System, WriteStorage,ReadStorage,Join};
use amethyst_extra::DestroyInTime;
use amethyst::renderer::{MeshHandle,Material,Transparent};
use rand::{thread_rng, Rng};
use data::{Bullet, Bulle... | true |
e1f1ceb6aa67399a7eb485af66a1d0ea3a1291dc | Rust | markrepedersen/netparser | /lib/netparse/src/layer3/ip/ipv6.rs | UTF-8 | 2,941 | 2.625 | 3 | [] | no_license | use crate::{
core::{
parse::{self, BitParsable},
ux::*,
},
layer3::{
icmp,
ip::{ip::*, tcp, udp},
},
};
use custom_debug_derive::*;
use nom::{
bits::bits,
bytes::complete::take,
combinator::map,
error::context,
number::complete::{be_u16, be_u8},
s... | true |
b38b95e918fa8001c5631c3715302299f45b246c | Rust | nirya-istari/dumb_os | /kernel/src/io/error.rs | UTF-8 | 3,017 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | use alloc::boxed::Box;
use core::fmt::Display;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum ErrorKind {
NotFound,
PermissionDenied,
ConnectionRefused,
ConnectionReset,
ConnectionAborted,
NotConnected,
AddrInUse,
AddrNotAvailable,
BrokenPipe,
AlreadyExis... | true |
4d3000fc150251088d5b84d14a62697ea6445bea | Rust | tov/succinct-rs | /src/coding/trans.rs | UTF-8 | 808 | 3.3125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::*;
use internal::errors::*;
use stream::*;
/// Lifts any code by adding one to each encoded value, and subtracting
/// one from each decoded value.
///
/// This is useful when the underlying code, like Elias codes, can’t handle 0s.
pub struct Lift0<Code: UniversalCode>(pub Code);
impl<Code: UniversalCode> ... | true |
e4028b62b629c96dd71ff0c39f27125caba3fd7c | Rust | frjonsen/read-package-json | /src/lib.rs | UTF-8 | 3,485 | 2.875 | 3 | [
"MIT"
] | permissive | mod parsers;
use crate::parsers::optional_string_or_struct;
use crate::PackageJsonError::ParseError;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
#[macro_use]
extern crate lazy_static;
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct Issues {
pub url: Option<url::Url>,... | true |
a9eefd9cd8be5f121c4c022a6b8448a8c01053ad | Rust | boluobanana/rust_example | /thread_local_test/src/main.rs | UTF-8 | 794 | 2.703125 | 3 | [] | no_license | use std::cell::RefCell;
thread_local! {
pub static FOO_LOCAL: RefCell<u32> = RefCell::new(444);
}
extern "C" fn log_foo_local(from: i32) {
FOO_LOCAL.with(|foo| {
println!("thread: {:?} foo local is {:?}", from, foo);
});
}
type LogFoo = extern "C" fn(i32);
extern {
fn cpp_foo_test(foo: LogFoo);... | true |
398593b2bbad575b575af34a5a66155dee76974c | Rust | weworld/rusty-leetcode | /src/sort_tag/best_meeting_point_296.rs | UTF-8 | 1,521 | 3.109375 | 3 | [
"WTFPL"
] | permissive | /*
* @lc app=leetcode.cn id=296 lang=rust
*
* [296] 最佳的碰头地点
*/
// @lc code=start
impl Solution {
pub fn min_total_distance(grid: Vec<Vec<i32>>) -> i32 {
if grid.is_empty() {
return 0;
}
if grid[0].is_empty() {
return 0;
}
let mut rows = vec![];
... | true |
3b86cdb38afc4a573c1eabed7721071fb0c89cef | Rust | jakalope/roll_play_ge | /src/tilesheet.rs | UTF-8 | 4,700 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::*;
use tiled;
use image;
#[derive(Debug)]
pub enum TilesheetError {
IoError(io::Error),
TiledError(tiled::TiledError),
ImageError(image::ImageError),
NoSuchGid(u32),
NoParentPath,
NoImages,
}
pub struct Tilesheet {
image: image::RgbaImage,
map: tiled::Map,
}
fn tileset_image(... | true |
fcdf9b5f12d0ca27fe42309c6c809b578fe79099 | Rust | akubera/rust-news | /src.orig/walkdir/src/lib.rs | UTF-8 | 8,951 | 2.859375 | 3 | [] | no_license | //! [file]: # (src/walkdir/src/lib.rs)
//!
//! Sub-crate of 'news' that yields the plugins used to
//! generate html from yaml files.
//!
#![crate_type="dylib"]
#![feature(plugin_registrar, rustc_private)]
extern crate syntax;
extern crate rustc;
extern crate rustc_plugin;
extern crate syntax_pos;
extern crate yaml_r... | true |
fe05578c3a62ebe69bee09223f1995028fd97a8d | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/half/src/binary16.rs | UTF-8 | 40,350 | 2.578125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
[
cfg
(
feature
=
"
bytemuck
"
)
]
use
bytemuck
:
:
{
Pod
Zeroable
}
;
use
core
:
:
{
cmp
:
:
Ordering
fmt
:
:
{
Binary
Debug
Display
Error
Formatter
LowerExp
LowerHex
Octal
UpperExp
UpperHex
}
iter
:
:
{
Product
Sum
}
num
:
:
{
FpCategory
ParseFloatError
}
ops
:
:
{
Add
AddAssign
Div
DivAssign
Mul
MulAssign
Neg
Rem
... | true |
211b0a30ffd63836efdfa19dffe4f94a9d134c47 | Rust | dragon1061/MoonZoon | /crates/hsluv_macro/src/lib.rs | UTF-8 | 2,754 | 3.0625 | 3 | [
"MIT"
] | permissive | use proc_macro::TokenStream;
use quote::quote_spanned;
use syn::{parse_macro_input, punctuated::Punctuated, spanned::Spanned, Error, Lit, Token};
// ```
// hsluv!(89.5, 100, 90.)
// hsluv!(265, 85.9, 32, 80.2)
// hsluv!(265, 85.9, 32, 20)
// ```
//
// generates:
//
// ```
// HSLuv::new_unchecked(89.5, 100., 90., 100. ... | true |
7985c939adbaa4c26a0a22a293bf32c1192a3fac | Rust | francisco-mendes/rust-unit | /src/error.rs | UTF-8 | 938 | 3.078125 | 3 | [] | no_license | use std::{
borrow::Cow,
error::Error,
fmt::{
Display,
Formatter,
},
};
pub type Result<T = ()> = std::result::Result<T, TestError>;
#[derive(Debug)]
pub struct TestError {
pub test: Cow<'static, str>,
pub location: &'static str,
pub reason: &'static str,
pub message: Op... | true |
6b8e0c566666bab1744f809373221dcaa3a8ca7f | Rust | mambisi/escanor | /src/common/parser.rs | UTF-8 | 1,593 | 2.953125 | 3 | [
"MIT"
] | permissive | pub fn parse_raw_cmd(cmd: &[u8]) -> Vec<String> {
let mut tokens: Vec<String> = vec![];
//let cmd = cmd.trim();
let mut block_seq = String::new();
let mut in_string = false;
let mut next_char = '\0';
let mut prev_char = '\0';
let text_qualifier = '`';
let text_delimiter = ' ';
f... | true |
a96b422a88e09bb84e64bc68108c08ff61e5d46f | Rust | doctorwidget/rust_book_examples | /15_traits/src/foo.rs | UTF-8 | 4,701 | 3.859375 | 4 | [] | no_license | /**
* Traits are Rust's interfaces.
*
* Traits are implemented by _structs_. Rust does not have classes per se,
* but structs plus traits gets you all the polymorphic goodness provided by
* classes, without encouraging the antipattern of deep inheritance.
*
* (Structs + Traits) > Classes
*
* Trai... | true |
a794907e6f6f5cb539939c54575ddb2e61a95e8a | Rust | doytsujin/googapis | /googapis/genproto/google.pubsub.v1beta2.rs | UTF-8 | 31,281 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | /// A topic resource.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Topic {
/// Name of the topic.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// A message data and its attributes.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubsubMessage {
/// The me... | true |
3eaab0454bc179a729041f281babaa8e44a31ba6 | Rust | mor9x/ustcp | /ustunet/src/util.rs | UTF-8 | 4,711 | 2.75 | 3 | [] | no_license | use smoltcp::wire::IpAddress as Address;
use std::future::Future;
use std::net::SocketAddr;
use std::pin::Pin;
use std::task::{Context, Poll};
pub fn convert_to_socket_address(
address: Address,
port: u16,
) -> Result<SocketAddr, smoltcp::Error> {
let socket_address = match address {
Address::Ipv4(... | true |
03de587295bab8e81f0c33438fc8726c01fa12f7 | Rust | andelf/picopb | /src/lib.rs | UTF-8 | 8,871 | 3.375 | 3 | [] | no_license | #![no_std]
use core::str;
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[repr(u8)]
/// A wire type that provides just enough information to find the length of the following value.
pub enum WireType {
/// int32, int64, uint32, uint64, sint32, sint64, bool, enum
Varint = 0,
/// fixed64, sfixed64, double
... | true |
b48d83a7703a22a93f8381825c4ed99f39788bd1 | Rust | Connor1996/RayTracing | /src/vec3.rs | UTF-8 | 3,912 | 3.640625 | 4 | [] | no_license | use std::ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub};
pub type Color = Vec3;
pub type Point3 = Vec3;
impl std::fmt::Display for Color {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{} {} {}",
(255.... | true |
b98349fb64ff90c75d280b3124c37e052030da10 | Rust | emilssolmanis/project-euler-rust | /src/solutions/problem_4.rs | UTF-8 | 1,386 | 3.875 | 4 | [] | no_license | struct Product {
i: u32,
j: u32,
}
impl Product {
fn new() -> Product {
Product { i: 999, j: 1000 }
}
}
impl Iterator for Product {
type Item = u32;
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
self.j -= 1;
if self.j < 100 {
self.j = 999;
... | true |
a147ef4b2daa2fc381cdaac0958ba3bb095a7307 | Rust | LFalch/adventofcode-2020 | /src/bin/day1.rs | UTF-8 | 770 | 3 | 3 | [] | no_license | use adventofcode_2020::read_lines;
use self_compare::SliceCompareExt;
fn main() {
let numbers: Vec<_> = read_lines("day1.txt")
.map(|s| s.trim().parse::<u128>().unwrap())
.collect();
// First solutions that were easy to write
// O(n²)
numbers.compare_self(|a, b| {
if a + b == ... | true |
4dfc2a9c5f0113909a5531f0a7585afc16a7cf2c | Rust | tony612/rust-by-example | /src/pointer/refcell.rs | UTF-8 | 4,703 | 3.6875 | 4 | [] | no_license | use std::{
cell::UnsafeCell,
ops::{Deref, DerefMut},
};
use super::cell::Cell;
#[derive(Copy, Clone)]
enum RefState {
Unshared,
Shared(usize),
Exclusive,
}
struct RefCell<T> {
value: UnsafeCell<T>,
state: Cell<RefState>,
}
impl<T> RefCell<T> {
fn new(value: T) -> RefCell<T> {
... | true |
3bba80dad9e6b8b8b1677e8960662e0023ac0bd6 | Rust | VoxWave/dungenon-rs | /src/generator/grid/faction.rs | UTF-8 | 7,539 | 2.609375 | 3 | [
"MIT"
] | permissive | use std::{mem, ops::Deref};
use rand::{rngs::OsRng, Rng};
use rayon::prelude::*;
use tile::Faction;
use level::GridLevel;
// Constants for 128 bit lehmer rngs
// const LEHMER_MULT0: u128 = 0x9cec0193f9cb55c4acce1fe16e62b05f;
// const LEHMER_MULT1: u128 = 0x82163e3e925f6e050dfa28d05eb25d83;
// const LEHMER_MULT2: u... | true |
2ce43ebadf91427d0b14643477d3b600497e57c8 | Rust | xleyba/ex002 | /src/main.rs | UTF-8 | 1,127 | 3.84375 | 4 | [] | no_license | // Given an array of integers, return a new array such that each element at index i of the new
// array is the product of all the numbers in the original array except the one at i.
//
// For example,
// if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24].
//
// If our input was [3, 2, 1... | true |
25fa943565a0b8a860a828448412e92272d90e7b | Rust | sagiegurari/cargo-make | /src/lib/cli_commands/list_steps_test.rs | UTF-8 | 10,867 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
] | permissive | use super::*;
use crate::io;
use crate::types::{ConfigSection, EnvValue, Task};
use expect_test::{expect, Expect};
use indexmap::IndexMap;
use std::path::PathBuf;
fn check(
config: &Config,
output_format: &str,
output_file: &Option<String>,
category: Option<String>,
hide_uninteresting: bool,
e... | true |
bc2b66b52d6d954ce9ff1a08dba2e9baac0f0e45 | Rust | MoonlightOwl/Quartz | /src/main.rs | UTF-8 | 2,471 | 2.625 | 3 | [
"MIT"
] | permissive | #![feature(plugin, decl_macro)]
#![plugin(rocket_codegen)]
extern crate rocket_contrib;
extern crate rocket;
#[macro_use] extern crate diesel;
#[macro_use] extern crate serde_derive;
mod db;
mod quote;
use quote::Quote;
use std::env;
use std::path::{Path, PathBuf};
use rocket::response::NamedFile;
use rocket::Requ... | true |
6e5bde60f233917785dc57ab5289d7f43c0be40e | Rust | bhechinger/tunnel_manager | /src/bin/client.rs | UTF-8 | 1,130 | 2.59375 | 3 | [] | no_license | use tonic::Request;
use api::user_client::UserClient;
use api::UserRequest;
use crate::api::user_request::IdOrEmail;
// use uuid::Uuid;
pub mod api {
tonic::include_proto!("api");
}
fn get_token() -> &str {
"Fake Token"
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let c... | true |
b65183cc4b4f394a6bd9466ae570abb251a8036e | Rust | pigeonhands/docker-generate-rs | /src/docker.rs | UTF-8 | 5,838 | 3.234375 | 3 | [] | no_license |
macro_rules! str_arr_to_string_vec {
($i:ident) => ($i.iter().map(|a| a.to_string()).collect::<Vec<String>>())
}
pub enum DockerFieldType<'a>{
Docker(DockerFile<'a>),
r#String(String),
Array(Vec<&'a str>),
TupleList(&'a[(&'a str, &'a str)]),
MultiValue(Vec<String>),
Protocal((i32, &'a str... | true |
2ae92653a358ebf9cf2b879d5e4ca011aaa0c267 | Rust | eadf/yabf.rs | /benches/bench.rs | UTF-8 | 4,305 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use criterion::{black_box, criterion_group, criterion_main, Criterion};
use yabf::Yabf;
#[cfg(test)]
// std::Vec: bench: [12.335 ms 12.337 ms 12.339 ms]
fn bench_vec(c: &mut Criterion) {
println!("running bench with std::vec::Vec");
let mut bf = Yabf::default();
c.bench_function("Yabf", |b| {
b.i... | true |
d5a5dc45eb0880f16db0f701a2c22c574cafd4ac | Rust | tomohiko38/rust_projects | /new_book/lesson02/src/main.rs | UTF-8 | 117 | 2.6875 | 3 | [] | no_license | fn main() {
let mut msg:String = String::from("Hello");
msg = msg + " Rust!";
println!("msg={}", msg);
}
| true |
f13aa75df24803f41ae456b1d285653a72b2a71c | Rust | mattatmsft/remotactoe | /app/src/runtime/configuration.rs | UTF-8 | 289 | 2.703125 | 3 | [
"MIT"
] | permissive | pub struct Configuration {
pub is_host: bool,
pub client_port: u16,
pub host_port: u16,
}
impl Configuration {
pub fn new() -> Configuration {
Configuration {
is_host: false,
client_port: 4791,
host_port: 4792,
}
}
} | true |
004fb141725d3a39c9fa78185e12c641b4b2edb4 | Rust | ruggeri/fourier2 | /src/lib/hz_scanner/scanner.rs | UTF-8 | 1,810 | 2.78125 | 3 | [] | no_license | use super::opts::HzScannerOpts;
use core::AudioSource;
use transforms::{ftransform, FourierTransformOpts};
use util;
pub struct HzScanner<'a, AS>
where
AS: AudioSource + 'a,
{
source: &'a AS,
t: f64,
hz: f64,
opts: HzScannerOpts,
}
#[derive(Debug)]
pub struct DetectedHz {
pub hz: f64,
pub ... | true |
78d40bbb835fd493a869a3d08643c0fdb270d621 | Rust | 0xb10ckdev/forest | /src/key_management/errors.rs | UTF-8 | 619 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use std::io;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
/// info that corresponds to key does not exist
#[error("Key info not found")]
KeyInfo,
/// Key already exists in key store
#[error("Key... | true |
58ccbd4b2dc93bb50f8457a4f8f31c87b560fd50 | Rust | hmarthinsen/gaby | /src/audio.rs | UTF-8 | 9,195 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::memory::{IORegister, Memory};
use rand::Rng;
use sdl2::audio::AudioQueue;
use std::{cell::RefCell, rc::Rc};
pub struct Audio {
mem: Rc<RefCell<Memory>>,
// tick_disabled: [bool; 4],
output_enabled: [bool; 4],
length_counters: [usize; 4],
envelope_counters: [u8; 4],
envelope_values: [... | true |
adf2c8360711933cfb77f627f26014dc62eefcad | Rust | lianhuiwang/tokamak | /src/parser2/attr.rs | UTF-8 | 1,961 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | // Functions dealing with attributes and meta items
use ast::Attribute;
/// A list of attributes, behind a optional box as
/// a space optimization.
pub type ThinAttributes = Option<Box<Vec<Attribute>>>;
pub trait ThinAttributesExt {
fn map_thin_attrs<F>(self, f: F) -> Self
where F: FnOnce(Vec<Attribute>... | true |
9b24149ea1e0faaf0bce072378bf4e2e32199fa7 | Rust | ypkulkar/binary_tree | /src/lib.rs | UTF-8 | 5,165 | 3.5 | 4 | [] | no_license | //use std::cmp::Ordering::*;
///use T: std::fmt::Debug;
#[derive(Debug)]
pub struct Node<T> {
key: T,
left : Option<Box<Node<T>>>,
right: Option<Box<Node<T>>>,
}
#[derive(Debug)]
pub struct Tree<T>{
node: Option<Box<Node<T>>>,
}
impl<T: Ord> Node<T> {
/// Creates an empty tree
pub fn new(key: T) -> Sel... | true |
2f55b0213eb230cbea6b13729da203d807c3e734 | Rust | CalliEve/boa | /boa_engine/src/object/internal_methods/global.rs | UTF-8 | 21,771 | 2.65625 | 3 | [
"MIT",
"Unlicense"
] | permissive | use crate::{
object::{
internal_methods::ordinary_get_prototype_of, InternalObjectMethods, JsObject, JsPrototype,
ORDINARY_INTERNAL_METHODS,
},
property::{DescriptorKind, PropertyDescriptor, PropertyKey},
value::JsValue,
Context, JsResult,
};
use boa_profiler::Profiler;
/// Definiti... | true |
a58e3b60f0c0c13630169f306a2e3d92778c6b25 | Rust | tromey/gdb-rsp | /src/util.rs | UTF-8 | 651 | 3.34375 | 3 | [] | no_license | #![deny(missing_docs)]
/// Decode a hex sequence.
pub fn decode_hex(seq: &[u8]) -> Option<u64> {
let mut result = 0;
for c in seq {
let digit = match *c {
b'0'...b'9' => c - b'0',
b'a'...b'f' => c - b'a' + 10,
b'A'...b'F' => c - b'A' + 10,
_ => { return N... | true |
aa009d2f63383355624b106f79d6dcdfb83bf4f8 | Rust | nickwong1005/flaky_test | /tests/tests.rs | UTF-8 | 488 | 2.546875 | 3 | [
"MIT"
] | permissive | use flaky_test::flaky_test;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
#[flaky_test]
fn assert_true() {
println!("should pass");
}
#[flaky_test]
fn fail_first_two_times() {
static C: AtomicUsize = AtomicUsize::new(0);
if C.fetch_add(1, Ordering::SeqCst) < 2 {
panic!("flaky");
}
... | true |
a7c6979789878d9efe2c532e588e441c59a9a1af | Rust | OrionNebula/trapdoor | /tests/integration_tests.rs | UTF-8 | 2,462 | 3.25 | 3 | [] | no_license | extern crate trapdoor;
use trapdoor::Trapdoor;
struct DropObserver<'a>(&'a mut bool);
impl<'a> Drop for DropObserver<'a> {
fn drop(&mut self) {
*self.0 = true;
}
}
#[test]
/// Ensures that the value contained in a Trapdoor is dropped when the two halves are
fn test_drop() {
let (mut tx, rx) = Tra... | true |
12f99946030779948504d8c21aa7b2b16832b2bf | Rust | maxmcc/aoc-2020 | /src/bin/day15.rs | UTF-8 | 2,678 | 3.3125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use aoc::{Parse, Result, Solve};
#[derive(Debug)]
struct MemoryGame {
start: Vec<u32>,
}
impl<'a> Parse<'a> for MemoryGame {
fn parse<'b: 'a>(input_str: &'b str) -> Result<Self> {
let start = input_str
.split(',')
.map(str::parse)
.collect::<Result<_, _>>()?;
... | true |
34f25d0b1233938f1d738d0da4d58a5d01affe41 | Rust | frewsxcv/advisory-db-renderer | /src/main.rs | UTF-8 | 1,342 | 2.515625 | 3 | [
"CC0-1.0"
] | permissive | extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate structopt;
extern crate toml;
use std::error::Error;
use std::fs;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "advisory-db-renderer")]
struct Opt {
#[structopt(name = "ADVISOR... | true |
98a0ec84424b077c0105c5217fcb565e3c1dd423 | Rust | r1cebank/genome | /src/dna.rs | UTF-8 | 8,001 | 3.4375 | 3 | [
"MIT"
] | permissive | use crate::gene::Gene;
use crate::utils;
use rand::prelude::*;
pub struct DNA {
// The pool size, number of genes
pub pool_size: u16,
// The amount of marker each gene has, each marker is f32
pub gene_size: u16,
// The genes for this DNA sequence
pub genes: Vec<Gene>,
}
impl DNA {
/// Cons... | true |
c5ba87ee864d7fe2b7052392608d2c107f58d945 | Rust | g2xpf/gfx-triangle | /src/renderer/pipeline.rs | UTF-8 | 3,788 | 2.625 | 3 | [] | no_license | use gfx_hal::{format as f, pass::Subpass, prelude::*, pso, Backend};
use std::fs::read;
use std::io::Cursor;
use std::mem::{self, ManuallyDrop};
use std::ptr;
const ENTRY_NAME: &str = "main";
pub struct Pipeline<'a, B: Backend> {
device: &'a B::Device,
pub pipeline: ManuallyDrop<B::GraphicsPipeline>,
pub ... | true |
e1706a78160dc600204456e9f7587c4e9f47cc95 | Rust | mainrs/owo-colors | /src/dyn_styles.rs | UTF-8 | 13,609 | 3.296875 | 3 | [] | no_license | use crate::{AnsiColors, Color, DynColor, DynColors};
use core::fmt;
#[cfg(doc)]
use crate::OwoColorize;
/// A runtime-configurable text effect for use with [`Style`]
#[derive(Debug, Copy, Clone)]
pub enum Effect {
Bold,
Dimmed,
Italic,
Underline,
Blink,
BlinkFast,
Reversed,
Hidden,
... | true |
7a10d2ab2da46216e471a8d9b8a2f78027721778 | Rust | potatogim/cloud-hypervisor | /vm-device/src/lib.rs | UTF-8 | 3,736 | 2.875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | extern crate serde;
extern crate thiserror;
extern crate vm_memory;
use vm_memory::{
Address, GuestAddress, GuestMemory, GuestMemoryMmap, GuestMemoryRegion, GuestRegionMmap,
MemoryRegionAddress,
};
use thiserror::Error;
/// Trait meant for triggering the DMA mapping update related to an external
/// device n... | true |
73d77bdaa6d86bedb8ce798967750f7263c7a62c | Rust | KuldeepSinh/trpl_notes | /04_chapter/slices/src/main.rs | UTF-8 | 2,172 | 4.3125 | 4 | [
"Apache-2.0"
] | permissive | //Slices let you reference a contiguous sequence of elements in a collection
//rather than the whole collection.
fn main() {
let s = String::from("Hello, world!");
let hello = &s[0..5]; //include start - exclude end.
let world = &s[7..12];
println!("first slice = {}\nsecond slice = {}.", hello, world);
... | true |
fe29ead03495dbb208e44e655ab91e8864dcdbec | Rust | occlum/occlum | /src/libos/src/untrusted/alloc.rs | UTF-8 | 2,213 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | use super::*;
use std::alloc::{AllocError, Allocator, Layout};
use std::ptr::{self, write_bytes, NonNull};
/// The global memory allocator for untrusted memory
pub static mut UNTRUSTED_ALLOC: UntrustedAlloc = UntrustedAlloc;
pub struct UntrustedAlloc;
unsafe impl Allocator for UntrustedAlloc {
fn allocate(&self,... | true |
2930d665b3be400c958034f90aeb0d891d95d88c | Rust | ltoddy/http-static-server | /src/method.rs | UTF-8 | 1,458 | 3.4375 | 3 | [] | no_license | use std::error;
use std::fmt;
#[derive(Debug, Clone, PartialOrd, PartialEq)]
#[allow(unused_must_use)]
pub enum HttpMethod {
Get,
Post,
Put,
Delete,
Options,
Head,
Connect,
Trace,
}
impl HttpMethod {
pub fn from_str(m: String) -> Result<Self, InvalidHttpMethod> {
match m.as... | true |
09903c349f296e0a6c8e1a9e54b76d927aff820b | Rust | tawaren/Sanskrit | /sanskrit_core/src/model/bitsets.rs | UTF-8 | 6,326 | 3.03125 | 3 | [] | no_license | use sanskrit_common::errors::*;
use sanskrit_common::encoding::*;
use model::{Capability, Permission};
pub trait BitEntry {
fn to_mask(&self) -> u8;
}
pub trait BitSet<T:BitEntry> where Self:Sized {
fn to_bits(&self) -> u8;
fn from_bits(idx:u8) -> Self;
//generate a empty set
fn empt... | true |
05ca32c4d8d9719aa54f75d96a38141407c45a93 | Rust | SuperCleanMe/RSV | /src/tokenizer.rs | UTF-8 | 1,419 | 3.75 | 4 | [
"MIT"
] | permissive | #[derive(Debug, Copy, Clone)]
pub enum Tokens {
Escape = 0,
Delimiter = 1,
AlphaNum = 2,
NewLine = 3,
}
#[derive(Debug, Copy, Clone)]
pub struct Token {
pub value: char,
pub token_type: Tokens,
pub is_escaped: bool,
pub is_whitespace: bool,
pub id: usize,
}
impl Token {
p... | true |
9b1901a79d2c66352fcb7074f887ed9a34d73dba | Rust | shelbyd/saturdays-lobster | /src/query/mod.rs | UTF-8 | 1,323 | 3.171875 | 3 | [
"MIT"
] | permissive | extern crate core;
use self::core::str::FromStr;
use self::core::error::Error;
use self::core::fmt;
pub struct Query;
impl Query {
pub fn execute(&self) -> String {
String::from_str("PONG")
}
}
impl FromStr for Query {
type Err = ParseQueryErr;
fn from_str(string: &str) -> Result<Query, Pars... | true |
f7ee86501d993f8f9b57c49797c8ed62acabfce5 | Rust | nash-io/rust-bigint | /src/big_num_gcd.rs | UTF-8 | 6,924 | 3.046875 | 3 | [
"MIT"
] | permissive | //! Definition and implementation of ModInverse trait for num_bigint
// copied from MIT/Apache-licensed https://github.com/RustCrypto/RSA/blob/7654e6094b00f5e180bed2343a3fc47e45832b5e/src/math.rs
// because num-bigint currently does not implement modular inverse and extended euclid
// see https://github.com/rust-num/n... | true |
e7ef7055de9fb2c0f0da033bf9e3254fe79977f3 | Rust | kkragoth-mimuw/instant | /src/ast.rs | UTF-8 | 617 | 3.09375 | 3 | [] | no_license | use std::fmt;
#[derive(Debug)]
pub enum Stmt {
SAss(String, Box<Expr>),
SExpr(Box<Expr>),
}
#[derive(Debug)]
pub enum Expr {
Number(i32),
Ident(String),
Op(Box<Expr>, Opcode, Box<Expr>),
}
#[derive(Debug, PartialEq)]
pub enum Opcode {
Add,
Sub,
Mul,
Div,
}
impl fmt::Display for O... | true |
ede61024a8de770603cdebe1effd864823f8f3ae | Rust | phlip9/queue_experiments | /src/arc_cell.rs | UTF-8 | 1,393 | 3.234375 | 3 | [] | no_license | use crate::loom::sync::{atomic::AtomicUsize, Arc};
use std::{fmt, marker::PhantomData, mem, sync::atomic::Ordering};
/// A Cell for containing a strong reference
pub struct ArcCell<T> {
inner: AtomicUsize,
_marker: PhantomData<T>,
}
impl<T> ArcCell<T> {
/// Constructs an ArcCell which initially points to ... | true |
d4722af21f5693a4fcf5fd4e291233bca30d9811 | Rust | wahello/spin | /crates/http/benches/wagi-benchmark/src/main.rs | UTF-8 | 353 | 2.703125 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | fn main() {
for arg in std::env::args() {
// sleep=<ms> param simulates processing time
if let Some(ms_str) = arg.strip_prefix("sleep=") {
let ms = ms_str.parse().expect("invalid sleep");
std::thread::sleep(std::time::Duration::from_millis(ms));
}
}
println!(... | true |
3348bcefa244f78a04515c3244ec5d9e2940d4e8 | Rust | zenkimoto/asteroids-wasm | /src/scenes/game_objects/asteroids.rs | UTF-8 | 7,426 | 3.140625 | 3 | [] | no_license | use quicksilver::{
graphics::Color,
geom::Vector,
Graphics, Result
};
use rand::Rng;
use super::util::math::VectorMath;
use super::game_object::GameObject;
use crate::randf;
use crate::rand;
use crate::v;
const HIT_RADIUS: f32 = 35.0;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Sizes {
Small,
... | true |
bf58cb2fd5a7bcff419f1d2ea720b33fe2ddd9b2 | Rust | JimFawcett/RustCommExperiments | /RustComm_VariableSizeMsg/rust_thread_pool/src/lib.rs | UTF-8 | 3,749 | 3.234375 | 3 | [] | no_license | /////////////////////////////////////////////////////////////
// rust_thread_pool::lib.rs - threadpool wit BlockingQueue //
// //
// Jim Fawcett, https://JimFawcett.github.com, 29 Jun 2020 //
/////////////////////////////////////////////////////////////
/*
Thr... | true |
3b31583f380a9605e9992760ef88c50d7e9fbf60 | Rust | ferrous-systems/imxrt1052 | /src/snvs/hpsvsr/mod.rs | UTF-8 | 28,833 | 2.71875 | 3 | [] | no_license | #[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::HPSVSR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mu... | true |
e25cb1f4a098660fbcbd1a543f71bd8003105eb0 | Rust | mkulikf5/RF24-rs | /src/lib.rs | UTF-8 | 5,983 | 3.171875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! This crate provides a platform agnostic Rust driver for the nRF24L01+ single chip 2.4 GHz
//! transceiver by Nordic Semiconduct for communicating data wirelessly using the [`embedded-hal`] traits.
//!
//! [`embedded-hal`]: https://github.com/rust-embedded/embedded-hal
//!
//! # Usage
//!
//! This crate can be used ... | true |
72be21f3e4e6239b765271c1de02fdf8357a0cb0 | Rust | dorucioclea/omics | /identity/domain/user/identity.rs | UTF-8 | 1,376 | 3.28125 | 3 | [] | no_license | use common::error::Error;
use common::result::Result;
use crate::domain::user::{Email, Password, Provider, Username};
#[derive(Debug, Clone)]
pub struct Identity {
provider: Provider,
username: Username,
email: Email,
password: Option<Password>,
}
impl Identity {
pub fn new(
provider: Pro... | true |
35f8a061b9469a8356565345e05c8d767f1e9cdf | Rust | fizyk20/gps-util | /src/ublox/msg_types/ubx_rxm_rawx.rs | UTF-8 | 6,259 | 2.53125 | 3 | [] | no_license | use std::convert::{TryFrom, TryInto};
use bitflags::bitflags;
use super::GnssId;
bitflags! {
pub struct UbxRxmRawxRecvStatus: u8 {
const LEAP_SEC = 0x01;
const CLK_RESET = 0x02;
}
}
bitflags! {
pub struct UbxRxmRawxMeasurementTrkStatus: u8 {
const PR_VALID = 0x01;
const C... | true |
55360fc7d28015470f72ad3df74653dfd814f23d | Rust | ShigekiKarita/rust_nlp100 | /src/bin/nlp02.rs | UTF-8 | 268 | 2.578125 | 3 | [
"BSL-1.0"
] | permissive | extern crate rust_nlp100;
fn main() {
let a = "パトカー".to_string();
let b = "タクシー".to_string();
let mut c = String::new();
for (ca, cb) in a.chars().zip(b.chars()) {
c.push(ca);
c.push(cb);
}
println!("{}", c);
}
| true |
56ed49c86ef95abc0c05e105064903bc87762a8e | Rust | ondralukes/dgs | /near-contract/src/class.rs | UTF-8 | 2,028 | 2.828125 | 3 | [
"MIT"
] | permissive | use near_sdk::AccountId;
use near_sdk::collections::{UnorderedSet, Vector};
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use crate::grade::Grade;
#[derive(BorshDeserialize, BorshSerialize)]
pub struct Class{
name: String,
storage_id: u128,
finalized: bool,
owner: AccountId,
member... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.