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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2beb3231ff0aeff86821aab5ae76a62c3c60dba5 | Rust | Tim-Zhang/rust-protobuf | /protobuf/src/varint/decode.rs | UTF-8 | 3,370 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Varint decode utilities.
use crate::error::WireError;
use crate::varint::MAX_VARINT32_ENCODED_LEN;
use crate::varint::MAX_VARINT_ENCODED_LEN;
trait DecodeVarint {
const MAX_ENCODED_LEN: usize;
const LAST_BYTE_MAX_VALUE: u8;
fn from_u64(value: u64) -> Self;
}
impl DecodeVarint for u64 {
const MAX... | true |
c91b153dc553864d914c34b1589122529e6c0f73 | Rust | tiannian/keccakf | /src/state.rs | UTF-8 | 942 | 2.734375 | 3 | [] | no_license | use crate::Permutation;
macro_rules! define_keccak_state {
($ty:ident, $length:expr, $pty:ty, $kf:ident) => {
#[derive(Clone, Debug)]
#[repr(align(8))]
/// State of keccak
pub struct $ty([u8; 200]);
impl Default for $ty {
fn default() -> Self {
S... | true |
c6e1689b09ab780e99b67e56dc25aa85c25a662d | Rust | kradical/feOxy | /src/dom.rs | UTF-8 | 6,984 | 4.03125 | 4 | [
"MIT"
] | permissive | //! The `dom` module provides a dom node datastructure for an html parser to use.
use std::collections::{HashMap, HashSet};
use std::fmt;
pub type AttrMap = HashMap<String, String>;
#[derive(PartialEq, Eq)]
pub struct Node {
pub children: Vec<Node>,
pub node_type: NodeType,
}
#[derive(PartialEq, Eq, Clone)]... | true |
fe06c56acfcf1b22b42cd2065cb63d9d31bbfa5a | Rust | soundust/ghakuf | /src/messages.rs | UTF-8 | 20,609 | 2.953125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use formats::*;
use std::fmt;
/// Common methods among three SMF Events.
///
/// # Examples
///
/// ```
/// use ghakuf::messages::{MessageTool, MetaEvent, MidiEvent, SysExEvent};
///
/// assert_eq!(MetaEvent::EndOfTrack.binary(), [0xff, 0x2f]);
/// assert_eq!(MidiEvent::NoteOn { ch: 0x03, note: 0x00, velocity: 0x65 }.... | true |
0968b83d7a8123e8b704547d00ac67a2be2695b8 | Rust | mass10/rust.note | /code/formatting/src/main.rs | UTF-8 | 589 | 3.046875 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
println!("{}", "あいうえお");
println!("{}, {}, {}", 1, "2", '3');
println!("{}", 95);
println!("{:X}", 95);
println!("{:#X}", 95);
println!("{:x}", 95);
println!("{:#x}", 95);
println!("{:08x}", 65536);
println!("{:#010x}", 65536);
println!("{:b}", 95);
println!("{:#b}"... | true |
4064194f8010212d31624b9834efa8feb0e942e0 | Rust | edarc/rasn | /src/types/oid.rs | UTF-8 | 14,926 | 3.109375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use alloc::vec::Vec;
use core::ops;
pub(crate) const MAX_OID_FIRST_OCTET: u32 = 2;
pub(crate) const MAX_OID_SECOND_OCTET: u32 = 39;
const fn is_valid_oid(slice: &[u32]) -> bool {
slice.len() >= 2 && slice[0] <= MAX_OID_FIRST_OCTET && slice[1] <= MAX_OID_SECOND_OCTET
}
/// A temporary workaround for [`Oid`] not c... | true |
0db2316eb6f2ef902effd80afcfaaf27949b1e39 | Rust | mingyli/hg-rs | /src/manifest.rs | UTF-8 | 602 | 2.765625 | 3 | [] | no_license | use std::collections::HashMap;
use std::fmt;
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct Manifest {
pub entries: HashMap<PathBuf, [u8; 20]>,
}
impl fmt::Display for Manifest {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Resul... | true |
728fa142178e6b61b190b0c8e14c2a73997ef4aa | Rust | sosik/siredir | /src/config.rs | UTF-8 | 1,140 | 2.984375 | 3 | [
"MIT"
] | permissive | use std::borrow::Cow;
use serde_derive;
use serde_yaml;
// Thread safe shareable representation of current configuration
// Representation of config file
#[derive(serde_derive::Deserialize, Debug)]
pub struct Config {
bind_to: Vec<String>,
redirects: Vec<ConfigRedirectRecord>,
}
#[derive(serde_derive::Deseri... | true |
72780f5065b745b576acf043c5129abe242c6640 | Rust | plazma-tool/plazma-tool | /libs/intro_runtime/src/model.rs | UTF-8 | 2,085 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::context_gfx::ContextGfx;
use crate::error::RuntimeError;
use crate::mesh::Mesh;
use crate::types::{BufferMapping, UniformMapping};
pub struct Model {
pub model_type: ModelType,
// pub textures_loaded: Vec<Texture>, // is this needed?
pub meshes: Vec<Mesh>,
}
pub struct ModelViewProjection {
... | true |
141d8f3c5bb82aedcf15d477ed465007a553e229 | Rust | ni-balexand/rust-msi | /tests/tables.rs | UTF-8 | 9,624 | 2.6875 | 3 | [
"MIT"
] | permissive | extern crate msi;
#[macro_use]
mod testutil;
use msi::{
Column, ColumnType, Expr, Insert, Package, PackageType, Select, Value,
};
use std::io::{Cursor, ErrorKind};
// ========================================================================= //
#[test]
fn create_table_with_invalid_name() {
let cursor = Curso... | true |
270a8583df8d3041df6557248d9383042cef5f36 | Rust | YaLTeR/wayland-rs | /wayland-server/src/lib.rs | UTF-8 | 12,530 | 3.40625 | 3 | [
"MIT"
] | permissive | //! Interface for interacting with the Wayland protocol, server-side.
//!
//! ## General concepts
//!
//! This crate is structured around four main objects: the [`Display`] and [`DisplayHandle`] structs,
//! resources (objects implementing the [`Resource`] trait), and the [`Dispatch`] trait.
//!
//! The [`Display`] is ... | true |
a8dcc3d0a30c2808b4fdac398c09a8e0d84669f2 | Rust | lily-mara/nu-plugin-template | /src/main.rs | UTF-8 | 1,828 | 2.828125 | 3 | [] | no_license | use nu_errors::ShellError;
use nu_plugin::{serve_plugin, Plugin};
use nu_protocol::{CallInfo, ReturnValue, Signature};
use serde::Serialize;
// This struct represents a single row on your output stream. Fields of this
// struct will be converted to columns of the output table.
#[derive(Serialize)]
struct OutputRow {
... | true |
a7bc72ab473174bf77d3953bac9454f4b07e9c2d | Rust | lorenzoditucci/calyx | /src/backend/xilinx/axi.rs | UTF-8 | 7,239 | 3.34375 | 3 | [
"MIT"
] | permissive | //! Code generation for the AXI interface.
use super::fsm;
use vast::v05::ast as v;
/// Represents the Direction of a channel
/// from the perspective of the master interface.
#[derive(Clone, Debug)]
pub(crate) enum ChannelDirection {
Recv,
Send,
}
/// Represents a single AXI channel.
#[derive(Clone, Debug)]
... | true |
dca271d99f05bbe016bc32d596f066c49354ea81 | Rust | leniseev/tokio | /tokio-trace/src/level_filters.rs | UTF-8 | 3,541 | 3.125 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use tokio_trace_core::Level;
/// `LevelFilter` is used to statistically filter the logging messages based on its `Level`.
/// Logging messages will be discarded if its `Level` is greater than `LevelFilter`.
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct LevelFilter(Option<Le... | true |
5c9b2cfa7d1ff5ec322ff36ea5b131b5643bf306 | Rust | nykh/exercism-rust | /atbash-cipher/src/lib.rs | UTF-8 | 889 | 3.421875 | 3 | [] | no_license | use std::iter::FromIterator;
use std::ascii::AsciiExt;
fn codec_char(c: char) -> char {
let id = (c as u8) - ('a' as u8); // 0 .. 25
((25 - id) + 'a' as u8) as char
}
pub fn encode(text: &str) -> String {
let mut v: Vec<char> = Vec::new();
let lc = text.to_lowercase();
let it = lc.chars().filter... | true |
2c702bb8439937a2c5a8794635841975f7bc7642 | Rust | clinuxrulz/sodium-rust-demo | /core/src/drivers/diag_driver.rs | UTF-8 | 383 | 2.640625 | 3 | [] | no_license | pub trait DiagDriver {
fn log_string(&mut self, msg: String);
}
pub trait Log {
fn log<S: ToString>(&mut self, msg: S);
}
impl Log for DiagDriver {
fn log<S: ToString>(&mut self, msg: S) {
self.log_string(msg.to_string());
}
}
impl<DD: DiagDriver> Log for DD {
fn log<S: ToString>(&mut sel... | true |
b13b703bf05f2a89933906c7acbaf5d5df199210 | Rust | pombredanne/symbols-1 | /src/main.rs | UTF-8 | 3,683 | 2.671875 | 3 | [] | no_license | use anyhow::{anyhow, bail, Context, Result};
use log::{/*error,*/ /*debug,*/ info, trace /*warn */};
use std::{path::Path, path::PathBuf};
use crate::config::{PathConfig, RemoteStorage, RemoteStorageType, S3Config};
mod args;
mod config;
mod symstore;
mod upload;
fn main() -> Result<()> {
let matches = args::pa... | true |
7a24a56fefad0b70ca2796ac8aa8e63f251a32a7 | Rust | CPT-Jack-A-Castle/crypto-crawler-rs | /crypto-pair/src/exchanges/bitfinex.rs | UTF-8 | 1,703 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use super::utils::http_get;
use lazy_static::lazy_static;
use std::collections::HashMap;
lazy_static! {
static ref BITFINEX_MAPPING: HashMap<String, String> = fetch_currency_mapping();
}
// see <https://api-pub.bitfinex.com/v2/conf/pub:map:currency:sym>
fn fetch_currency_mapping() -> HashMap<String, String> {
... | true |
ea79517e44e2fb5bb343934e3b3d88c0aa6f5ba7 | Rust | AlseinX/mrn | /src/errors.rs | UTF-8 | 3,011 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::{
error,
ffi::{OsStr, OsString},
fmt::{Debug, Display},
ops::Deref,
};
use Error::*;
pub trait Expect {
type T;
type E;
fn expect_fn<S: Display, F: Fn(Self::E) -> S>(self, msg: F) -> Self::T;
}
impl<T, E> Expect for Result<T, E> {
type T = T;
type E = E;
#[inline]
... | true |
6e889bb48e2830ac9d5f22a193d7c277daf3df8b | Rust | tompreston/bft | /bft_types/src/lib.rs | UTF-8 | 11,049 | 3.625 | 4 | [] | no_license | //! Brainfuck interpreter types
//!
//! This crate contains all the data types necessary for the Brainfuck
//! interpreter project.
#![deny(missing_docs)]
use std::fmt;
use std::io;
use std::path::{Path, PathBuf};
use thiserror::Error;
/// Represents a Brainfuck Types Error.
#[derive(Error, fmt::Debug)]
pub enum Br... | true |
4859162fff218a3e4205bd20a87622469039722e | Rust | Andy-Python-Programmer/pro-bot | /src/commands/scissors.rs | UTF-8 | 4,864 | 2.828125 | 3 | [] | no_license | use rand::seq::SliceRandom;
use std::time::Duration;
use serenity::{
builder::CreateEmbedFooter, client::Context, framework::standard::macros::command,
framework::standard::CommandResult, model::channel::Message, model::channel::ReactionType,
utils::Colour,
};
use crate::PREFIX;
#[command]
pub async fn s... | true |
2b5d3b4adf2c8469609018aac120bb74dd2cb922 | Rust | dhadka/chain-libs | /chain-crypto/src/bech32.rs | UTF-8 | 2,198 | 2.9375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use bech32::{self, Error as Bech32Error, FromBase32, ToBase32};
use std::error::Error as StdError;
use std::fmt;
use std::result::Result as StdResult;
pub type Result<T> = StdResult<T, Error>;
pub trait Bech32 {
const BECH32_HRP: &'static str;
fn try_from_bech32_str(bech32_str: &str) -> Result<Self>
wher... | true |
d58434977f4d2978a32707f2a548408fdfa65b03 | Rust | kellpossible/sentry-tracing | /src/converters.rs | UTF-8 | 7,696 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::BTreeMap;
use sentry_backtrace::current_stacktrace;
use sentry_core::protocol::{Event, Exception};
use sentry_core::Breadcrumb;
use tracing::field::Field;
use crate::TracingIntegrationOptions;
fn convert_tracing_level(level: &tracing::Level) -> sentry_core::Level {
match level {
&tr... | true |
6e0e2695aa63d3a1385d21851d74c84ec5fdf5fd | Rust | pokeraigym/pokereval-cactus-py | /src/deck.rs | UTF-8 | 609 | 2.828125 | 3 | [
"MIT"
] | permissive | use pyo3::prelude::*;
#[pyclass]
pub struct Deck {
deck: pokereval_cactus::deck::Deck,
}
#[pymethods]
impl Deck {
#[new]
fn new_py(obj: &PyRawObject) {
obj.init(Deck {
deck: pokereval_cactus::deck::Deck::new()
})
}
fn shuffle(&mut self) -> PyResult<()> {
self.d... | true |
5cd818018f0d8f1647e28127d8d2c6dae27d2448 | Rust | KizzyCode/slice_queue | /src/lib.rs | UTF-8 | 893 | 2.78125 | 3 | [
"MIT",
"BSD-2-Clause"
] | permissive | //! This library provides `SliceQueue`, a optimized queue for efficient working with (byte-)slices.
//! It allows you to
//! - efficiently push an arbitrary amount of elements to the back by either consuming them or by
//! cloning/copying them from a slice (if the type supports the `Clone`/`Copy` trait)
//! - comm... | true |
5f1f0d82f5aae0c5c492a1f0c7e935fc6cad610f | Rust | korczis/maze-rs | /src/web/mod.rs | UTF-8 | 2,577 | 2.625 | 3 | [
"MIT"
] | permissive | extern crate iron;
extern crate router;
extern crate time;
extern crate urlencoded;
use hyper::header::Headers;
use iron::prelude::*;
use iron::status;
use router::Router;
use time::PreciseTime;
use urlencoded::UrlEncodedQuery;
use super::types::cell::BaseCell;
use super::types::grid::Grid;
pub fn start_web<'a>(port... | true |
c96595735a8662197553313a22e3758981c01b54 | Rust | luojia65/skip | /src/skip_map.rs | UTF-8 | 6,954 | 3.140625 | 3 | [] | no_license | use core::ptr::NonNull;
use core::marker::PhantomData;
use core::borrow::Borrow;
use core::mem;
use core::cmp::Ordering::{self, Less, Equal, Greater};
pub struct SkipMap<K, V, T>
where K: Ord, T: Tower<K, V> {
head_tower: T,
tail: Option<NonNull<Node<K, V, T>>>,
len: usize,
_marker: PhantomData<Box<No... | true |
c35df8cbf7939e61d6a1c2d2adb9fb77aff13355 | Rust | FSMaxB/rust-either-future | /src/futures03.rs | UTF-8 | 695 | 2.78125 | 3 | [
"ISC"
] | permissive | use crate::EitherFuture;
use futures_util::future::Either;
impl<LeftFuture, RightFuture> From<Either<LeftFuture, RightFuture>> for EitherFuture<LeftFuture, RightFuture> {
fn from(either: Either<LeftFuture, RightFuture>) -> Self {
match either {
Either::Left(left) => EitherFuture::left(left),
Either::Right(rig... | true |
00b96f1cc9392ca8721e7b9e47730968a3bf3121 | Rust | rolisz/rust_crawler | /src/bin/set.rs | UTF-8 | 454 | 2.921875 | 3 | [] | no_license | use std::collections::HashSet;
fn main() {
let mut books : HashSet<String> = HashSet::new();
let v = vec!("Bible".to_string(), "8 biographis".into(), "NCL".into(), "Bible".into());
println!("{:#?}", v);
// for b in v {
// books.insert(b);
// }
println!("{:#?}", books);
v.iter().map(|x... | true |
388945c6386c5af7cd470d5f4d4326e80ebf5b7b | Rust | rafaelcaricio/jsonschema-rs | /bindings/python/src/string.rs | UTF-8 | 1,643 | 2.578125 | 3 | [
"MIT"
] | permissive | use pyo3::ffi::{PyTypeObject, PyUnicode_AsUTF8AndSize, Py_UNICODE, Py_hash_t, Py_ssize_t};
use std::os::raw::c_char;
#[repr(C)]
struct PyAsciiObject {
pub ob_refcnt: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
pub length: Py_ssize_t,
pub hash: Py_hash_t,
pub state: u32,
pub wstr: *mut c_char,
}... | true |
cc0bb16da23dddee65bf0ba20ff2592d06b9a17e | Rust | delaneyj/minigame-rust | /src/spritecomponent.rs | UTF-8 | 4,453 | 2.921875 | 3 | [
"MIT"
] | permissive | extern crate cgmath;
use color::Color;
use component::{Component};
use rectangle::Rectangle;
use texture::Texture;
use spritebatch::SpriteBatch;
use subtexture::Subtexture;
use entity::Entity;
use self::cgmath::Vector2;
use std::collections::HashMap;
use std::rc::Rc;
use std::option::Option;
use log::Log;
pub struct ... | true |
c940ccd45c8a5dcc8e9b49cc36b6c1b8f793a45f | Rust | EasyToFindName/ultimate-tic-tac-toe-game | /tic-tac-toe/src/game_logic/game_board.rs | UTF-8 | 5,082 | 3.390625 | 3 | [] | no_license | use basics::*;
use game_elements::*;
use std::fmt;
// Directions used in get_winner algorithm
const DIRECTIONS: [Point<i32>; 4] = [
Point { x: -1, y: 0 },
Point { x: -1, y: 1 },
Point { x: 0, y: 1 },
Point { x: 1, y: 1 },
];
pub struct GameBoard {
board: Arr2D<GameElem>,
free_cells: usize,
... | true |
500b6f552bd8e1eefb77d652434425e6bbcb5282 | Rust | geomatsi/rust-tests | /stellar/src/main.rs | UTF-8 | 2,179 | 2.640625 | 3 | [] | no_license | //
//
//
extern crate stellar;
use stellar::star::*;
use std::io;
fn main() {
let mut sky: Vec<Star> = Vec::new();
let sun: Star = Star::get_sun();
sky.push(Star::new_star("Zeta Puppis", SpectralClass::O(4), 56.1));
sky.push(Star::new_star("Rigel", SpectralClass::B(8), 23.0));
sky.push(Star::ne... | true |
e5f6ebb74080c71a700a1a5de396136ea3063991 | Rust | vanderian/physync | /src/server.rs | UTF-8 | 417 | 2.921875 | 3 | [] | no_license | use crate::errors::Result;
use crate::Peer;
pub struct Server {
peer: Peer,
}
impl Server {
pub async fn new(addr: &str) -> Result<Self> {
let peer = Peer::bind(addr).await?;
println!("Listening on: {}", peer.local_addr()?);
Ok(Server { peer })
}
pub async fn run(self) -> Res... | true |
8bf61787de28b7ad7bc7d98823b712a3b673a52b | Rust | mythmon/advent-of-code | /year2017/src/day08/part2.rs | UTF-8 | 1,791 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::day08::{Instruction, Operation};
use advent_lib::cases::{GenericPuzzleCase, PuzzleCase, PuzzleRunner};
use std::{cmp, collections::HashMap};
#[derive(Debug)]
pub struct Part2;
impl PuzzleRunner for Part2 {
type Input = Vec<Instruction>;
type Output = isize;
fn name(&self) -> String {
"... | true |
a6221771ad895f424a1fad04253cc0bcea115872 | Rust | reitermarkus/dockworker | /examples/findports.rs | UTF-8 | 857 | 2.75 | 3 | [] | no_license | extern crate dockworker;
extern crate failure;
use failure::*;
use dockworker::{Docker, models::ContainerFilters};
fn find_all_exported_ports() -> Result<(), Error> {
let docker = Docker::from_env()?;
let filter = ContainerFilters::new();
let containers = docker.container_list(None, None, None, filter)?;
for ... | true |
3c536b6b161a28164d9dcd36db87d391e43d2327 | Rust | justinmc/parse-pdb-rust | /src/molecule/mod.rs | UTF-8 | 3,280 | 3.109375 | 3 | [
"MIT"
] | permissive | mod atom;
mod chain;
mod residue;
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
pub struct Molecule {
pub atoms: Vec<atom::Atom>,
pub chains: HashMap<String, chain::Chain>,
pub filename: String,
pub residues: Vec<residue::Residue>,
}
impl Molecul... | true |
d6c9cdd75bb81eaa47ed14c1f246765100e49468 | Rust | chaoticgood1/bevy_mod_picking | /src/debug.rs | UTF-8 | 3,290 | 2.640625 | 3 | [
"MIT"
] | permissive | use super::*;
use bevy::prelude::*;
pub struct DebugPickingPlugin;
impl Plugin for DebugPickingPlugin {
fn build(&self, app: &mut AppBuilder) {
app.init_resource::<CursorEvents>()
.add_startup_system(setup_debug_cursor)
.add_system(update_debug_cursor_position)
.add_syst... | true |
466a59e7799333491627c8ab403d3ee5c2bfdf5b | Rust | funkiben/Rust-HTTP | /tests/util/curl.rs | UTF-8 | 1,370 | 3.046875 | 3 | [] | no_license | use std::process::Command;
use my_http::common::request::Request;
pub fn request(addr: &str, request: &Request, https: bool) -> String {
let reqs = [request];
requests(addr, &reqs, https)
}
pub fn requests(addr: &str, requests: &[&Request], https: bool) -> String {
let mut cmd = Command::new("curl");
... | true |
9e4666e01c84bec33a1309ad76ca2ce5b49739e4 | Rust | tor-legit/LRVM | /lrvm_tools/src/bytes/mod.rs | UTF-8 | 840 | 3.484375 | 3 | [] | no_license | //! Utilities to deal with bytes
/// Convert a list of bytes to a list of words
pub fn bytes_to_words(bytes: impl AsRef<[u8]>) -> Vec<u32> {
let bytes = bytes.as_ref();
let rem = bytes.len() % 4;
let mut words = Vec::with_capacity(bytes.len() / 4 + if rem == 0 { 1 } else { 0 });
let mut word = 0;
... | true |
a4612cef0125ce5e8e6144a3de24f6055864a08c | Rust | jianingy/airstation | /src/errors.rs | UTF-8 | 1,126 | 2.5625 | 3 | [] | no_license | // Jianing Yang <jianingy.yang@gmail.com> @ 2 Oct, 2016
error_chain!{
errors {
UartError(reason: String) {
description("uart port error")
display("uart port error: {}", reason)
}
DataError(reason: String) {
description("data error")
display(... | true |
2f4154f689df2556b210a7f4da1f7819e264bedd | Rust | burtonageo/clipboard_rs | /src/lib.rs | UTF-8 | 2,665 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[cfg(any(windows, unix))]
extern crate libc;
#[cfg(target_os = "macos")]
mod mac_clipboard;
#[cfg(target_os = "macos")]
use mac_clipboard as inner;
#[cfg(windows)]
mod windows_clipboard;
#[cfg(windows)]
use windows_clipboard as inner;
#[cfg(all(not(target_os = "macos"), unix))]
mod unix_clipboard;
#[cfg(all(not(... | true |
08fe0cc260e7e7e8fca648a7496b82676b4ef885 | Rust | jakeisnt/raytracinginrust | /rust/src/main.rs | UTF-8 | 4,697 | 2.703125 | 3 | [
"CC0-1.0"
] | permissive | mod vec;
mod ray;
mod hit;
mod sphere;
mod camera;
mod material;
use std::sync::Arc;
use rand::prelude::*;
use rayon::prelude::*;
use vec::{Vec3, Point3, Color};
use ray::Ray;
use hit::{Hit, World};
use sphere::Sphere;
use material::{Lambertian, Metal, Dielectric};
use camera::Camera;
fn random_scene() -> World {
... | true |
b4fd1e19ab494437d9b520ca2a0dadbaf24a4b09 | Rust | jmjoy/cross | /src/rustc.rs | UTF-8 | 1,464 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::path::PathBuf;
use std::process::Command;
use rustc_version::{Version, VersionMeta};
use crate::errors::*;
use crate::extensions::CommandExt;
use crate::{Host, Target};
#[derive(Debug)]
pub struct TargetList {
pub triples: Vec<String>,
}
impl TargetList {
pub fn contains(&self, triple: &str) -> boo... | true |
a46a53433b84a4422107cf191bcc19e5e7118f0e | Rust | moonmile/rust-sample | /src/ch05/sample-05-02/src/main.rs | UTF-8 | 1,305 | 3.765625 | 4 | [] | no_license | fn main() {
// 一般的な四則演算子
let a = 20 + 10 ;
println!("a is {}", a );
let a = 20 - 10 ;
println!("a is {}", a );
let a = 20 * 10 ;
println!("a is {}", a );
let a = 20 / 10 ;
println!("a is {}", a );
let a = 20 % 3 ;
println!("a is {}", a );
// 割り算で整数と実数の違い
let a = 10 ;... | true |
b7d39a30b8599afea662a731f72e6094474138c9 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/fallible_collections/src/try_clone.rs | UTF-8 | 815 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /
/
!
this
module
implements
try
clone
for
primitive
rust
types
use
super
:
:
TryClone
;
use
crate
:
:
TryReserveError
;
macro_rules
!
impl_try_clone
{
(
(
e
:
ty
)
*
)
=
>
{
(
impl
TryClone
for
e
{
#
[
inline
(
always
)
]
fn
try_clone
(
&
self
)
-
>
Result
<
Self
TryReserveError
>
where
Self
:
core
:
:
marker
:
:
Size... | true |
444ad4234ea339b6423a7e7a057532d8cc8850f0 | Rust | l0calh05t/raytracing-weekend-rs | /src/scene.rs | UTF-8 | 2,692 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use std::sync::Arc;
use crate::hittable::Hittable;
use crate::materials::*;
use crate::sphere::Sphere;
use crate::vec::*;
pub fn random_scene() -> Vec<Box<dyn Hittable + Sync>> {
let mut list: Vec<Box<dyn Hittable + Sync>> = Vec::new();
let ground_sphere_radius = 1000.0;
list.push(Box::new(Sphere {
ce... | true |
9fa3c86844e945728f1f00b58bef11eec99ed016 | Rust | seanwallawalla-forks/nushell | /crates/nu-command/src/commands/filters/rotate/command.rs | UTF-8 | 3,292 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{
merge_descriptors, ColumnPath, ReturnSuccess, Signature, SyntaxShape, TaggedDictBuilder,
UntaggedValue,
};
use nu_source::{SpannedItem, Tagged};
use nu_value_ext::ValueExt;
pub struct Command;
impl WholeStr... | true |
1fb2b30da0645376b55383d51177f75c83e2a3ab | Rust | ericdeansanchez/bifrost | /src/bifrost/ops/bifrost_load.rs | UTF-8 | 969 | 2.625 | 3 | [
"MIT"
] | permissive | //! Implementation details of the `load` subcommand.
use std::io::{self, Write};
use crate::core::config::Config;
use crate::core::workspace::{BifrostOperable, WorkSpace};
use crate::util::{BifrostResult, OperationInfo};
use crate::ArgMatches;
/// Loads a Bifrost Workspace. Utilizes `Config` and `ArgMatches` to const... | true |
a835cdf632e1d46762b0ffaaa884875c17a55566 | Rust | Licenser/ordnung | /src/lib.rs | UTF-8 | 23,434 | 3.4375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! # Ordnung
//!
//! Fast, vector-based map implementation that preserves insertion order.
//!
//! + Map is implemented as a binary tree over a `Vec` for storage, with only
//! two extra words per entry for book-keeping on 64-bit architectures.
//! + A fast hash function with good random distribution is used to bala... | true |
1cf63721d9d9811d6e7251180a7dd9306e43da18 | Rust | drewtato/aoc2019 | /days/day17/src/main.rs | UTF-8 | 1,438 | 2.734375 | 3 | [] | no_license | const DAY: u8 = 17;
use intcode::IntcodeProgram;
fn main() {
let mut program = IntcodeProgram::vec_from_file(format!("inputs/day{:02}.txt", DAY)).unwrap();
program[0] = 2;
let input = b"A,B,A,C,A,B,C,B,C,A\nL,12,R,4,R,4,L,6\nL,12,R,4,R,4,R,12\nL,10,L,6,R,4\nn\n"
.iter()
.map(|&c| c as i64);
program.add_input_... | true |
87ee0248816b764ccb5b5f2a7ede236fbc0f4b53 | Rust | alexmeli100/pbrt-rust | /src/core/geometry/vector.rs | UTF-8 | 11,920 | 3.203125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::point::{Point2, Point3};
use super::normal::Normal3;
use crate::core::pbrt::{Float};
use std::ops::{Add, Mul, AddAssign, MulAssign, SubAssign, Sub, Div, DivAssign, Index, IndexMut, Neg};
use num::{Signed, Zero, One};
use std::fmt::{Debug, Display, Formatter};
use std::fmt;
use crate::core::geometry::normal::... | true |
8e882b0ccd25b4ae2f21ca7df7794cb9aba846f7 | Rust | matthew-mcallister/playstation-emulator | /src/cpu/operations/j.rs | UTF-8 | 734 | 2.734375 | 3 | [] | no_license | use crate::cpu::delay::Delay;
use crate::cpu::exception::Exception;
use crate::cpu::interconnect::Interconnect;
use crate::cpu::operations::Operation;
use crate::cpu::registers::Registers;
use crate::instruction::Instruction;
pub struct J {
instruction: Instruction
}
impl J {
pub fn new(instruction: Instructi... | true |
fd36b0ae021ac0ff3b48e1405e4a9cb53d4a82cc | Rust | gnoliyil/fuchsia | /src/sys/pkg/lib/omaha-client/src/metrics/mock.rs | UTF-8 | 1,723 | 2.828125 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::metrics::{Metrics, MetricsReporter};
use anyhow::{format_err, Error};
/// A mock implementation of MetricsReporter save the metrics into a vect... | true |
9446f6273de6963a9205d8187b2320277aca2068 | Rust | cholcombe973/preserve | /src/backend/file.rs | UTF-8 | 5,011 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use backend::Backend;
use keystore::{EncryptedArchiveName, EncryptedArchive, EncryptedBlock, BlockId};
use std::path::{Path, PathBuf};
use std::io::{BufReader, Read, Write};
use std::fs::{self, OpenOptions};
use rand::{Rng, OsRng};
use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::str::FromStr;
use error::... | true |
782dcf668523af714c3fd921f80722c63137a8b5 | Rust | belst/Advent-of-Code-2017 | /src/bin/day6.rs | UTF-8 | 1,237 | 3.4375 | 3 | [] | no_license | use std::io::Read;
// Finds maximum (if multiple, first)
// max_by finds last
fn find_max(arr: &[usize]) -> (usize, usize) {
arr.iter()
.enumerate()
.fold((0, 0), |(index, max), (curr_index, &val)| {
if val > max {
(curr_index, val)
} else {
... | true |
908aafeabaedf84ae3830169e4a66c5134627944 | Rust | MikkoSpoo/advent2019 | /src/bin/aoc6.rs | UTF-8 | 4,253 | 3.328125 | 3 | [] | no_license | // https://adventofcode.com/2019/day/6
use std::collections::HashMap;
use std::collections::HashSet;
use std::io;
use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
struct Obj {
orbits: Option<String>,
on_orbit: HashSet<String>,
}
impl Obj {
fn new() -> Obj {
Obj {
orbi... | true |
75b1225dae7f50442295cd4650f341455ceea13f | Rust | TobiasFaller/UniFr-Project-RayTracer-Rust | /src/object/model/obj_loader.rs | UTF-8 | 5,313 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Error as IOError;
use std::io::ErrorKind;
use vecmath::Vector2;
use vecmath::Vector3;
use object::RayTraceObjectModel;
use object::model::RayTraceModelNormalInterpolation;
use material::RayTraceMaterial;
pub fn obj_load(file_name: &str, ma... | true |
909efb238080b9cd470e2e6cf69ba51dbd69a0d7 | Rust | eZanmoto/term_emu_poc | /src/main.rs | UTF-8 | 11,970 | 2.625 | 3 | [
"MIT"
] | permissive | // Copyright 2020 Sean Kelleher. All rights reserved.
// Use of this source code is governed by a MIT
// licence that can be found in the LICENCE file.
use std::convert::TryInto;
use std::io::ErrorKind;
use std::io::Read;
use std::io::Write;
extern crate alacritty;
extern crate pancurses;
use alacritty::ansi::{Color... | true |
3a39909b9baf83d47902f52404cd3bcf8e9d119a | Rust | wycats/rust-experiments | /tests/macros/fragment.rs | UTF-8 | 3,760 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::path::Path;
use console::Color::{Green, Red};
use spectrum::{compose::BoxedDoc, EmitBackendTrait, EmitForTest, EmitPlain, EmitResult};
use spectrum_macros::frag;
fn plain(frag: &BoxedDoc) -> EmitResult<String> {
Ok(EmitPlain.render(frag, 80)?)
// frag.emit_into_string_with(&EmitPlain, ctx)
}
fn colo... | true |
e1b9b1b6953ec1a89676a5c04f1680685149e9ca | Rust | a2aaron/ggez_experiment | /src/util.rs | UTF-8 | 616 | 3 | 3 | [] | no_license | use ggez::mint;
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Direction8 {
Left,
Right,
Up,
Down,
LeftUp,
LeftDown,
RightUp,
RightDown,
}
pub fn into_mint<T>(point: cgmath::Point2<T>) -> mint::Point2<T> {
mint::Point2 {
x: point.x,
y: point.y,
}
}
pub fn mi... | true |
ae7bbe25d379ad081fea5db365299af4ebe73397 | Rust | nickray/lpc55-hal | /src/drivers/gint.rs | UTF-8 | 5,237 | 3.125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{
drivers::pins::Pin,
traits::Gint,
typestates::pin::{
self,
PinId,
}
};
pub trait Mode {}
pub trait NotAnd {}
pub trait NotOr {}
pub trait Set {}
pub struct NotSet;
impl Mode for NotSet {}
impl NotAnd for NotSet {}
impl NotOr for NotSet {}
pub struct And;
impl Mode for And {... | true |
6e74b008e238065608c84f0e19b02dbab1ee708b | Rust | ganmacs/playground | /rust/msg/src/unpacker/bool.rs | UTF-8 | 396 | 2.875 | 3 | [] | no_license | use super::byte;
use crate::code;
use bytes;
pub fn read_bool<T>(buf: &mut T) -> Result<bool, String>
where
T: bytes::Buf,
{
match byte::read_u8(buf)? {
code::TRUE => Ok(true),
code::FALSE => Ok(false),
v => Err(format!(
"Expected bool({:?} or {:?}) but found: {:?}",
... | true |
4a86c1335083f9507962cc589293ae0eda0fc546 | Rust | hoangpq/process-viewer | /src/notebook.rs | UTF-8 | 733 | 2.84375 | 3 | [
"MIT"
] | permissive | use gtk::{self, IsA};
use gtk::prelude::{BoxExt, NotebookExtManual, WidgetExt};
pub struct NoteBook {
pub notebook: gtk::Notebook,
pub tabs: Vec<gtk::Box>,
}
impl NoteBook {
pub fn new() -> NoteBook {
NoteBook {
notebook: gtk::Notebook::new(),
tabs: Vec::new(),
}
... | true |
b20abc15d6efcd7dceaca9d4bc5cac97068911b0 | Rust | cksac/fake-rs | /fake/examples/collections.rs | UTF-8 | 1,230 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use fake::{self, Fake, Faker};
use rand::distributions;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
fn main() {
let vec = fake::vec![u8; 4..8];
println!("Vec {:?}", vec);
let vec_deque = fake::vec_deque![u8; 4..8];
println!("VecDeque {:?}", vec_deque);
let linked_list = fake::li... | true |
557d37dae5c7e4ce621b61c15dbc8c11ae3df791 | Rust | EFanZh/LeetCode | /src/problem_1370_increasing_decreasing_string/mod.rs | UTF-8 | 371 | 2.9375 | 3 | [] | no_license | pub mod iterative;
pub trait Solution {
fn sort_string(s: String) -> String;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [("aaaabbbbcccc", "abccbaabccba"), ("rat", "art")];
for (s, expected) in test_cases {
assert_eq!(S::sort_s... | true |
eab6d069e409a1f4df0d46cbf3579bd6751335b7 | Rust | stjepangolemac/exer | /src/opt.rs | UTF-8 | 352 | 2.84375 | 3 | [] | no_license | use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub enum Command {
/// Initializes a new exer project
Init,
}
#[derive(Debug, StructOpt)]
#[structopt(name = "exer", about = "Generates sites in no time")]
pub struct Options {
#[structopt(subcommand)]
pub command: Command,
}
pub fn get() -> Optio... | true |
42ceb4188ed621c94981f2fbc925bac5d1afbd5d | Rust | brianduff/repodump | /src/main.rs | UTF-8 | 7,497 | 2.796875 | 3 | [] | no_license | use anyhow::{anyhow, Result};
use regex::Regex;
use reqwest::blocking::Client;
use reqwest::header::HeaderValue;
use reqwest::Url;
use rustyline::Editor;
use serde::Deserialize;
use serde_json;
use std::convert::TryInto;
use std::fs;
use std::path::PathBuf;
#[macro_use]
extern crate lazy_static;
use std::process::{Comm... | true |
f0c00e279dfedd5c8b453b0b03f85d8c675a758b | Rust | nanoporetech/fast-ctc-decode | /src/duplex.rs | UTF-8 | 33,553 | 2.546875 | 3 | [
"MIT"
] | permissive | use super::SearchError;
use crate::tree::{SuffixTree, ROOT_NODE};
use logspace::LogSpace;
use ndarray::{ArrayBase, Axis, Data, Ix1, Ix2, Ix3};
use ndarray_stats::QuantileExt;
mod logspace {
use std::ops::{Add, AddAssign, Mul, MulAssign};
#[cfg(feature = "fastexp")]
fn exp(a: f32) -> f32 {
use crat... | true |
9d6c164ca22d75256e772099d53b73acf399d28c | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0221.maximal-square/maximal-square_test.go | UTF-8 | 1,160 | 2.53125 | 3 | [
"MIT"
] | permissive | package problem0221
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
matrix [][]byte
ans int
}{
{
[][]byte{
[]byte("01"),
},
1,
},
{
[][]byte{
[]byte("1"),
},
1,
},
{
[][]byte{
[]byte("11111111"),
[]byte("11111110"... | true |
18bccf99379813f6de7188b688cfbd9132642f8d | Rust | paletteOvO/LeetCode | /lc406.rs | UTF-8 | 611 | 2.90625 | 3 | [] | no_license | use std::cmp::Ordering;
impl Solution {
pub fn reconstruct_queue(people: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
let mut v = people.to_vec();
v.sort_unstable_by(|x, y| {
if x[0] > y[0] {
Ordering::Less
} else if x[0] == y[0] {
if x[1] > y[1] {
Ordering:... | true |
2c7f69869d03a0bd5f521b14441ceba9b54f7068 | Rust | tonmanna/RustLearningFollowBookBeginer | /chapter2/src/tuples_sample1.rs | UTF-8 | 124 | 2.515625 | 3 | [] | no_license | pub fn tuples_sample_reverse(pair: (i32, bool)) -> (bool, i32) {
let (integer, boolean) = pair;
(boolean, integer)
} | true |
2a65574f55ca8e1972e861506447dc9b2b07b5e9 | Rust | ferrous-systems/imxrt1052 | /src/romc/rompatcha/mod.rs | UTF-8 | 5,920 | 2.546875 | 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::ROMPATCHA {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w... | true |
af0c365c11e03a8946a8ea99a2608d528de9d53c | Rust | ThePuffin/rustudemy | /ten part/communicator/src/simplifyWithEnum.rs | UTF-8 | 367 | 3.0625 | 3 | [] | no_license | #[allow(unused_variables)]
enum TrafficLight{
Red,Yellow,Green,
}
// use TrafficLight::{Red,Yellow};
// fn main () {
// let red=Red;
// let yellow=Yellow;
// let green=TrafficLight::Green; // because we don't import green with use TrafficLight
// }
use TrafficLight::*;
fn main () {
let red=Red;... | true |
b41c6b8d15437c0a35f49fb68a2f9ceedba12091 | Rust | isgasho/leetcode-1 | /tests/index_61_70_test.rs | UTF-8 | 179 | 2.515625 | 3 | [
"MIT"
] | permissive | extern crate leetcode;
use leetcode::index_61_70::*;
// 70
#[test]
#[ignore]
fn climb_stairs_works() {
assert_eq!(climb_stairs(2), 2);
assert_eq!(climb_stairs(3), 3);
}
| true |
47781b7ee7451b4aa94268cc6eefcd70a1e05d2d | Rust | ferrous-systems/imxrt1052 | /src/usb1/hccparams/mod.rs | UTF-8 | 3,993 | 2.6875 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::HCCPARAMS {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct ADCR {
bit... | true |
0c9213209cd1f314b3e92feb609c56207d3d7b34 | Rust | roadrunner-craft/core | /src/block/properties.rs | UTF-8 | 728 | 2.890625 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
#[derive(Deserialize, Clone)]
#[serde(default)]
pub struct BlockProperties {
pub name: String,
pub solid: bool,
pub opaque: bool,
pub flora: bool,
pub texture: BlockTextureProperties,
}
impl Default for BlockProperties {
fn default() -> Self {
Self {
... | true |
6ed980a0a3598ea59a730e6b766b7656487b0f58 | Rust | sastels/advent-of-code-2020 | /src/day6.rs | UTF-8 | 1,082 | 3.015625 | 3 | [] | no_license | use crate::utils::join_lines;
use itertools::Itertools;
pub fn solve_a(data: &[String]) -> usize {
join_lines(data)
.iter()
.map(|line| {
line.chars()
.filter(|c| *c != ' ') // join_lines substitutes spaces for newlines
.unique()
.count()
... | true |
b56c4533153aa06de40b7ee800ce2ba5d69ba55f | Rust | moshg/rust-std-ja | /src/test/run-pass/traits-conditional-dispatch.rs | UTF-8 | 1,377 | 3 | 3 | [
"MIT",
"BSD-3-Clause",
"NCSA",
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"BSD-2-Clause"
] | permissive | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
7655c3e773db404a2e0bd3f6afd3375794b5f7ef | Rust | niklasbuechner/parser-experiments | /lexer-with-dynamic-state-machine/src/lib.rs | UTF-8 | 885 | 3.09375 | 3 | [] | no_license | fn create_lexer() {
let code = "if hello then hi else bye 'if else' how";
// Define tokens
// %TOKENS%{
// IF,
// THEN,
// ELSE,
// ID(&str),
// }
// Define states
// %STATES%{
// INITIAL,
// QUOTATION,
// }
// Allow additional logic & f... | true |
464225159a9ff60f8bfba776ea8a856a0cba125d | Rust | yangzhe1990/conflux-rust | /core/src/evm/interpreter/memory.rs | UTF-8 | 6,119 | 2.65625 | 3 | [
"GPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.0-or-later",
"GPL-3.0-or-later",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-copyleft"
] | permissive | // Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | true |
78b7274add11ed4740b32736de72d204f03028b4 | Rust | cnaj/adventofcode | /day05/src/main.rs | UTF-8 | 880 | 3.21875 | 3 | [
"Unlicense"
] | permissive | extern crate day05;
use std::io;
use std::io::BufRead;
use day05::execute;
fn main() {
let stdin = io::stdin();
let handle = stdin.lock();
let mut list: Vec<i32> = vec![];
for line in handle.lines() {
match parse_instruction(line) {
Ok(value) => list.push(value),
Err(... | true |
5b2f85ef64db3aac943cf4589d705ce285075206 | Rust | serdaraltin/Epic-Asset-Manager | /src/ui/widgets/logged_in/asset.rs | UTF-8 | 4,404 | 2.6875 | 3 | [
"MIT"
] | permissive | use gtk4::subclass::prelude::*;
use gtk4::{self, prelude::*};
use gtk4::{glib, CompositeTemplate};
pub(crate) mod imp {
use super::*;
use gtk4::gdk_pixbuf::prelude::StaticType;
use gtk4::gdk_pixbuf::Pixbuf;
use std::cell::RefCell;
#[derive(Debug, CompositeTemplate)]
#[template(resource = "/io/... | true |
7aac501d8c2ad02e129085cd04879ffbd77e7bc9 | Rust | solana-labs/solana | /accounts-db/src/account_rent_state.rs | UTF-8 | 8,094 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use {
log::*,
solana_sdk::{
account::{AccountSharedData, ReadableAccount},
pubkey::Pubkey,
rent::Rent,
transaction::{Result, TransactionError},
transaction_context::{IndexOfAccount, TransactionContext},
},
};
#[derive(Debug, PartialEq, Eq)]
pub enum RentState {
/... | true |
bd9ab173ec9e03467d0e81a5f0f34f51008b6266 | Rust | daniel5151/iotedge | /containrs/oci-distribution/src/v2/tags.rs | UTF-8 | 245 | 2.578125 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
/// A list of tags for the named repository.
#[derive(Debug, Serialize, Deserialize)]
pub struct Tags {
#[serde(rename = "name")]
name: String,
#[serde(rename = "tags")]
tags: Vec<String>,
}
| true |
5fb6f8f31dfef0124caeb0d11574b1c46cc3131e | Rust | gifnksm/ProjectEulerRust | /src/bin/p052.rs | UTF-8 | 1,446 | 2.9375 | 3 | [
"MIT"
] | permissive | //! [Problem 52](https://projecteuler.net/problem=52) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use integer::Integer;
fn compute() -> u32 {
let radix = 10;
let repeat = 6;
let mut n = 0;
let mut ord... | true |
cbab7aa92ad06c4e3d338f52a3561dd4c00148a6 | Rust | jonhoo/ureq | /src/test/range.rs | UTF-8 | 614 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[cfg(feature = "tls")]
use std::io::Read;
#[cfg(feature = "tls")]
use super::super::*;
#[test]
#[cfg(feature = "tls")]
fn read_range() {
let resp = get("https://ureq.s3.eu-central-1.amazonaws.com/sherlock.txt")
.set("Range", "bytes=1000-1999")
.call()
.unwrap();
assert_eq!(resp.status... | true |
83fc1ef6184b0b15a7e5b95a232903e40f9b6489 | Rust | 46bit/advent-of-code | /2021/src/day23.rs | UTF-8 | 11,735 | 2.703125 | 3 | [] | no_license | use std::fmt;
use core::cmp::{min, max};
use std::collections::{HashMap, HashSet, BTreeMap};
#[aoc(day23, part1)]
fn part1(input: &str) -> u64 {
let (_, yx_graph, y_max, x_max) = old_part1(input);
print_yx_graph(&yx_graph, y_max, x_max);
println!();
let mut cheapest_way_to_state: HashMap<YXGraph, u64>... | true |
c433164312d7a6d796601cd4c75c2ae5618a89c5 | Rust | kaaboaye/Operating-Systems | /processes/src/sjf.rs | UTF-8 | 3,624 | 3.03125 | 3 | [] | no_license | use std::collections::{BinaryHeap, BTreeMap};
use config::simulation_mode_config::SimulationModeConfig;
use tasks::{get_tasks, Task};
pub fn start(config: SimulationModeConfig) {
println!("👀 Starting Shortest Job First simulation");
let tasks = get_tasks(&config);
let mut state = State::new(config, tas... | true |
e89b9859e490eb6772ee28482954e2e9cb380957 | Rust | uw-ictd/dAuth | /services/auth-vector/src/types/keys_5g.rs | UTF-8 | 1,852 | 2.515625 | 3 | [] | no_license | use hmac::{Hmac, Mac};
use sha2::Sha256;
use crate::types::{Autn, Ck, Ik};
pub const KAUSF_LENGTH: usize = 32;
pub const KSEAF_LENGTH: usize = 32;
const FC_KAUSF: u8 = 0x6A;
const FC_KSEAF: u8 = 0x6C;
pub type Kausf = [u8; KAUSF_LENGTH];
pub type Kseaf = [u8; KSEAF_LENGTH];
pub fn gen_kausf(mcc: &str, mnc: &str, ck... | true |
ee24cd5df22f59934ff6a8c637099c97721c556e | Rust | pepyakin/chetyre | /servant/src/serial.rs | UTF-8 | 1,712 | 2.59375 | 3 | [] | no_license | // Thanks for the examples from
// https://github.com/therealprof/microbit/
use nrf51822::{Peripherals, UART0};
pub fn init(p: &Peripherals) {
p.GPIO.pin_cnf[24].write(|w| w.pull().pullup().dir().output());
p.GPIO.pin_cnf[25].write(|w| w.pull().disabled().dir().input());
p.UART0.pseltxd.write(|w| unsafe ... | true |
da6d4bcc7a70f27c0a3fd1a4712b9d8a2cae41cb | Rust | jabedude/trpl | /functions/src/main.rs | UTF-8 | 190 | 3.53125 | 4 | [] | no_license | use std::error::Error;
fn main() {
println!("Getting value {}", add_one(3));
}
fn add_one(x: i32) -> Result<i32, Error> {
match x {
1 => Ok(2),
_ => Err(1),
}
}
| true |
623c5f5c8d32cc871b3d2a37a91b9b14ad296f1c | Rust | emirayka/nia_interpreter_core | /src/interpreter/library/keys/key_chord/list_to_key_chord.rs | UTF-8 | 3,634 | 3.375 | 3 | [
"MIT"
] | permissive | use crate::interpreter::interpreter::Interpreter;
use crate::interpreter::value::Value;
use crate::Error;
use crate::KeyChord;
use crate::library;
pub fn list_to_key_chord(
interpreter: &mut Interpreter,
key_chord_list: Value,
) -> Result<KeyChord, Error> {
let key_chord_vector =
library::read_as... | true |
2dc952626399eae26c1478827f94939d10a45289 | Rust | tuffy/emuman | /src/split.rs | UTF-8 | 3,802 | 2.875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::dat::Datafile;
use serde_derive::{Deserialize, Serialize};
use std::collections::HashMap;
use std::io;
use std::path::Path;
#[derive(Serialize, Deserialize)]
pub struct SplitDb {
games: HashMap<u64, Vec<SplitGame>>,
}
impl SplitDb {
#[inline]
pub fn new() -> Self {
Self {
ga... | true |
43aab70643a7471a60bb2827d557c6d4183aa4ed | Rust | rowanhill/aoc20 | /day08/src/main.rs | UTF-8 | 3,532 | 3.390625 | 3 | [] | no_license | #![feature(str_split_once)]
use std::io::{BufReader, BufRead};
use std::fs::File;
enum Instruction {
Acc(i32),
Jmp(i32),
Nop(i32),
}
impl Instruction {
fn from_str(def: &str) -> Instruction {
let (name, num_def) = def.split_once(" ")
.expect("Could not split instruction definition ... | true |
f1785989dca0a0fba2f5d42e342d6c315e32c76f | Rust | alexlee85/rust_by_example | /src/bin/test.rs | UTF-8 | 782 | 3.265625 | 3 | [] | no_license | extern crate bytes;
use bytes::Bytes;
fn skip_prefix<'a, 'b>(line: &'a str, prefix: &'b str) -> &'a str {
let x = str::replace(line, prefix, "");
println!("{}", x);
line
}
fn main() {
let line = "lang:en=Hello World!";
let lang = "en";
let v;
{
let p = format!("lang:{}=", lang);... | true |
677bce47156d542b7464d7eb25c08c4bf855139f | Rust | xslr/usb-device | /src/device_builder.rs | UTF-8 | 4,416 | 3.09375 | 3 | [
"MIT"
] | permissive | use bus::{UsbBusWrapper, UsbBus};
use device::{UsbDevice, UsbDeviceInfo};
use class::UsbClass;
/// A USB vendor ID and product ID pair.
pub struct UsbVidPid(pub u16, pub u16);
/// Used to build new [`UsbDevice`]s.
pub struct UsbDeviceBuilder<'a, B: 'a + UsbBus> {
bus: &'a UsbBusWrapper<B>,
info: UsbDeviceInfo... | true |
3038dcd87b5e9110533ff281738abae83b3fe45f | Rust | isgasho/fluvio | /cli/src/spu/helpers/list_output.rs | UTF-8 | 2,708 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | //!
//! # Fluvio SC - output processing
//!
//! Format SPU response based on output type
//!
use prettytable::Row;
use prettytable::row;
use prettytable::cell;
use crate::error::CliError;
use crate::common::OutputType;
use crate::common::{EncoderOutputHandler, TableOutputHandler};
use super::list_metadata::ScSpuMetad... | true |
a845a934006b6f9baccef6497bf16de06088c025 | Rust | jpfeltracco/shrubbery | /src/input.rs | UTF-8 | 1,301 | 2.796875 | 3 | [] | no_license | use amethyst::{
core::{timing::Time, transform::Transform},
derive::SystemDesc,
ecs::prelude::{Join, Read, ReadStorage, System, SystemData, WriteStorage},
input::{InputHandler, StringBindings},
renderer::Camera,
};
/// This system is responsible for moving all the paddles according to the user
/// ... | true |
ce36d421e2f5285959e6687f57cc033805115787 | Rust | sstasenco/MeiliDB | /src/rank/criterion/words_proximity.rs | UTF-8 | 3,682 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::cmp::{self, Ordering};
use std::ops::Deref;
use rocksdb::DB;
use group_by::GroupBy;
use crate::rank::{match_query_index, Document};
use crate::rank::criterion::Criterion;
use crate::database::DatabaseView;
use crate::Match;
const MAX_DISTANCE: u32 = 8;
fn index_proximity(lhs: u32, rhs: u32) -> u32 {
if... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.