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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d104e74bd84dde222b5e2b9fcd9c7e67bb0d3c41 | Rust | wisehead/rust_lib | /01.basic/12.template_trait/trait.rs | UTF-8 | 400 | 3.5625 | 4 | [] | no_license | trait Descriptive {
fn describe(&self) -> String {
String::from("[Object]")
}
}
struct Person {
name: String,
age: u8
}
impl Descriptive for Person {
fn describe(&self) -> String {
format!("{} {}", self.name, self.age)
}
}
fn main() {
let cali = Person {
name: Stri... | true |
70d33de61c77b3169c9e670f0f87d7a0cf398308 | Rust | snsvrno/lpsettings-rs | /lpsettings/src/location.rs | UTF-8 | 1,115 | 3.625 | 4 | [] | no_license | use std::fmt;
use std::env;
/// a location to be used to determine where to load a value from
#[derive(PartialEq)]
pub enum Location {
/// whatever the default recommeneded location is
Best,
// the local location
Local,
// the global location
Global
}
impl Location {
pub fn get_locati... | true |
8ccfad1db2b16428e972b7fd6f32d5670b49fe63 | Rust | AntonHermann/fntools | /src/lib.rs | UTF-8 | 4,215 | 3.46875 | 3 | [
"MIT"
] | permissive | #![cfg_attr(not(stable), feature(unboxed_closures, fn_traits))]
#[cfg(not(stable))]
/// Features that uses nightly-only unstable API
pub mod unstable;
pub mod prelude {
pub use super::{ValueExt, swap_args, chain, compose};
}
/// Represents a type which can have functions applied to it (implemented
/// by default... | true |
61e12b9e05313947e9d8592af7e5c1fab8c66f3b | Rust | Tomarchelone/mp3 | /src/header.rs | UTF-8 | 6,751 | 2.9375 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use tables::*;
use Mp3Error;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Version {
Mpeg2_5,
Reserved,
Mpeg2,
Mpeg1,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Layer {
LayerI,
LayerII,
LayerIII,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Bitrate {
Indexed(u16),
... | true |
6d7f56f8a9f61126c8012a7825b0c4f4c0858f51 | Rust | gbutler69/rust-exercism | /alphametics/src/equation/solution.rs | UTF-8 | 4,127 | 3.1875 | 3 | [] | no_license | use std::collections::HashMap;
pub struct EquationSolverBuilder(EquationSolver);
pub struct EquationSolver {
digits: Vec<EquationSolverDigit>,
digits_index: HashMap<char, usize>,
}
struct EquationSolverDigit {
digit: u8,
allow_zero: bool,
}
pub trait EquationSolution {
fn solution_for(&self, alpha_... | true |
7b0fb1c633e8b4c6e8695b1c089882b93ed412b5 | Rust | tveronezi/help_sample_runtime_block_on | /src/lib.rs | UTF-8 | 1,631 | 2.53125 | 3 | [] | no_license | pub mod docker {
use std::path::Path;
use futures_util::stream::TryStreamExt;
use hyper::Client;
use hyperlocal::{UnixClientExt, Uri};
pub async fn get_containers() -> Result<String, Box<dyn std::error::Error>> {
let path = Path::new("/var/run/docker.sock");
let url = Uri::new(path... | true |
14912a30c356f6a0474b7740fa90c6b81f04d2aa | Rust | 95th/justc | /src/symbol/table.rs | UTF-8 | 1,242 | 3.125 | 3 | [] | no_license | use crate::symbol::Symbol;
use std::collections::HashMap;
#[derive(Debug, Clone, PartialEq)]
pub struct SymbolTable<T> {
map: HashMap<Symbol, T>,
changes: Vec<(Symbol, Option<T>)>,
}
impl<T> Default for SymbolTable<T> {
fn default() -> Self {
Self {
map: HashMap::new(),
cha... | true |
7bcf1f685687d7ed78422afa2f257e96f9e517d4 | Rust | eycorsican/leaf | /leaf/src/proxy/redirect/datagram.rs | UTF-8 | 2,679 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use std::{io, net::IpAddr};
use async_trait::async_trait;
use futures::TryFutureExt;
use crate::{proxy::*, session::*};
/// Handler with a redirect target address.
pub struct Handler {
pub address: String,
pub port: u16,
}
#[async_trait]
impl OutboundDatagramHandler for Handler {
fn connect_addr(&self) ... | true |
aabf786df26eb33bd6a9d354d2e7b79a06d56e2f | Rust | bjnord/coding_practice | /hogan-57/7-struct/magic_8ball/src/main.rs | UTF-8 | 415 | 3.125 | 3 | [] | no_license | extern crate interact_io;
use interact_io::readln;
use rand::Rng;
const ANSWERS: &'static [&'static str] = &["Yes", "No", "Maybe", "Ask again later"];
fn main() {
let _question = readln::read_string("What's your question? ").unwrap();
let answer = pick_answer(4);
println!("{}.", ANSWERS[answer]);
}
fn pi... | true |
0be0a7f440a87c726b6511bc98fd592ae0456a54 | Rust | forgeyao/rust-learning | /RustByExample/9/Capturing/main.rs | UTF-8 | 1,071 | 3.65625 | 4 | [
"Apache-2.0"
] | permissive | /**
*
* https://doc.rust-lang.org/rust-by-example/fn/closures/capture.html
*/
fn main() {
use std::mem;
let color = String::from("green");
// borrow color
let print = || println!("`color`: {}", color);
print();
let _reborrow = &color;
print();
let _color_moved = color;
let ... | true |
e4e3332b8a80b5895c3c5c0a323d6df1af0cd28c | Rust | ItsaMeTuni/calendar-server | /src/env_helpers.rs | UTF-8 | 379 | 2.921875 | 3 | [] | no_license | use std::env;
pub fn get_env(name: &str) -> String
{
env::vars()
.find(|(key, _)| key == name)
.expect(&format!("Missing {} environment variable.", name))
.1
}
pub fn get_env_default(name: &str, default: &str) -> String
{
env::vars()
.find(|(key, _)| key == name)
.map(|... | true |
cab3ce545ea9e030b3e134e2eb932e1feeb7924e | Rust | iliabylich/alloc-from-pool | /src/pool.rs | UTF-8 | 959 | 2.5625 | 3 | [] | no_license | use crate::{Factory, InnerPool, PoolValue};
#[derive(Debug)]
pub struct Pool<T: 'static> {
inner: *mut InnerPool<T>,
}
impl<T> Default for Pool<T> {
fn default() -> Self {
let inner = Box::leak(Box::new(InnerPool::new()));
Self { inner }
}
}
impl<T> Pool<T> {
pub fn new() -> Self {
... | true |
f5c7a5402a8f8bd925f482c05c8f7559fc2ba724 | Rust | owen8877/leetcode-rs | /src/problem_20.rs | UTF-8 | 1,240 | 3.625 | 4 | [] | no_license | pub fn is_valid(s: String) -> bool {
let n = s.len();
if n == 0 {
return true
}
if n % 2 == 1 {
return false
}
let mut previous_pos = vec![0; n];
let chars: Vec<char> = s.chars().collect();
let mut last_position = 0;
let mut counter = 0;
for i in 0..n {
... | true |
1feedf4b072b73a36b544cffa1bb06490e2a1592 | Rust | woubuc/postage-rs | /src/sync.rs | UTF-8 | 3,693 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::sync::Arc;
use notifier::Notifier;
use ref_count::RefCount;
use std::fmt::Debug;
use crate::Context;
use self::{notifier::NotificationGuard, ref_count::TryDecrement};
pub mod mpmc_circular_buffer;
pub mod notifier;
mod oneshot_cell;
mod ref_count;
// mod rr_lock;
mod state_cell;
pub(crate) mod transfer;
p... | true |
789a85ce9da6a67c73cd2a0e673101df40f70b94 | Rust | tomhoule/tide-cookie-session | /src/lib.rs | UTF-8 | 5,810 | 2.6875 | 3 | [] | no_license | // #[deny(missing_docs)]
#![feature(associated_type_defaults)]
#![feature(async_await)]
#![feature(futures_api)]
pub mod storage;
use storage::*;
use tide_core::{error::StringError, Context, box_async};
use futures::channel::oneshot;
use futures::future::BoxFuture;
use tide_cookies::ContextExt as _;
use cookie::{Coo... | true |
da4d3e2a42cf03ed5d79d1970245f1b1a5f9c734 | Rust | Azure/iot-identity-service | /cert/cert-renewal/src/cert_interface.rs | UTF-8 | 7,484 | 2.671875 | 3 | [
"MIT"
] | permissive | // Copyright (c) Microsoft. All rights reserved.
#[async_trait::async_trait]
pub trait CertInterface {
/// Represents a key used for a new certificate. Initially returned from cert renewal as a
/// temporary key, and later written to persistent storage with the renewed cert.
type NewKey: Send + Sync;
... | true |
0ca45ea9686c71f406d0f0e14034a355bcaad5ab | Rust | tilpner/includedir | /lib/src/lib.rs | UTF-8 | 3,470 | 2.984375 | 3 | [
"BSD-3-Clause"
] | permissive | extern crate phf;
#[cfg(feature = "flate2")]
extern crate flate2;
use std::borrow::{Borrow, Cow};
use std::io::{self, BufReader, Cursor, Error, ErrorKind, Read};
use std::fs::File;
use std::sync::atomic::{AtomicBool, Ordering};
#[cfg(feature = "flate2")]
use flate2::bufread::GzDecoder;
#[derive(Debug, Clone, Copy, ... | true |
8f0c8435d2eb61e4845322ae68003b97693e31e3 | Rust | porglezomp/libgoscore | /src/lib.rs | UTF-8 | 13,220 | 3.359375 | 3 | [] | no_license | #![warn(missing_docs)]
extern crate libc;
use libc::c_char;
/// Contains bindings intended to be called from C
pub mod ffi;
// Data Structures /////////////////////////////////////////////////////////////
/// A wrapper around a `c_char` to enable accessors and setters for the
/// bitflags. A `Stone` contains inf... | true |
82e47ed1081b245c93321c72e939112bd5b928f1 | Rust | sansajn/rtest | /thread.rs | UTF-8 | 166 | 2.921875 | 3 | [] | no_license | use std::thread;
fn main() {
let t = thread::spawn(|| {
for i in 1..10 {
println!("hello {}", i);
}
});
t.join().unwrap();
} | true |
cd3e34e2cc231433da0950ac170348c8a262b90e | Rust | fluencelabs/llamadb | /cli/src/main.rs | UTF-8 | 3,803 | 2.78125 | 3 | [
"MIT"
] | permissive | #![feature(duration_span)]
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate linenoise;
extern crate llamadb;
use std::io::Write;
use std::time::Duration;
mod prettyselect;
use prettyselect::pretty_select;
fn main() {
env_logger::init().unwrap();
let mut lexer = llamadb::sqlsyntax::lex... | true |
37e2bb25681d35c1da666b5e63392f3d5502a4e4 | Rust | Mirko-von-Leipzig/interledger-rs | /crates/interledger-btp/src/packet.rs | UTF-8 | 20,394 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | use super::errors::{BtpPacketError, PacketTypeError};
use bytes::{Buf, BufMut};
use interledger_packet::{
oer::{self, BufOerExt, MutBufOerExt, VariableLengthTimestamp},
OerError,
};
#[cfg(test)]
use once_cell::sync::Lazy;
use std::borrow::Cow;
use std::str;
const REQUEST_ID_LEN: usize = 4;
pub trait Serializa... | true |
05a46703d0ddc659222e54cd374467408689fe8f | Rust | gimli-rs/object | /src/read/coff/comdat.rs | UTF-8 | 6,664 | 2.640625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::str;
use crate::endian::LittleEndian as LE;
use crate::pe;
use crate::read::{
self, ComdatKind, ObjectComdat, ReadError, ReadRef, Result, SectionIndex, SymbolIndex,
};
use super::{CoffFile, CoffHeader, ImageSymbol};
/// An iterator over the COMDAT section groups of a `CoffBigFile`.
pub type CoffBigComd... | true |
1fe4e104609f621d70bc05ab6fc26f692b70735a | Rust | Nertsal/nertsal-telegram-bot | /src/bot/users_state.rs | UTF-8 | 1,594 | 2.84375 | 3 | [] | no_license | use super::*;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct UsersState {
pub active_users: HashSet<ChatUser>,
pub chosen_users: HashSet<ChatUser>,
pub all_chosen_users: HashSet<ChatUser>,
}
impl UsersState {
pub fn new() -> Self {
Self {
active_u... | true |
ca3cc50967f8aa0385e64b78e188c56863fd1396 | Rust | JulianKnodt/nadir | /src/search.rs | UTF-8 | 2,944 | 2.765625 | 3 | [
"MIT"
] | permissive | extern crate ndarray;
use std::ops::{Mul, Add, Sub, Div};
use std::sync::Arc;
use crate::function::{Function, FunctionGradient};
use crate::line_search::{golden_section_search};
use self::ndarray::{Ix, Ix1, Ix2};
/// The set of possible strategies to pick from
pub enum Strategy {
BFGS,
}
struct BFGS<A>
where A:... | true |
734feadb6e5b8e1bca0ea69c91beff9456fe3e4a | Rust | Drevoed/narwhalol | /src/constants/ranked_tier.rs | UTF-8 | 2,309 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::convert::AsRef;
use std::fmt;
use Inner::*;
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct RankedTier(Inner);
#[derive(Clone, PartialEq, Eq, Hash)]
enum Inner {
Iron,
Bronze,
Silver,
Gold,
Platinum,
Diamond,
Master,
Grandmaster,
Challenger,
}
impl RankedTier {
pub c... | true |
67c3209c9fa1436a4f0a3fabd9cbb541172b4bba | Rust | SalDev40/Rust | /dataStructures/src/libs/binaryTree.rs | UTF-8 | 2,789 | 3.4375 | 3 | [] | no_license | #![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
use std::fmt::{Debug, Display};
use std::io::{Error, ErrorKind};
#[derive(Debug)]
pub struct Node<T> {
data: T,
left: BinTree<T>,
right: BinTree<T>,
}
#[derive(Debug)]
pub enum BinTree<T> {
NonEmptyTree(Box<Node<T>>),
Empty... | true |
5a1bf3bff700c1ae7f911fbcb2e2f47c719341d9 | Rust | luoxiangyong/travis-rust-demo | /src/main.rs | UTF-8 | 119 | 2.765625 | 3 | [] | no_license |
fn add(a:i64,b:i32) -> i64 {
a + b as i64
}
fn main() {
println!("The Add结果是:{}", add(100i64,1000));
}
| true |
c3b5f4d26e2684765a0ce8d04c95be8b79662244 | Rust | microsoft/rust_win_etw | /win_etw_provider/src/types.rs | UTF-8 | 3,711 | 2.578125 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT"
] | permissive | //! Contains items that are part of the implementation of `win_etw`, but not intended to be used
//! directly by application code. Only code generated by the `trace_logging_provider` macro
//! should use these types.
#![doc(hidden)]
pub use widestring::{U16CStr, U16CString};
use crate::EventDataDescriptor;
use zeroco... | true |
b419347512a098eef217faf5cfe4d051c7d83867 | Rust | lelongg/ros_package_manifest | /src/tags/license.rs | UTF-8 | 607 | 2.75 | 3 | [] | no_license | use roxmltree::Node;
use std::convert::TryFrom;
use thiserror::Error;
#[derive(Default, Debug, Clone, PartialEq)]
pub struct License {
pub license: String,
pub file: Option<String>,
}
#[derive(Debug, Clone, Error)]
pub enum LicenseError {
#[error("no license")]
NoLicense,
}
impl TryFrom<Node<'_, '_>>... | true |
bb615b28999bf96244f618372e5bd5acb8f0e73c | Rust | felixwatts/harvest | /src/evaluator.rs | UTF-8 | 3,748 | 2.859375 | 3 | [] | no_license | use crate::plan::Plan;
use crate::constant::SEASON_LENGTH;
use crate::tasks::Tasks;
use crate::params::Params;
use crate::bed_plan::BedPlan;
pub struct Evaluator<'a> {
params: &'a Params,
plan: &'a Plan
}
impl<'a> Evaluator<'a> {
pub fn new(
params: &'a Params,
plan: &'a Plan) -> Self {
... | true |
cfe6731be43866e6e04704a4876f0e42d921c4f5 | Rust | 18616378431/myCode | /rust/test3-30/src/main.rs | UTF-8 | 410 | 3.765625 | 4 | [] | no_license | //为新类型实现Add操作
use std::ops::Add;
#[derive(Debug)]
struct Point {
x : i32,
y : i32,
}
impl Add for Point {
type Output = Point;
fn add(self, other : Point) -> Point {//Point Self Self::Output
Point {
x : self.x + other.x,
y : self.y + other.y,
}
}
}
fn main... | true |
cf427472b15f6687eaeb737ff0b1bbfa350d3828 | Rust | icub3d/puzzles | /advent-of-code/2020/day24/src/main.rs | UTF-8 | 2,753 | 3.296875 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{BufRead, BufReader};
fn moves(s: String) -> Vec<String> {
let mut mm = vec![];
let mut it = s.chars();
loop {
let cur = it.next();
match cur {
None => break,
Some(c) => {
if c... | true |
4080abbb571f6c546913e96eaa85b736dad13764 | Rust | Lukazoid/lz_quic | /src/packets/incoming_packet.rs | UTF-8 | 368 | 2.53125 | 3 | [] | no_license | use bytes::Bytes;
use chrono::{DateTime, UTC};
use packets::PacketHeader;
use std::net::SocketAddr;
/// An incoming packet before any decryption has taken place.
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct IncomingPacket {
pub source_address: SocketAddr,
pub packet_header: PacketHeader,
pub dat... | true |
a432a84912c410f987f102169cfe9c980185a51d | Rust | timmonfette1/rustworking-cli | /src/main.rs | UTF-8 | 5,906 | 2.90625 | 3 | [
"MIT"
] | permissive | /* rustworking-cli
*
* Command line tool to handle network tasks for
* system administration. Has the ability to perform
* various tasks in bulk
*
* Currently supports:
* PING an IP address (single or in bulk)
*
* Coming soon:
* Send a TCP packet to test a connection
* Send a UDP packet to tes... | true |
e52aba90f1dc63dfc01077e5ef91f1f691eb4701 | Rust | mknaw/jrnl | /src/time.rs | UTF-8 | 5,091 | 3.5625 | 4 | [] | no_license | use std::fmt;
/// Week days
#[derive(Copy, Clone, PartialEq)]
pub enum WeekDay {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday,
}
pub const WEEKDAYS: [WeekDay; 7] = [
WeekDay::Monday,
WeekDay::Tuesday,
WeekDay::Wednesday,
WeekDay::Thursday,
WeekDay::Fr... | true |
817443bde66fdf83821d0bfcd9fca290699e2834 | Rust | theemathas/binary_turk | /game/src/pos/legal.rs | UTF-8 | 1,844 | 3 | 3 | [
"MIT"
] | permissive | use std::iter;
use square::Square;
use moves::Move;
use super::Position;
pub struct Iter<'a>(iter::Chain<NoisyIter<'a>, QuietIter<'a>>);
impl<'a> Iterator for Iter<'a> {
type Item = Move;
fn next(&mut self) -> Option<Move> { self.0.next() }
fn size_hint(&self) -> (usize, Option<usize>) { self.0.size_hint... | true |
83aad82ba2c21b00748e13c855cd0b265bea7afc | Rust | hershi/cryptopals_rust | /utils/src/lib.rs | UTF-8 | 1,839 | 2.59375 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
pub mod english_scoring;
pub mod encoding;
pub mod encryption;
pub mod repeating_xor_cracker;
pub mod mt19937;
pub mod sha1;
pub mod md4;
pub mod hmac;
pub mod hash_utils;
pub mod diffie_hellman;
pub fn xor(input: &[u8], key: &[u8]) -> Vec<u8> {
input
.iter()
... | true |
36c3b05c686b004a33a4dc2d893ecce95478a343 | Rust | pdx-cs-rust/rust-misc | /stacktrait/examples/demo.rs | UTF-8 | 250 | 2.96875 | 3 | [
"MIT"
] | permissive | use stacktrait::*;
use std::collections::LinkedList;
fn main() {
let mut s = Vec::new();
s.spush(&5);
println!("{}", s.spop().unwrap());
let mut s = LinkedList::new();
s.spush("hello");
println!("{}", s.spop().unwrap());
}
| true |
b79e044c0c9ef80fc7b44a0ab88141c5b4272ff3 | Rust | little-dude/netlink | /netlink-packet-generic/src/traits.rs | UTF-8 | 1,160 | 2.578125 | 3 | [
"MIT",
"MITNFA"
] | permissive | // SPDX-License-Identifier: MIT
//! Traits for implementing generic netlink family
/// Provide the definition for generic netlink family
///
/// Family payload type should implement this trait to provide necessary
/// informations in order to build the packet headers (`nlmsghdr` and `genlmsghdr`).
///
/// If you are ... | true |
e954b246d17cfaf613549c0c87fb11bca588da8f | Rust | ottingbob/rust-dojo | /12-scopes/12-3-3-aliasing.rs | UTF-8 | 1,085 | 3.90625 | 4 | [] | no_license |
struct Point { x: i32, y: i32, z: i32 }
fn main() {
let mut point = Point { x: 0, y: 0, z: 0 };
let borrowed_point = &point;
let another_borrow = &point;
println!("Point has coordinates: ({}, {}, {})",
borrowed_point.x, another_borrow.y, point.z);
// Cant borrow point as mutable because its current... | true |
b4e9cf8314c0ececd024661877c03037b7f83c82 | Rust | razn-v/rasm | /src/register.rs | UTF-8 | 2,272 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::str::FromStr;
/// List of available registers
#[derive(PartialEq, Eq)]
pub enum Register {
R0,
R1,
R2,
R3,
R4,
R5,
R6,
R7,
R8,
R9,
R10,
R11,
R12,
R13,
R14,
R15,
CPSR,
SPSR,
}
impl FromStr for Register {
type Err = ();
fn from_st... | true |
4d01e9038a9acc8d7e69e97113fd43bc7482e836 | Rust | copvampire/wooting_snake | /src/sound_manager.rs | UTF-8 | 2,923 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | use rand::Rng;
use rodio;
use rodio::Device;
use rodio::Source;
use std::collections::HashMap;
use std::fs::File;
use std::convert::AsRef;
use std::io;
use std::io::prelude::*;
use std::sync::Arc;
type Sounds = Vec<Sound>;
type SoundsMap = HashMap<SoundType, Sounds>;
#[derive(Eq, PartialEq, std::hash::Hash, Clone, C... | true |
072456465b1a7e17893f163530fdb7cff037ef38 | Rust | maidsafe/safe_network | /sn_networking/src/circular_vec.rs | UTF-8 | 2,039 | 3.28125 | 3 | [] | no_license | // Copyright 2023 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... | true |
367b3753c52fd8fc18d92ac0b793b4364a8c34d9 | Rust | Aleman778/First-Compiler | /src/ir.rs | UTF-8 | 38,652 | 3.25 | 3 | [] | no_license | use std::collections::HashMap;
use std::fmt;
use crate::ast::*;
use crate::intrinsics;
/**
* Used for building low-level intermediate representation.
*/
pub struct IrBuilder<'a> {
pub file: Option<&'a File>,
pub instructions: Vec<IrInstruction>,
pub functions: HashMap<IrIdent, IrBasicBlock>,
pub addr... | true |
8ef68a40c22d49310d568a72883f9f39e4d019ef | Rust | rxRust/rxRust | /src/ops/future.rs | UTF-8 | 4,145 | 3.34375 | 3 | [
"MIT"
] | permissive | use std::{
cell::RefCell,
fmt::Display,
task::{Context, Poll},
};
use futures::{
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
ready, Future, FutureExt, StreamExt,
};
use crate::{observable::Observable, observer::Observer};
/// Errors that can prevent an observable future from resolving c... | true |
74712b5ffa22c40995cc19f9b0bb598daadb71b5 | Rust | PoorlyDefinedBehaviour/data-structures-and-algorithms | /rust/data_structures/stack_of_plates/main.rs | UTF-8 | 1,780 | 3.796875 | 4 | [
"MIT"
] | permissive | // Stack of Plates: Imagine a (literal) stack of plates. If the stack gets too high, it might topple.
// Therefore, in real life, we would likely start a new stack when the previous stack exceeds some
// threshold. Implement a data structure SetOfStacks that mimics this. SetOfStacks should be
// composed of several sta... | true |
ab2ade7e0e4cda638549f9abb01276c190ed9ea2 | Rust | tesseract-one/Keychain.rs | /keychain-c/src/utils/panic.rs | UTF-8 | 811 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use error::ErrorPtr;
use keychain::Error;
use std::panic;
pub fn handle_exception<F: FnOnce() -> R + panic::UnwindSafe, R>(func: F) -> Result<R, ErrorPtr> {
handle_exception_result(|| Ok(func()))
}
pub fn handle_exception_result<F: FnOnce() -> Result<R, Error> + panic::UnwindSafe, R>(
func: F
) -> Result<R, Error... | true |
cba64be00d95d78664ada58d2afa49e26eba981d | Rust | lfdominguez/elastic | /src/elastic/src/client/responses/tests/document_delete/mod.rs | UTF-8 | 808 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{
client::responses::*,
http::{
receiver::parse,
StatusCode,
},
};
#[test]
fn success_parse_found_response() {
let f = include_bytes!("delete_found.json");
let deserialized = parse::<DeleteResponse>()
.from_slice(StatusCode::OK, f as &[_])
.unwrap();
... | true |
ab88082704fa22396e781055d5257bc2c5cf92ae | Rust | bieganski/distributed | /dslab03/main.rs | UTF-8 | 612 | 2.59375 | 3 | [] | no_license | mod public_test;
mod solution;
use std::env;
use std::process;
fn parse_args() -> usize {
let args: Vec<String> = env::args().collect();
match args.len() {
1 => 10,
2 => match args.get(1).unwrap().parse() {
Ok(n) => n,
Err(_) => {
println!("Not an unsign... | true |
6238b56e96dc06eb17d072fe5ef3fcb78b893e38 | Rust | sm921/pattern-making | /pmdraw/src/drawing.rs | UTF-8 | 4,385 | 2.984375 | 3 | [] | no_license | use std::f64::consts::PI;
// #[cfg(not(target_arch = "wasm32"))]
// use pmrender::show_lines;
use pmrender::show_lines;
use crate::shapes::{bezier::Bezier, circle::Circle, line::Line, point::Point, Shape};
#[derive(Clone)]
pub struct Drawing {
/// canvas width in centimeters
pub width: f64,
/// canvas h... | true |
6a258c7b90dcf52837c688b579af9d35f5a90bc9 | Rust | JacobHenner/cargo | /src/cargo/util/sha256.rs | UTF-8 | 4,337 | 2.53125 | 3 | [
"GPL-2.0-only",
"Apache-2.0",
"OpenSSL",
"MIT",
"GCC-exception-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"curl",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"Unlicense",
"LGPL-2.1-only"
] | permissive | pub use self::imp::Sha256;
// Someone upstream will link to OpenSSL, so we don't need to explicitly
// link to it ourselves. Hence we pick up Sha256 digests from OpenSSL
#[cfg(not(windows))]
#[allow(bad_style)]
mod imp {
use libc;
enum EVP_MD_CTX {}
enum EVP_MD {}
enum ENGINE {}
extern {
... | true |
e2c3a8262f85b40a7619b179fdc2c03427618289 | Rust | gaultier/kotlin-rs | /tests/var.rs | UTF-8 | 4,785 | 3.15625 | 3 | [] | no_license | use kotlin::compile::sexp;
use kotlin::error::*;
use kotlin::parse::Type;
#[test]
fn simple_var() {
let src = "var a = 1;";
let mut out: Vec<u8> = Vec::new();
assert!(sexp(src, &mut out).is_ok());
assert_eq!(
std::str::from_utf8(&out).as_mut().unwrap().trim(),
"(define a 1)"
);
}
... | true |
d3a30c9f0c193f2c8f4989f10d5c3e0db6476b0e | Rust | tychedelia/franz | /franz_protocol/src/types.rs | UTF-8 | 46,089 | 2.859375 | 3 | [] | no_license | use std::string::String as StdString;
use std::hash::Hash;
use indexmap::IndexMap;
use string::TryFrom;
use super::{DecodeError, EncodeError, Encoder, Decoder, Encodable, Decodable, MapEncodable, MapDecodable, NewType, StrBytes};
use crate::buf::{ByteBuf, ByteBufMut};
macro_rules! define_copy_impl {
($e:ident, $... | true |
cf2133479be952500d772834d9b968ddf9b493db | Rust | HaronK/aoc2019 | /task17_1/src/main.rs | UTF-8 | 1,234 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::robot::*;
use anyhow::{anyhow, Result};
use common::log::*;
use std::fs::File;
use std::io::{prelude::*, BufReader};
mod robot;
fn main() -> Result<()> {
let log = Log::new(false);
let file = File::open("input.txt")?;
let reader = BufReader::new(file);
let prog_str = reader
.lines()... | true |
baf54efb8f2e86e00336d4311aa1adf755d341a9 | Rust | clap-rs/thunder | /examples/thor.rs | UTF-8 | 861 | 3.328125 | 3 | [] | no_license | //! Thor is the god of thunder
#![feature(proc_macro)]
extern crate clap;
extern crate thunder;
use thunder::thunderclap;
struct Thor;
/// An application that shoots lightning out of its hands
#[thunderclap(drunk: bool: "Bla bla bla")]
impl Thor {
/// Say hello to someone at home
fn hello(name: &str, times: O... | true |
b9f50448f1cfcca977908f4f4319b8e6fc3c401c | Rust | jlgerber/jobsyspolice | /src/jspt/parser/node.rs | UTF-8 | 16,692 | 2.953125 | 3 | [] | no_license | use nom::{
IResult,
branch::alt,
sequence::{tuple,preceded, delimited},
bytes::complete::{tag},
combinator::{ map, },
character::complete::{char, space0, multispace0, },
};
use crate::jspt::helpers::*;
use crate::jspt::{Node, ParseResult, parse_metadata};
/// Parses a Node given an input str. ... | true |
87e232e90c3d371ba12a1692e6de210963065d58 | Rust | AdelaideAuto-IDLab/bTracked | /tracking/src/filter_runner.rs | UTF-8 | 8,601 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use glm::{self, vec3, Vec3};
use rand::{self, Rng, FromEntropy, rngs::SmallRng, distributions::StandardNormal};
use stats;
use particle_filter::{Filter, ParticleFilter};
use {
signal::MeasurementModel,
geometry::World,
distance_field::DistanceField,
util, TrackingConfig, FilterConfig, ModelConfig, Mea... | true |
32a2884d4af3fdc6bb2b5eb796caaecfe5432f5f | Rust | barneyb/rust_playground | /src/aoc_2019_01.rs | UTF-8 | 1,170 | 3.421875 | 3 | [] | no_license | use crate::cli;
use crate::fs;
pub fn run() {
let masses: Vec<usize> = fs::read_lines(cli::aoc_filename("aoc_2019_01.txt"), |l| {
l.parse::<usize>().unwrap()
})
.unwrap();
let fuel: usize = masses.iter().map(needed_fuel).sum();
println!("Fuel needed: {}", fuel);
let fuel: usize = mas... | true |
c5739e58efa8263f3dba3ab7dfcd3f9f29f5edb5 | Rust | rust-lang-ja/rust-by-example-ja | /src-old/error/result_map/result.rs | UTF-8 | 1,147 | 4.09375 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::num::ParseIntError;
// 返り値の型を書き直し、`unwrap()`を用いないパターンマッチに変更したが、
// まだ少しごちゃごちゃしている。`Option`の場合と同様に
// スッキリさせられないだろうか?答えはYes
fn double_number(number_str: &str) -> Result<i32, ParseIntError> {
match number_str.parse::<i32>() {
Ok(n) => Ok(2 * n),
Err(e) => Err(e),
}
}
// 上と全く同じ機能を、`map(... | true |
02c698ae58a0d2b9405f871fe410ec2aa3a59791 | Rust | moon-cat-liquid/link | /src/lib.rs | UTF-8 | 21,498 | 3.90625 | 4 | [] | no_license | //! 这是一个rust的单向链表的实现,本链表实现了集合的基本功能。
/// 链表结构体
#[derive(Clone)]
pub struct Link<T> (Option<Box<Node<T>>>);
///节点结构体
#[derive(Clone)]
pub struct Node<T> {
pub value: T,
next: Link<T>,
}
impl<T> Node<T> {
/// 创建节点
fn new(value:T, data: Option<Box<Self>>) -> Self {
Self {value, next: Li... | true |
d431492663da84ab23dbaa24d76fea128e957c4a | Rust | ttys3/mdcat | /src/terminal/terminology.rs | UTF-8 | 2,873 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required ... | true |
9fb21573908714911ebe7cc318f9f123c4da8ef8 | Rust | DarkKowalski/gameboy | /src/timer.rs | UTF-8 | 3,694 | 3.53125 | 4 | [
"WTFPL"
] | permissive | // Sometimes it's useful to have a timer that interrupts at regular intervals for routines that require periodic or
// percise updates. The timer in the GameBoy has a selectable frequency of 4096, 16384, 65536, or 262144 Hertz.
// This frequency increments the Timer Counter (TIMA). When it overflows, it generates an in... | true |
155c8198f892eaf337fe2b06d0d858b18d60308b | Rust | rodrimati1992/core_extensions | /core_extensions_proc_macros/src/derive/transparent_newtype_derive/tn_attribute_parsing.rs | UTF-8 | 3,878 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::derive::{
attr_parsing::{self, AttrParsing, SharedConfig, ParseCtx},
utils::Empty,
DataStructure, Field, ParseBufferExt,
};
use proc_macro2::Span;
use syn::{
parse::ParseBuffer,
Attribute,
};
pub(super) struct WrappedField<'a> {
pub(super) field: &'a Field<'a>,
pub(super) tran... | true |
8c3f9d7f519e11383818caf9110a9e499463b791 | Rust | keeslinp/rust_invaders | /src/main_state.rs | UTF-8 | 2,043 | 3.203125 | 3 | [] | no_license | extern crate ggez;
use ggez::event;
use ggez::event::Keycode;
use ggez::event::Mod;
use ggez::{GameResult, Context};
use ggez::graphics;
use std::rc::Rc;
use std::time::Duration;
use states::menu_state::MenuState;
use states::play_state::PlayState;
use std::collections::HashMap;
use states::GameState;
// First we make ... | true |
8f1c43ef57d4f4240dfbb4f81dfe167c966950a9 | Rust | zackw/openvpn_netns_tools | /src/subprocess.rs | UTF-8 | 3,125 | 2.75 | 3 | [] | no_license | /// Subprocess management.
use std::io;
use std::num;
use std::str;
use std::io::Write;
use std::process::{Child,Command,Stdio,ExitStatus};
use nix::sys::signal::SigSet;
//use nix::sys::signal::SIG_SETMASK;
//use std::os::unix::process::CommandExt;
use libc::pid_t;
use err::*;
#[allow(dead_code)] // until we turn s... | true |
e58bdb8ee4d757a1c1134b897aae90f080bf2593 | Rust | ST92/secondary-control-keyboard | /src/main.rs | UTF-8 | 5,517 | 3 | 3 | [] | no_license | /*!
Xorg input device grabbing utility
Claims all input from an USB keyboard to use it's keys to perform utility functions
for me, regardless of what's on my screen or what window has focus.
made by Supersonic Tumbleweed to teach myself Rust while solving a real problem.
*/
mod inputs;
mod xorg_functionality;... | true |
4b3bff5d4cf69527cbabb03e1d899d06c3e5a2d3 | Rust | 0xb10ckdev/forest | /benches/example-benchmark.rs | UTF-8 | 1,519 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
fn fibonacci_slow(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
n => fibonacci_slow(n - 1) + fibonacci_slow(n - 2),
}
}
fn fibona... | true |
89779142fa637026a3fa3840b9965eddc7679a14 | Rust | seanpianka/leetcode-rust | /src/greedy/candy.rs | UTF-8 | 595 | 3.453125 | 3 | [] | no_license | /// https://leetcode.com/problems/candy/
fn candy(ratings: Vec<i32>) -> i32 {
let n = ratings.len();
// 首先每个孩子至少要给1个糖果
let mut nums = vec![1; n];
// 先看每个孩子的左边情况,如果当前孩子比左边的成绩更好,则理应比左边的多一个糖果
for i in 1..n {
if ratings[i] > ratings[i - 1] {
nums[i] = nums[i - 1] + 1;
}
}... | true |
2d2e8937a49c239c2ae2864d12ddacacca5c09e3 | Rust | akusumoto/xbook-deployer | /src/main.rs | UTF-8 | 3,592 | 3.0625 | 3 | [] | no_license | use std::env;
use std::path::{PathBuf};
use std::fs;
use std::io;
use std::io::Write;
extern crate fs_extra;
use fs_extra::file;
extern crate regex;
use regex::Regex;
fn load_args() -> Result<(PathBuf, PathBuf), String> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
Err(String:... | true |
73fcfe3d5fe8376bfd8cd51e9beb365e76af3bb5 | Rust | denis-gudim/rust-algo | /src/sort/quick_sort_hoare.rs | UTF-8 | 765 | 3.140625 | 3 | [] | no_license | pub fn sort<T: Ord>(list: &mut [T], low: usize, high: usize) {
if high > low {
let mut i = low;
let mut j = high;
loop {
while list[i] < list[low] { i += 1 }
while list[j] > list[low] { j -= 1 }
if i >= j { break }
list.swap(i, j);
i += 1;
j -= 1;
}
sort(list, low, j);
sort(list, j... | true |
45fee673166edcf19865c92b25c24bca6bbfd134 | Rust | likr/atcoder | /abc149/src/bin/f.rs | UTF-8 | 2,396 | 2.890625 | 3 | [] | no_license | use proconio::input;
use std::collections::HashSet;
const M: usize = 1000000007;
fn count_children(
graph: &Vec<Vec<usize>>,
u: usize,
nodes: &mut Vec<usize>,
leaves: &mut Vec<usize>,
visited: &mut HashSet<usize>,
) {
visited.insert(u);
nodes[u] = 1;
leaves[u] = if graph[u].len() == 1 ... | true |
41cb89f8fdd1a9432d122dad38f76379db78718b | Rust | althonos/uniprot.rs | /src/uniref/model/reference.rs | UTF-8 | 1,043 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::io::BufRead;
use crate::error::Error;
use crate::parser::utils::decode_attribute;
use crate::parser::FromXml;
use quick_xml::events::BytesStart;
use quick_xml::Reader;
use super::Property;
/// A UniRef database reference.
#[derive(Debug, Clone)]
pub struct Reference {
pub id: String,
pub ty: String,... | true |
2f81f69df056e2f51565d5e2e5063ddf90cd03cd | Rust | untoldwind/razer_test_test | /src/cli/set_color.rs | UTF-8 | 230 | 2.546875 | 3 | [] | no_license | use devices::{self, Color};
use errors::Result;
pub fn set_color(color: Color) -> Result<()> {
for device in devices::list_devices()? {
println!("{} {:?}", device.name(), device.set_color(color));
}
Ok(())
}
| true |
72dd33f38735dbebec24d4a956c822b768046ccc | Rust | FrazAli/aoc | /2022/d01/src/main.rs | UTF-8 | 1,028 | 3.53125 | 4 | [] | no_license | use std::fs::File;
use std::io::Read;
struct Elf {
calories: Vec<usize>,
total: usize,
}
fn main() {
let mut file: File = File::open("input.txt")
.expect("Unable to open the file");
let mut data: String = String::new();
file.read_to_string(&mut data)
.expect("Unable to read the fil... | true |
88b5b4cc48360b5d75ac020de6e607081592768d | Rust | RobinThrift/befunge-rs | /src/parser.rs | UTF-8 | 646 | 3.40625 | 3 | [] | no_license |
pub fn parse(code: Vec<String>) -> Vec<Vec<String>> {
let mut tokens = Vec::new();
for l in code.iter() {
let mut line_tokens = Vec::new();
for c in l.as_slice().chars() {
line_tokens.push(c.to_string());
}
tokens.push(line_tokens);
}
return tokens;
}
#[c... | true |
b02ae1605ed21b03abbe18bf87820409aea13238 | Rust | dawidovsky/IIUWr | /Rust/L1/zad3/src/main.rs | UTF-8 | 699 | 3.59375 | 4 | [] | no_license | fn main() {}
fn square_area_to_circle(size:f64) -> f64 {
size/4.0 * std::f64::consts::PI
}
fn assert_close(a:f64, b:f64, epsilon:f64) {
assert!( (a-b).abs() < epsilon, format!("Expected: {}, got: {}",b,a) );
}
#[test]
fn test1() {
assert_close(square_area_to_circle(9.0), 7.0685834705770345, 1e-8);
}
#[t... | true |
78c1d194178a323b16b35ec79e5c5ca4260f92d6 | Rust | zandeck/Amalia_fork | /src/vertex_computation/compute.rs | UTF-8 | 2,523 | 2.5625 | 3 | [] | no_license | use md5::md5mesh::*;
use cgmath::{Vector3, InnerSpace};
use vertex_computation::convert::generate_indices;
pub fn prepare_mesh(m: &Mesh, v_joints: &Vec<Joint>) -> Vec<Vector3<f32>> {
let mut position_buffer : Vec<Vector3<f32>> = Vec::new();
for vertice in &m.vertices {
let mut new_vertice : Vec... | true |
6fd322a5e70567f4b0b3872b615a1353a399fc37 | Rust | jsdelivrbot/euler_criterion.rs | /problems/013/013.rs.broken | UTF-8 | 976 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![feature(slicing_syntax)]
extern crate num;
extern crate test;
extern crate time;
use num::bigint::BigUint;
use std::io::{File, stdio};
use std::iter::AdditiveIterator;
use std::os;
fn solution(input: &str) -> String {
input.
lines().
filter_map(|line| from_str::<BigUint>(line.trim())).
... | true |
c7ae8481a3aeadfc7ce5618e3a7a0a09207a1140 | Rust | zjw1918/proj-rust-minigrep | /src/zjw_learn/smart_pointer.rs | UTF-8 | 6,570 | 3.140625 | 3 | [] | no_license | use self::List::{ Cons, Nil };
use self::ListRc::{ ConsRc, NilRc };
use self::ListRf::{ ConsRf, NilRf };
use self::List1::{ Cons1, Nil1 };
use std::ops::Deref;
use std::rc::{Rc, Weak};
use std::cell::RefCell;
pub fn run() {
// let list = Cons(1,
// Box::new(Cons(2,
// Box::new(Cons(3,
//... | true |
7bd3442a0b07eee76e6c15ce793d1921bf03cacc | Rust | jcdyer/rawbson | /src/lib.rs | UTF-8 | 64,002 | 3.46875 | 3 | [
"MIT"
] | permissive | /*!
A rawbson document can be created from a `Vec<u8>` containing raw BSON data, and elements
accessed via methods similar to those in the [bson-rust](https://crates.io/crate/bson-rust)
crate. Note that rawbson returns a Result<Option<T>>, since the bytes contained in the
document are not fully validated until trying ... | true |
c26895c9e6d879deb07ad8ee0bd6d55e6845a57f | Rust | 0ndorio/advent-of-code | /2018/aoc07/src/step.rs | UTF-8 | 1,575 | 3.09375 | 3 | [
"Unlicense"
] | permissive | use std::{
cell::RefCell,
cmp::Ordering,
collections::HashSet,
hash::{Hash, Hasher},
ops::Deref,
rc::Rc,
};
#[derive(Ord, PartialOrd, Eq, Clone)]
pub struct StepCell(pub Rc<RefCell<Step>>);
impl StepCell {
pub fn new(step: Step) -> Self {
Self {
0: Rc::new(RefCell::new(... | true |
4f669ab69caa4db54d2acaf5ed29178235425840 | Rust | Ummon/AdventOfCode2019 | /src/day10.rs | UTF-8 | 6,415 | 3.046875 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
pub fn read_map(raw: &str) -> Vec<(i32, i32)> {
let lines: Vec<&str> = raw.lines().map(|l| l.trim()).collect();
let mut map = Vec::<(i32, i32)>::new();
for x in 0 .. lines[0].len() {
for (y, line) in lines.iter().enumerate() {
if line.chars().nt... | true |
c2a46cd4462f7810751562de6a6a354ad540533a | Rust | MagneticMartian/specaneca | /src/main.rs | UTF-8 | 3,203 | 2.8125 | 3 | [] | no_license | use rand::Rng;
use std::f64::consts::PI;
use num::complex::Complex;
use plotlib::page::Page;
use plotlib::repr::Plot;
use plotlib::view::ContinuousView;
use plotlib::style::{PointMarker, PointStyle};
static STEPS: usize = 100;
static COLS: usize = 700;
static PERIODS: usize = 1024;
fn linspace(start: f64, stop: f64, ... | true |
0b835c452915276a61f8a7490bca717b698c4f78 | Rust | informationsea/xlsxwriter-rs | /libxlsxwriter/src/format.rs | UTF-8 | 19,416 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use crate::{CStringHelper, XlsxError};
#[allow(clippy::unreadable_literal)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum FormatColor {
Black,
Blue,
Brown,
Cyan,
Gray,
Green,
Lime,
Magenta,
Navy,
Orange,
Purple,
Red,
Pink,
Silver,
... | true |
4342ed16889a0d4d60a83a9a8ffe70492b357b35 | Rust | Shipica/Shipica.github.io | /shipico/src/old/widget/common.rs | UTF-8 | 3,243 | 2.875 | 3 | [
"MIT"
] | permissive | //! TODO rename this module maybe?
//!
//! Common is not the best name for it, but i don't know
//! what is better
use web_sys::DomMatrix;
use crate::{
canvas::Canvas,
math::{Matrix, Vec2},
};
use super::Widget;
// ----------------------------------------------------------------
// Transform
// ------------... | true |
10bd1f652916b53c03fcd2ef2828d88b56e40bfa | Rust | shakyShane/dsa | /src/balanced_recursive.rs | UTF-8 | 1,220 | 3.703125 | 4 | [] | no_license | use std::str::Chars;
fn balanced_recursive(input: &str) -> bool {
expect(None, &mut input.chars())
}
fn expect(end: Option<char>, input: &mut Chars) -> bool {
loop {
let c = input.next();
let good = match c {
Some('(') => expect(Some(')'), input),
Some('[') => expect(So... | true |
074944b37af08045b7c576b2a1be84c1ca5e7636 | Rust | madmax28/aoc2019 | /src/day16/mod.rs | UTF-8 | 2,017 | 3.203125 | 3 | [] | no_license | #[derive(Debug)]
enum Error {
InvalidInput,
}
const BASE: &[i32] = &[0, 1, 0, -1];
fn fft(values: &mut Vec<i32>, skip: usize) {
let init = values.clone();
let total_len = init.len() + skip;
for idx in 0..init.len() {
let phase = skip + idx;
if phase <= total_len / 3 {
val... | true |
cbb2031a7bd88fe5669cba1f7eec7300fc121986 | Rust | ftsell/pixelflut | /rust/src/net/mod.rs | UTF-8 | 2,212 | 2.5625 | 3 | [
"MIT"
] | permissive | //!
//! Networking layer for pixelflut servers and clients as well as on-the-wire protocol handling
//!
use std::convert::TryFrom;
use anyhow::Result;
use bytes::{Buf, Bytes};
use crate::net::framing::Frame;
use crate::pixmap::traits::{PixmapBase, PixmapRead, PixmapWrite};
use crate::pixmap::SharedPixmap;
use crate:... | true |
7601f0df15931f43f89c71f4dd3c3073b8d197b4 | Rust | MichelleJiam/AdventofCode2020 | /D02/d02a.rs | UTF-8 | 748 | 3.265625 | 3 | [] | no_license | use std::fs::File;
use std::io::Read;
fn main() {
let mut file = File::open("d02-input").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut valid_pass = 0;
for line in input.lines() {
let line2 = &line.replace(":", " ");
let chunks: Vec<_> = line2.split_whitespace().co... | true |
6326210a496ac4f0d08dc7b41aad2b59269892e8 | Rust | fulmicoton/irc-search-index | /src/index.rs | UTF-8 | 2,498 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::path::Path;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use std::time::Instant;
use tantivy::Index;
use tantivy::schema::*;
use walkdir::WalkDir;
use regex::Regex;
use errors::*;
lazy_static! {
static ref RE: Regex = Regex::new(r"(?x)
(?P<time>\d{2}:\d{2})\s
[+@&]?
... | true |
f837f8be6722c37e0bbf54bf4a339ea2ee8cac8f | Rust | ebkalderon/deck | /deck-core/src/manifest.rs | UTF-8 | 10,367 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Reproducible package manifest data.
pub use self::sources::Source;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::{Display, Error as FmtError, Formatter, Result as FmtResult};
use std::str::FromStr;
use serde::{Deserialize, Serialize};
use toml::de::Error as DeserializeError;
use self::outputs::Outpu... | true |
1a921fd919cfc7152ea42df29f4d0c2c8cc69ff6 | Rust | southball/judge-controller | /src/util.rs | UTF-8 | 1,508 | 3.015625 | 3 | [] | no_license | use futures_util::stream::{Stream, StreamExt};
use std::io::Write;
pub async fn write_stream_to_file<'a, T>(
stream: &mut T,
path: &'a std::path::Path,
) -> Result<(), Box<dyn std::error::Error>>
where
T: Stream<Item = reqwest::Result<bytes::Bytes>> + std::marker::Unpin,
{
let mut file = std::fs::File:... | true |
02ead2dd85173f697f302069c5fed79fe7eab8bc | Rust | TomaszWaszczyk/kernel-from-scratch | /src/gdt/segment_descriptor.rs | UTF-8 | 2,838 | 3.046875 | 3 | [] | no_license | /// Segment Descriptor
#[derive(Debug, Clone, Copy, Default)]
#[repr(C, packed)]
pub struct SegmentDescriptor {
lim0_15: u16,
base0_15: u16,
base16_23: u8,
access: u8,
lim16_19_flags: u8,
base24_31: u8,
}
impl SegmentDescriptor {
pub const fn new(base: u32, limit: u32, access: u8, flags: u8... | true |
7fce878391638b4b0fb802cf1bbe2ef125de9060 | Rust | MaaxGr/latex-toc-markdown | /src/toc_formatter.rs | UTF-8 | 3,036 | 3.578125 | 4 | [] | no_license |
use regex::Regex;
pub fn line_to_md(line: &str) -> String {
let toc_layer = get_toc_layer(line);
if line.contains("nonumberline") {
let regex = Regex::new(r"\\contentsline \{[^{]+}\{\\nonumberline ([^}]+)}.+").unwrap();
let caps = regex.captures(line).unwrap();
let text = caps.get(1... | true |
6917c517d2f726b3bb37b0961f43aba5ea880105 | Rust | IThawk/rust-project | /rust-master/src/test/mir-opt/simplify_cfg.rs | UTF-8 | 1,179 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Test that the goto chain starting from bb0 is collapsed.
fn main() {
loop {
if bar() {
break;
}
}
}
#[inline(never)]
fn bar() -> bool {
true
}
// END RUST SOURCE
// START rustc.main.SimplifyCfg-initial.before.mir
// bb0: {
// goto -> bb1;
// }
// bb1: {
... | true |
1afe35b5830e3412e73202eef174aaae9b0c6122 | Rust | IThawk/rust-project | /rust-master/src/test/ui/dropck/dropck-union.rs | UTF-8 | 748 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![feature(untagged_unions)]
use std::cell::Cell;
use std::ops::Deref;
use std::mem::ManuallyDrop;
union Wrap<T> { x: ManuallyDrop<T> }
impl<T> Drop for Wrap<T> {
fn drop(&mut self) {
unsafe { std::ptr::drop_in_place(&mut *self.x as *mut T); }
}
}
impl<T> Wrap<T> {
fn new(x: T) -> Self {
... | true |
d7fb63054855787e65afb92107e9b608c03d439d | Rust | oxidecomputer/openapi-generator | /samples/client/petstore/rust/reqwest/fileResponseTest/src/apis/mod.rs | UTF-8 | 876 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use reqwest;
use serde_json;
#[derive(Debug, Clone)]
pub struct ResponseContent<T> {
pub status: reqwest::StatusCode,
pub content: String,
pub entity: Option<T>,
}
#[derive(Debug)]
pub enum Error<T> {
Reqwest(reqwest::Error),
Serde(serde_json::Error),
Io(std::io::Error),
ResponseError(Resp... | true |
1695ca83aaf896972cb619f59dacccbc34dcb5e1 | Rust | kyleburton/sandbox | /examples/rust/learn-rust/arrays-and-slices/src/main.rs | UTF-8 | 982 | 3.53125 | 4 | [] | no_license | use std::mem;
fn analyze_slice(slice: &[i32]) {
println!("First element of the slice: {}", slice[0]);
println!("The slice has {} elements", slice.len());
}
fn main() {
let xs: [i32; 5] = [1, 2, 3, 4, 5];
let ys: [i32; 500] = [0; 500];
println!("First element of the xs array: {}", xs[0]);
pri... | true |
3c751a68f3476c18e965737dd31ade5c617fc741 | Rust | SimonBartonPSU/Fractal-Generator | /src/auto_random.rs | UTF-8 | 1,382 | 2.9375 | 3 | [
"MIT"
] | permissive | // Copyright © 2019 Liam Rotchford, Simon Barton
//! Automatic fractal generation for those who wish to skip the menu system.
use crate::barnsley::*;
use crate::julia_sets::*;
use crate::mandelbrot::*;
use crate::util::*;
use rand::Rng;
/// str literals for randomly selecting a fractal
const FRACTALS: [&str; 4] = ["... | true |
533e5fef19c2760891310995518599301ca1f1f8 | Rust | alessiofino/MySearch | /src/main.rs | UTF-8 | 5,863 | 2.6875 | 3 | [] | no_license | use std::{char, fs::File, io::BufReader, time::Instant};
use clap::{App, Arg};
use log::error;
use mysearch::index::Index;
use serde_json::Value;
use ncurses::*;
extern crate jemallocator;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
struct CursedPrinter {
attributes: Vec<... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.