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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
aa725f5e18239bd7f3e9ce9382011f1cdd7fcbfe | Rust | Roba1993/rune | /crates/rune/src/compiling/v1/assemble/expr_binary.rs | UTF-8 | 7,042 | 2.96875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::compiling::v1::assemble::prelude::*;
/// Compile a binary expression.
impl Assemble for ast::ExprBinary {
fn assemble(&self, c: &mut Compiler<'_>, needs: Needs) -> CompileResult<Asm> {
let span = self.span();
log::trace!("ExprBinary => {:?}", c.source.source(span));
log::trace!(
... | true |
8cad04a0bbc32daffe851b1dd0901d613a58c9bf | Rust | chris-morgan/diffbot-rust-client | /src/diffbot/lib.rs | UTF-8 | 12,566 | 3.0625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*!
* This library provides an API client for Diffbot.
*
* Making API requests
* -------------------
*
* There are a handful of different ways to make API calls:
*
* 1. The most basic way to make a request is with the ``call()`` function.
* Everything must be specified for each request.
*
* 2. Use the ``D... | true |
f376fd84b8b6d7c6703dd86681b5e748c2603358 | Rust | dermesser/scrapeprice | /src/err.rs | UTF-8 | 1,219 | 2.921875 | 3 | [] | no_license |
#![allow(unused)]
use std::fmt;
use std::error::Error;
pub fn logic_err(e: &dyn Error) -> HTTPError {
let s = format!("{}", e);
HTTPError::LogicError(s)
}
#[derive(Debug)]
pub enum HTTPError {
EncodingError(String),
HttpError(http::Error),
HyperError(hyper::Error),
LogicError(String),
St... | true |
f674eea5f87e3dc32f35eaaba22d05eac817521a | Rust | casperstorm/bsp-rs | /crates/decoder/src/error.rs | UTF-8 | 508 | 2.578125 | 3 | [] | no_license | use thiserror::Error;
use crate::BspVersion;
#[derive(Debug, Error)]
pub enum Error {
#[error("{0}")]
Custom(String),
#[error("Invalid or Unimplemented bsp identifier: {ident}")]
InvalidOrUnimplementedIdent { ident: i32 },
#[error("Invalid BspFormat used to decode file of version: {version:?}")]
... | true |
4ffe48602f2cb037316660f165ff64ee98cf52bd | Rust | DanielKeep/rust-advent-of-code | /src/bin/day15.rs | UTF-8 | 4,165 | 2.640625 | 3 | [] | no_license | #[macro_use] extern crate lazy_static;
extern crate arrayvec;
extern crate conv;
extern crate regex;
use arrayvec::ArrayVec;
use conv::prelude::*;
use regex::Regex;
fn main() {
let calories = args();
let ingredients = parse_input();
let (score, amts) = brute_force(&ingredients, calories);
println!("b... | true |
54e847a668348cf80eae05acaefd6d146dd59119 | Rust | RiddleAndCode/ogma | /testing/src/matcher.rs | UTF-8 | 1,954 | 3.109375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::error::Fallible;
use alloc::vec::Vec;
use ogma::clause::Token;
use ogma::matcher::*;
use ogma::object_query::Query;
#[derive(Debug, Eq, PartialEq)]
pub struct Add<'a> {
a: i32,
b: i32,
out: Vec<Query<'a>>,
}
impl<'a> Add<'a> {
clause! {
const CLAUSE = "Given the addition of d`b` and... | true |
5f7bf970de79cf1bc432eb28cd307743e2a6f15e | Rust | getappa/appa | /src/commands/processor/functions.rs | UTF-8 | 1,648 | 2.71875 | 3 | [
"MIT"
] | permissive | use super::super::super::{ConfigurationFile, ProcessEntity};
use super::Processor;
pub fn new(file: &str, processor: &Processor) {
let mut config = ConfigurationFile::new(&file);
config.processors.push(processor.to_entity());
config.save(&file);
}
pub fn update(file: &str, processor: &Processor) {
le... | true |
8d80f2b3a2dfaae5c04887b7696a0a75206c1e86 | Rust | wa7sa34cx/near-cli-rs | /src/commands/construct_transaction_command/transaction_actions/add_access_key_mode/add_access_key/mod.rs | UTF-8 | 8,572 | 2.609375 | 3 | [] | no_license | use async_recursion::async_recursion;
use dialoguer::{theme::ColorfulTheme, Input, Select};
use strum::{EnumDiscriminants, EnumIter, EnumMessage, IntoEnumIterator};
mod full_access_type;
mod function_call_type;
/// добавление ключа пользователю
#[derive(Debug, Default, Clone, clap::Clap)]
#[clap(
setting(clap::Ap... | true |
2fdd96f3c6cdc78fbf766f9fb6464a436966f5e4 | Rust | toyseed/rust-study | /src/vectors.rs | UTF-8 | 881 | 3.640625 | 4 | [] | no_license | #[test]
fn test_lock() {
let mut v = vec![1, 2, 3, 4, 5];
let first = &v[0];
println!("first {:?}", first);
v.push(6);
println!("v {:?}", v);
}
#[test]
fn test_mut_vector() {
let mut v = vec![1, 2, 3, 4, 5];
v.push(6);
let first = &v[0];
println!("first : {}", first);
for i in... | true |
c5f2d7316e931d538717d4a849dce36470809d17 | Rust | CryZe/romhack-compiler | /backend/src/iso/virtual_file_system.rs | UTF-8 | 5,433 | 2.984375 | 3 | [
"MIT"
] | permissive | use std::borrow::Cow;
#[derive(Debug)]
pub enum Node<'a> {
Directory(Box<Directory<'a>>),
File(File<'a>),
}
impl<'a> Node<'a> {
pub fn as_directory(&self) -> Option<&Directory<'a>> {
if let &Node::Directory(ref dir) = self {
Some(dir)
} else {
None
}
}
... | true |
f6d78a159b167fe130b55fc921869cd8741832c5 | Rust | rogercoll/oprollups | /src/lib.rs | UTF-8 | 3,272 | 2.921875 | 3 | [] | no_license | pub mod batch;
pub mod transaction;
pub mod mktree;
pub mod account;
use std::collections::HashMap;
use std::fmt;
impl fmt::Display for Batch {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Pre-State root: {} \nPost-State root: {}\n ###Transactions###\n{}", self.pre_state_root, sel... | true |
9675f6ae65def2da53d9f2c2a342258baab9c90b | Rust | poorpy/pli | /tests/lexer.rs | UTF-8 | 1,605 | 2.921875 | 3 | [] | no_license | use plib::lexer;
use std::collections::VecDeque;
#[test]
fn tokenize_parens() {
let vec = vec![lexer::Token::LParen, lexer::Token::RParen];
let tokens = lexer::tokenize("()".to_owned()).unwrap();
let matching = vec
.iter()
.zip(tokens.iter())
.filter(|&(a, b)| a == b)
.count... | true |
9293a0d0a982882f94bb50bad2d1412d0f48928b | Rust | hfantin/cursos | /rust/c15-smart-pointers/drop/src/main.rs | UTF-8 | 471 | 3.734375 | 4 | [] | no_license | fn main() {
println!("drop");
let c = CustomSmartPointer{
data: String::from("my stuff"),
};
let d = CustomSmartPointer{
data: String::from("other stuff"),
};
// explicit call of drop
// drop(c);
println!("Custom Stuff created");
}
struct CustomSmartPointer {
data: ... | true |
e502ef3b015294d910f78c49d4adddeb83418ed0 | Rust | LK-Herman/Cookbook | /Desktop/gui/src/gui_data/connections/buttons/login_window/mod.rs | UTF-8 | 2,777 | 2.515625 | 3 | [] | no_license | use gtk::prelude::*;
use crate::gui::favorites_update;
use crate::gui::initialize_user;
use crate::gui_data::login_window::LoginWindow;
use crate::gui_data::GuiData;
use crate::buttons::login_window::login_buttons::email::on_email_login_button_clicked;
use crate::buttons::login_window::login_buttons::facebook::on_fac... | true |
51259c77a1814b36cbbb44553773bbeac1e63211 | Rust | tweber12/lorentz_vector_rs | /src/lib.rs | UTF-8 | 12,796 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2018 Torsten Weber
//
// 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according t... | true |
affaa0c5a11fc17684820fca827f23b4dad6db5e | Rust | madmax28/aoc2018 | /day3/src/main.rs | UTF-8 | 1,971 | 3.25 | 3 | [] | no_license | extern crate regex;
use regex::Regex;
use std::fs;
use std::num::ParseIntError;
use std::str;
use std::str::FromStr;
struct Claim {
id: usize,
pos: (usize, usize),
size: (usize, usize),
}
impl FromStr for Claim {
type Err = ParseIntError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
... | true |
70437559e1002084ca466fa43b250051fbd924a6 | Rust | qinxiaoguang/rs-lc | /src/solution/l1079.rs | UTF-8 | 1,531 | 3.265625 | 3 | [] | no_license | use super::Solution;
use std::collections::HashSet;
impl Solution {
pub fn num_tile_possibilities(tiles: String) -> i32 {
// 非空且不能重复,dfs + 剪枝
let mut cache = HashSet::new();
let mut res = 0;
let tiles: Vec<char> = tiles.chars().collect();
for i in 0..tiles.len() {
... | true |
9c71d24aba08c8ece2fcee041917a6d996518a94 | Rust | yyogo/iter_to_array | /src/lib.rs | UTF-8 | 9,938 | 3.484375 | 3 | [
"MIT"
] | permissive | #![no_std]
#![feature(min_const_generics,maybe_uninit_extra)]
use core::mem::{self, MaybeUninit};
#[derive(Clone,Debug,PartialEq)]
pub enum ToArrayError {
TooShort(usize, usize),
TooLong(usize)
}
#[derive(Copy,Clone,Debug,PartialEq,Eq)]
pub enum MaybePartial<A> {
Full(A),
Partial(A, usize),
Empty... | true |
3448b21a075eaa06403f0782f1d31dd53bf60b69 | Rust | sakjur/incode | /prime/prime.rs | UTF-8 | 756 | 3.234375 | 3 | [] | no_license | fn findprimes(n: i64) -> Vec<i64> {
let candidates: Vec<i64> = (2..n).collect();
return reduce(candidates, vec![]);
}
fn reduce(mut candidates: Vec<i64>, mut finalists: Vec<i64>) -> Vec<i64> {
if candidates.is_empty() {
return finalists;
} else {
let first = *candidates.first().unwrap();
let mut done = false... | true |
8cd5c8429b6780f7cc7a5778e912e25e8dd8a645 | Rust | forksarchive/dolores | /src/service.rs | UTF-8 | 1,040 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::net;
use std::sync::Arc;
use rustls::Session;
#[derive(Clone, Debug)]
pub struct Service {
pub domain: String,
pub addr: net::SocketAddr,
pub proxy: Arc<crate::proxy::TcpProxy>,
}
impl Service {
pub fn new(domain: &str, addr: net::SocketAddr, proxy: crate::proxy::Type) -> Self {
Serv... | true |
502f976c3653b79c98f913d066613c4282ca6808 | Rust | m00p1ng/learn-rust | /example/src/vectors.rs | UTF-8 | 377 | 3.546875 | 4 | [] | no_license | fn vectors() {
let mut a = Vec::new();
a.push(1);
a.push(2);
a.push(4);
println!("a = {:?}", a);
match a.get(6) {
Some(x) => println!("a[6] = {}", x),
None => println!("error, no such element"),
}
let last_elem = a.pop(); // Option
println!("last elem is {:?}, a = {:?}", last_elem, a);
wh... | true |
6f919ff5f64b95ce3eeda1603352a2aa8f9d7120 | Rust | marinewater/polyline-rust | /src/lib.rs | UTF-8 | 10,693 | 3.71875 | 4 | [
"MIT"
] | permissive | //! # polyline_rust
//! Crate to encode/decode polylines in "Encoded Polyline Algorithm Format"
//!
//! Usage example:
//! ```
//! use polyline_rust::{Point, encode, decode};
//!
//! fn main() {
//! let polyline = encode(vec![
//! Point::new(12.34567, 89.01234),
//! Point::new(12.34891, 89.01567),
/... | true |
dc7d4204245c59226a1d442850bbba040456710d | Rust | mnts26/aws-sdk-rust | /sdk/cloudhsmv2/src/model.rs | UTF-8 | 53,371 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
/// <p>Contains a tag. A tag is a key-value pair.</p>
#[non_exhaustive]
#[derive(std::clone::Clone, std::cmp::PartialEq)]
pub struct Tag {
/// <p>The key of the tag.</p>
pub key: std::option::Option<std::string::String>,
/// <p... | true |
58d98c20427fbe6b8e01bcc3c74756bee2ed4147 | Rust | profsucrose/the-ray-tracer-challenge | /src/implementations/pattern.rs | UTF-8 | 881 | 3.109375 | 3 | [] | no_license | use std::fmt::Debug;
use super::{matrices::Matrix4x4, shape::*, tuples::*};
pub trait PatternClone {
fn clone_box(&self) -> Box<dyn Pattern>;
}
impl<T> PatternClone for T
where
T: 'static + Pattern + Clone
{
fn clone_box(&self) -> Box<dyn Pattern> {
Box::new(self.clone())
}
}
impl Clone fo... | true |
788c5b577035ee77f5e50fa8417bc68d4c20a4a5 | Rust | ehaskins/rust-arduino | /src/bin/echo.rs | UTF-8 | 4,581 | 2.5625 | 3 | [] | no_license | #![no_std]
#![no_main]
extern crate panic_halt; // you can put a breakpoint on `rust_begin_unwind` to catch panics
extern crate sam3x8e;
use cortex_m_rt::entry;
use sam3x8e::{EFC0, EFC1, PIOB, RTT};
fn delay_ms(rtt: &RTT, ms: u32) {
// We're not considering overflow here, 32 bits can keep about 49 days in ms
let... | true |
df87efe97eb670ee0ce989a5fb18b041bbfaa239 | Rust | yutiansut/actix-server-alt | /actix-http-alt/src/util/error_logger.rs | UTF-8 | 1,645 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use std::fmt::Debug;
use actix_service_alt::{Service, ServiceFactory};
use std::future::Future;
use std::task::{Context, Poll};
/// A factory that log and print error with Debug impl
pub struct ErrorLoggerFactory<F> {
factory: F,
}
impl<F> ErrorLoggerFactory<F> {
pub fn new(factory: F) -> Self {
Self... | true |
c7bb078464fb33b4aa6ff0f6e72ff5cae7be8505 | Rust | fugashy/load_to_rustacean | /adder/src/lib.rs | UTF-8 | 2,332 | 3.6875 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | // ベンチマークテストもサポートしている
//
// また,ドキュメントに現れたコード例もコンパイルされる
// すごいな
//
// 関数名を指定すると,その関数のみ実行される
// 指定した文字と合致するテストが実行される.これもすごい
// pubにしないと内部関数となる
// この場合,使われないとdead_codeワーニングがでる
pub fn add_two(a: i32) -> i32 {
a + 2
}
pub fn greeting(name: &str) -> String {
format!("hello {}", name)
}
// 関数の出力はテストライブラリによってキャプチャされ... | true |
c210f3ca75a7eed37d5b06659ac5a930f846c782 | Rust | wulymammoth/rust-book | /collections/src/main.rs | UTF-8 | 4,830 | 3.984375 | 4 | [] | no_license | fn main() {
delimit("creating a new vector (rare)");
let v: Vec<i32> = Vec::new();
println!("{:?}", v);
delimit("creating a vector more common (with `vec!` macro)");
let mut v = vec![1, 2, 3];
println!("{:?}", v);
for i in 4..10 {
v.push(i);
}
delimit("reading elements in ... | true |
bb776c9a381379e3751886bd4873f57ebcce5990 | Rust | K2Da/hrkk | /src/service/cloudwatch/alarm_history.rs | UTF-8 | 2,649 | 2.515625 | 3 | [] | no_license | use crate::service::prelude::*;
#[derive(Serialize)]
pub(crate) struct Resource {
info: Info,
}
pub(crate) fn new() -> Resource {
Resource {
info: Info {
sub_command: Some(SubCommand::Cloudwatch {
command: Cloudwatch::AlarmHistory,
}),
key_attribute:... | true |
1c3b33e85d492022962002de0f04b1495a27fc43 | Rust | Mubelotix/wasm-game-lib | /src/inputs/mouse.rs | UTF-8 | 6,799 | 3.046875 | 3 | [
"MIT"
] | permissive | use core::convert::TryFrom;
use crate::elog;
/// An event related to the mouse
#[derive(Debug)]
pub enum MouseEvent {
/// A click with the main button
Click(u32, u32),
DoubleClick(u32, u32),
Move(u32, u32),
Enter(u32, u32),
Leave(u32, u32),
Up(Button, u32, u32),
Down(Button, u32, u32),
... | true |
4e8c16b48cbfa3e2c4e08915b510ec2a02808c80 | Rust | arathunku/rjrn | /src/config.rs | UTF-8 | 5,361 | 3.171875 | 3 | [
"MIT"
] | permissive | //! File Journal which implements handlers for a journal that's on the file disk.
//! It's the default and only handler right now.
//!
//! Usage for bootstraping and saving:
//!
//!```
//! use rjrn::config::Config;
//! use rjrn::journal::Journal;
//! use rjrn::file_journal::FileJournal;
//!
//! let journal ... | true |
640f4724363aa5852455c3ecc9ebe50afa8cc998 | Rust | kuririn246/sabun_data_model | /sabun_maker/src/imp/structs/root_obj.rs | UTF-8 | 1,908 | 2.734375 | 3 | [] | no_license | use crate::{HashM, HashS};
use crate::imp::structs::root_value::RootValue;
use crate::imp::structs::rust_param::RustParam;
use crate::imp::structs::util::set_sabun::{SetSabunError, verify_set_sabun};
#[derive(Debug, PartialEq)]
pub struct RootObject{
///listのobjectの場合、defaultはlist側にあるが、ここには初期値が入る。
default : Bo... | true |
b7bff2020155551f4a9d7966c4d915483edbc086 | Rust | franziskuskiefer/kerkour.com | /2021/rust_postgresql_job_queue/src/postgres.rs | UTF-8 | 3,983 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use crate::{
db::DB,
queue::{Job, Message, Queue},
};
use chrono;
use sqlx::{self, types::Json};
use ulid::Ulid;
use uuid::Uuid;
#[derive(Debug, Clone)]
pub struct PostgresQueue {
db: DB,
max_attempts: u32,
}
const MAX_FAILED_ATTEMPTS: i32 = 3; // low, as most jobs also use retries internally
#[deriv... | true |
96d9fa4112c8cac00429e515104779ea07a02bd3 | Rust | KevinGrandon/overlord | /src/overlord/config_loader.rs | UTF-8 | 5,415 | 2.671875 | 3 | [] | no_license | // This module handles loading all manifest files and converting files from the
// manifest interchange format to the in memory strucutred format used in later
// operations.
use config::{Suite, SuitePath};
use util::{PathWrapper};
use interchange::{Manifest, ManifestSuite};
use error::{OverlordError, OverlordResult};
... | true |
e3d86d7754cb487919d837ff308ca5450c4e0ace | Rust | Nesquick0/Adventofcode | /2022/04/src/main.rs | UTF-8 | 1,590 | 3.125 | 3 | [] | no_license | #![allow(non_snake_case)]
#![allow(unused_parens)]
use regex::Regex;
use std::fs;
fn part1(text: &String) {
// Regular expression to parse range of ids 1-2,3-4.
let patternIds = Regex::new(r"^(?P<a1>\d+)-(?P<a2>\d+),(?P<b1>\d+)-(?P<b2>\d+)$").unwrap();
let mut counter: i64 = 0;
let mut counterOverlap:... | true |
3fc34d2ce22b8c17b06b7d3ef028f8114aa480c0 | Rust | rust-lang/rust | /tests/ui/iterators/float_iterator_hint.rs | UTF-8 | 652 | 3 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // #106728
fn main() {
for i in 0.2 {
//~^ ERROR `{float}` is not an iterator
//~| `{float}` is not an iterator
//~| NOTE in this expansion of desugaring of `for` loop
//~| NOTE in this expansion of desugaring of `for` loop
//~| NOTE in this expansion of desugaring of `for` ... | true |
9bcb3d93e9b6780471a0ce063fbf0a49cab73016 | Rust | cstegel/exercismises | /rust/dot-dsl/src/graph/graph_items/edge.rs | UTF-8 | 530 | 3 | 3 | [] | no_license | use std::collections::HashMap;
#[derive(Debug, PartialEq, Clone)]
pub struct Edge {
pub start: String,
pub end: String,
pub attrs: HashMap<String, String>,
}
impl Edge {
pub fn new(start: &str, end: &str) -> Edge {
Edge {
start: start.to_string(),
end: end.to_string(),
... | true |
3b5c8e1beec9e6d91f3217594f5a95fec9477da3 | Rust | yutiansut/clickhouse-rs-1 | /clickhouse-postgres-client/src/row.rs | UTF-8 | 2,246 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::convert::TryFrom as _;
use sqlx_clickhouse_ext::{
sqlx_core::{
column::Column as _, column::ColumnIndex, error::Error, postgres::PgRow, row::Row as _,
type_info::TypeInfo as _, value::ValueRef as _,
},
value::ValueRefTryGet as _,
};
use crate::type_info::{ClickhousePgType, Clickho... | true |
40861254aea83b0fe9a7a4e9f92a2b4248034274 | Rust | rectinajh/rust-leetcode | /src/rust_syntax/borrow_trait.rs | UTF-8 | 955 | 3.953125 | 4 | [] | no_license | use std::borrow::Borrow;
use std::fmt::Display;
/*
Which should I use?
We can see how they’re kind of the same: they both deal with owned and borrowed versions of some type. However, they’re a bit different.
Choose Borrow when you want to abstract over different kinds of borrowing, or when you’re building a data struc... | true |
07d1a479ef1afaf241ce4c418dd728878f02d636 | Rust | linkerd/linkerd2-proxy | /linkerd/proxy/http/src/retain.rs | UTF-8 | 3,203 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | //! Provides a middleware that holds an inner service as long as responses are
//! being processed.
use linkerd_stack::layer;
use pin_project::pin_project;
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
/// Retains an inner service as long as its HTTP responses are being processsed
/// so ... | true |
e9a5cd262606158b4938ab996d35fbcf6bffc2c6 | Rust | cute-jumper/LeetCode | /Rust/src/s19_remove_nth_node_from_end.rs | UTF-8 | 1,809 | 3.28125 | 3 | [] | no_license | use crate::list_node::ListNode;
struct Solution;
impl Solution {
pub fn remove_nth_from_end(head: Option<Box<ListNode>>, n: i32) -> Option<Box<ListNode>> {
let mut vhead = Some(Box::new(ListNode { val: 0, next: head }));
let mut fast = &vhead;
let mut count = 0;
while let Some(node... | true |
ee2457157288ea873575773c4960863fff28edbf | Rust | larsjarlvik/wgpu-rs | /src/world/map/task.rs | UTF-8 | 413 | 2.625 | 3 | [] | no_license | pub struct Task<'a> {
pub label: String,
pub pipeline: &'a wgpu::ComputePipeline,
pub run_times: u32,
pub stage_count: u32,
}
impl<'a> Task<'a> {
pub fn new(label: &str, pipeline: &'a wgpu::ComputePipeline, run_times: u32, stage_count: u32) -> Self {
Self {
label: label.to_strin... | true |
072f1c0c3ae4a501da6e9d563d5e84f8885ca247 | Rust | peacekeeper/sdk | /vcx/libvcx/src/utils/libindy/return_types.rs | UTF-8 | 11,690 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | extern crate libc;
use self::libc::c_char;
use std::sync::mpsc::Receiver;
use std::sync::mpsc::RecvTimeoutError;
use utils::libindy::next_i32_command_handle;
use utils::libindy::callback;
use utils::libindy::error_codes::map_indy_error;
use utils::timeout::TimeoutUtils;
use utils::error;
use std::sync::mpsc::channel;
... | true |
23e7fbc73bce375a2e7ec0d320b8faab468154a6 | Rust | alexander-koch/bachelors-thesis-bin | /src/harrison.rs | UTF-8 | 15,008 | 2.6875 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use crate::ebnf::{Grammar, Rule};
use crate::ll::FFSets;
use crate::lr::{is_final, LR0Item};
use log::debug;
pub fn fmt_tex_lr0_set(grammar: &Grammar, states: &HashSet<LR0Item>) -> String {
format!(
"$ {} $",
states
.iter()
... | true |
f14cfa4efcfe4d0e1616ded0a80c7e79348901bf | Rust | AlanRace/voronator-rs | /benches/delaunator.rs | UTF-8 | 5,130 | 2.734375 | 3 | [
"MIT"
] | permissive | use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::distributions::Uniform;
use rand::Rng;
use rand_distr::StandardNormal;
use voronator::delaunator::{triangulate, Point};
pub fn uniform20000(c: &mut Criterion) {
let mut rng = rand::thread_rng();
let range = Uniform::new(0., 1000.... | true |
63cdbe877ed1a33d48985d826b3231fc6320d374 | Rust | mozilla/gecko-dev | /third_party/rust/icu_locid/src/parser/errors.rs | UTF-8 | 2,025 | 2.765625 | 3 | [
"LicenseRef-scancode-unicode",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
use displaydoc::Display;
/// List of parser errors that can be generated
/// while parsing [`LanguageIdentifier`](cr... | true |
fda4fb4810e735c572596041386308a84b4ea185 | Rust | Owez/holenews | /src/map.rs | UTF-8 | 187,655 | 3.1875 | 3 | [] | no_license | //! Rich inner-game map bindings; see [Map] for top-level variants
use serde::Serialize;
/// Common trait for all map locations of a given hex
pub trait Location: Sized {
/// Gets map location from api-centric name
fn from_name(name: &str) -> Option<Self> {
todo!("map location from name '{}'", name)
... | true |
7b7c824f15c73cdb69948bc2b3d45fa7d0f3cfc5 | Rust | seed-rs/seed | /examples/canvas/src/lib.rs | UTF-8 | 3,565 | 2.796875 | 3 | [
"MIT"
] | permissive | //! [Web-sys docs](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.CanvasRenderingContext2d.html)
//! [Web-sys example](https://rustwasm.github.io/wasm-bindgen/examples/2d-canvas.html)
//! [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawWindow)
use seed::{prelude::*, *};
... | true |
6ec0073dda6ca9518e7a85d14e828fb456fa83c1 | Rust | EliasDeMa/exercism-exercises | /rust/saddle-points/src/lib.rs | UTF-8 | 1,418 | 3.546875 | 4 | [] | no_license | pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> {
let max_values_row: Vec<u64> = input.iter()
.map(|row| find_row_max(row))
.collect();
let min_values_column: Vec<u64> = (0..input[0].len()) //input[0].len() = amount of ... | true |
730fd78f1c94487f20d58ffc69102ec87fe27da3 | Rust | porglezomp/canvas-cli | /src/config.rs | UTF-8 | 1,296 | 2.796875 | 3 | [] | no_license | use std;
use std::io::Read;
use toml;
use xdg;
#[derive(Deserialize, Debug)]
pub struct Config {
api: Api,
}
#[derive(Deserialize, Debug)]
pub struct Api {
key: String,
url: String,
}
impl Config {
pub fn api_url(&self) -> String {
format!("https://{}/api/v1", self.api.url)
}
pub fn... | true |
b015774390ebe4e89cb66b4c90b03fa7da02d9fa | Rust | pathalog/pathalog_rs | /src/nand/runtime.rs | UTF-8 | 17,689 | 3.6875 | 4 | [
"Apache-2.0"
] | permissive | #[derive(Debug,Clone,Copy,PartialEq,Eq)]
pub enum Bit {
Zero,
One
}
impl Bit {
pub fn one() -> Self {
Self::One
}
pub fn zero() -> Self {
Self::Zero
}
}
impl Default for Bit {
fn default() -> Self {
Bit::zero()
}
}
use Bit::*;
use core::fmt::{Display, Formatter... | true |
32ef78e67ebd7a24d35e708e814ae2e2104e7376 | Rust | 3kyro/caprice | /examples/echo_alternate.rs | UTF-8 | 2,056 | 3.265625 | 3 | [] | no_license | use caprice::theme::{Theme, DEFAULT_THEME};
use caprice::{Caprice, CapriceCommand};
use crossterm::style::Color;
use std::thread;
use std::time::Duration;
fn main() {
let caprice = Caprice::new()
.set_prompt("!:") // set the prompt
.disable_ctrl_c() // pressing control + c won't terminate the capric... | true |
e420d0a6a108c5f3f27fd2e22569386a4f5f124a | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/dbus/src/matchrule.rs | UTF-8 | 2,249 | 2.703125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
crate
:
:
{
Message
MessageType
BusName
Path
Interface
Member
}
;
#
[
derive
(
Clone
Debug
Default
)
]
pub
struct
MatchRule
<
'
a
>
{
pub
msg_type
:
Option
<
MessageType
>
pub
sender
:
Option
<
BusName
<
'
a
>
>
pub
path
:
Option
<
Path
<
'
a
>
>
pub
interface
:
Option
<
Interface
<
'
a
>
>
pub
member
:
Option
<
Me... | true |
59334be35d4c4e2d6c04a44bfb9cf3aeaf3f08dd | Rust | ndr-brt/rslsk | /src/lib.rs | UTF-8 | 1,236 | 2.890625 | 3 | [] | no_license | use std::net::{TcpStream};
use std::io::{Error};
use protocol::message::{Message};
use std::sync::mpsc::{Sender};
use server::Server;
mod protocol;
mod server;
mod utils;
pub struct Slsk {
username: &'static str,
password: &'static str,
server_out: Sender<Box<dyn Message>>,
}
impl Slsk {
pub fn conne... | true |
19f70c024a64f5758f8ddaad0850581b6b06b2d1 | Rust | alexey-mz/rust | /etl/src/lib.rs | UTF-8 | 274 | 2.65625 | 3 | [] | no_license | use std::collections::BTreeMap;
pub fn transform(h: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> {
let mut res = BTreeMap::new();
for (&k, v) in h {
v.iter().for_each(|&x| {
res.insert(x.to_ascii_lowercase(), k);
})
}
res
}
| true |
ea229a9079baefd9160a9f22ff86ccbe44d1a5b8 | Rust | jwarley/hcpi | /src/mdp.rs | UTF-8 | 4,272 | 3.046875 | 3 | [
"MIT"
] | permissive | extern crate convert_base;
extern crate ndarray;
use convert_base::Convert;
use ndarray::prelude::*;
use std::f64::consts::{E, PI};
pub mod util {
extern crate rayon;
use rayon::prelude::*;
/// Unbiased sample standard deviation of a vector xs with mean x_bar
pub fn sample_std(xs: &Vec<f64>, x_bar: f6... | true |
b54acc38e9806bcadf9208cd1bb59eb972baae59 | Rust | drwilco/aoc | /template/src/bin/first.rs | UTF-8 | 342 | 3.34375 | 3 | [] | no_license | use std::fs;
fn do_the_thing(input: &str) {
}
fn main() {
let input = fs::read_to_string("input.txt").unwrap();
println!("{:?}", do_the_thing(&input));
}
#[cfg(test)]
mod tests {
use super::*;
use test_case::test_case;
#[test_case("Hello world!" => ())]
fn test(input: &str) {
do_the_... | true |
e7796621dbdcc01f862435442505c70718024ae4 | Rust | brunoczim/thedes | /src/storage.rs | UTF-8 | 1,487 | 2.765625 | 3 | [
"MIT"
] | permissive | /// A game session save database related utilities.
pub mod save;
/// A game session save database related utilities.
pub mod settings;
use crate::error::{ErrorExt, Result};
use chrono::Local;
use directories::ProjectDirs;
use std::{
fmt,
path::{Path, PathBuf},
};
use tokio::{fs, io::ErrorKind::AlreadyExists}... | true |
8234f4a407b53b44ff6a5a326452f521464c13b4 | Rust | arizuk/programming-contest-solutions | /codeforces/1176/E/main.rs | UTF-8 | 2,543 | 3.0625 | 3 | [] | no_license | #[allow(unused_macros)]
macro_rules! debug {
($($a:expr),*) => {
#[cfg(debug_assertions)]
writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
}
}
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::Write;
fn solve... | true |
6cda94db113049b925e5ac8d6347cf2121490d49 | Rust | coriolinus/adventofcode-2015 | /day15/src/lib.rs | UTF-8 | 2,487 | 3.5 | 4 | [] | no_license | //! # Day 15: Science for Hungry People
//!
//! Today, you set out on the task of perfecting your milk-dunking cookie recipe. All you have to
//! do is find the right balance of ingredients.
//!
//! Your recipe leaves room for exactly `100` teaspoons of ingredients. You make a list of the
//! remaining ingredients you ... | true |
6ab051dc6e6a681df88b839bb6c12d6e1586f9d5 | Rust | jean553/rust-divisible-game | /rust-divisible-game/src/main.rs | UTF-8 | 2,212 | 3.515625 | 4 | [] | no_license | extern crate rand;
use std::io::stdin;
use std::time::Instant;
use rand::{thread_rng, Rng};
/**
* Handles user input with expected error message if failure.
*
* Args:
*
* `destination` - where the input should be stored
*/
fn handle_input(destination: &mut String) {
stdin().read_line(destination).expect("I... | true |
f787c855e0d3047351027fd59773710bff389b1c | Rust | lopsided98/crate2nix | /crate2nix/src/nix_build.rs | UTF-8 | 2,534 | 3.109375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Code for invoking `nix-build`.
use std::io::BufRead;
use std::io::Write;
use std::path::Path;
use std::process::Command;
use anyhow::bail;
use anyhow::format_err;
use anyhow::Error;
/// Call `nix build` in the given directory on the `default.nix` in that directory.
pub fn nix_build(
project_dir: impl AsRef<P... | true |
a6f255b8c6853121603d0b0375f5efaa6fc71202 | Rust | acmcarther/cargo-raze-examples | /bazel/complicated_cargo_library/cargo/vendor/hibitset-0.3.2/src/util.rs | UTF-8 | 1,574 | 3.125 | 3 | [
"Apache-2.0"
] | permissive |
/// Type used for indexing.
pub type Index = u32;
/// Base two log of the number of bits in a usize.
#[cfg(target_pointer_width= "64")]
pub const BITS: usize = 6;
#[cfg(target_pointer_width= "32")]
pub const BITS: usize = 5;
/// Amount of layers in the hierarchical bitset.
pub const LAYERS: usize = 4;
pub const MAX: ... | true |
8c33fa78620c4ae58f4b4185f59dbcc081e8bb7d | Rust | isabella232/interval-tree | /src/interval_tree/node.rs | UTF-8 | 585 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::ops::RangeInclusive;
pub(crate) struct Node<K: Clone + Ord, V> {
pub(crate) key: RangeInclusive<K>,
pub(crate) value: V,
pub(crate) max: K,
pub(crate) height: u32,
pub(crate) left: Option<Box<Node<K, V>>>,
pub(crate) right: Option<Box<Node<K, V>>>,
}
impl<K: Clone + Ord, V> Node<K, V>... | true |
fc8ed42af372756a4099a4fff3aa3e1e17b903c7 | Rust | rcore-os-infohub/ossoc2020-iLFTH-daily | /RUST/编程小练习15题/RUST代码/spell_it_right/src/main.rs | UTF-8 | 745 | 3.25 | 3 | [] | no_license | // input "12345"
fn char_counter<T:AsRef<str>>(arg: T) -> usize {
arg.as_ref().chars().count()
}
fn main() {
let mut s:String;
let temp:[&str;10] = ["zero","one","two","three","four","five","six","seven","eight","nine"];
let mut input = String::new();
std::io::stdin().read_line(&mu... | true |
b1f074be699bf5b6e96dbc348dcd24ac211fc2d6 | Rust | jawwadturabi/AXIOM-IOT-Batch-04 | /closures/src/main.rs | UTF-8 | 1,678 | 3.546875 | 4 | [] | no_license | // use std::thread;
// use std::time::Duration;
// fn generate_workout(intensity: u32, random_number: u32) {
// let calculate = |a| {
// println!("calculating slowly...");
// thread::sleep(Duration::from_secs(2));
// a
// };
// if intensity < 25 {
// println!("Today, do {} pu... | true |
49f094888e17c57f86de7ff007b12b334b3ecb96 | Rust | lensvol/adventofcode | /day6/src/main.rs | UTF-8 | 2,977 | 3.171875 | 3 | [] | no_license | extern crate regex;
use std::collections::HashMap;
use std::io::{self, Read};
use regex::Regex;
static CMD_RE: &'static str = r"(turn on|toggle|turn off) (\d+),(\d+) through (\d+),(\d+)";
type LightsMap = HashMap<(i32, i32), u8>;
type LightSwitch = fn(&mut LightsMap, i32, i32) -> ();
fn read_from_stdin() -> String... | true |
7e5fd6acdb139796510fa33dcc8d21ae19b59d6d | Rust | 4xrsJCr9/alsa-rs | /src/poll.rs | UTF-8 | 3,053 | 2.90625 | 3 | [] | no_license | //! Tiny poll ffi
//!
//! This should probably have been part of the libc crate instead,
//! but since it isn't, here's what you need to use the poll system call
//! with ALSA.
use libc;
use super::error::*;
use std::os::unix::io::{RawFd, AsRawFd};
use std::io;
bitflags! {
pub flags PollFlags: ::libc::c_short {
... | true |
222f6eb3b92452586b5f934738c57ad01b084271 | Rust | reproto/reproto | /lib/languageserver/models.rs | UTF-8 | 3,962 | 3.109375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Data models that are shared for the language server.
use reproto_core::{Position, RpVersionedPackage};
use std::collections::BTreeSet;
use url::Url;
/// Specifies a rename.
#[derive(Debug, Clone)]
pub enum Rename {
/// A prefix that should be name.
Prefix { prefix: String },
/// Rename a local type.
... | true |
55ffc0235cd6e834957e9d80df1146dbf7073bd6 | Rust | rust-random/rand | /rand_distr/tests/sparkline.rs | UTF-8 | 3,900 | 3.234375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2021 Developers of the Rand project.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
/... | true |
50371a4e6625ddf056cc4be34c811546c554f5ed | Rust | 38/d4-format | /d4/src/index/data_index/data.rs | UTF-8 | 4,173 | 2.6875 | 3 | [
"MIT"
] | permissive | use std::{io::Result, iter::Once, marker::PhantomData};
use crate::{
task::{Task, TaskContext, TaskOutputVec, TaskPartition},
D4TrackReader,
};
use super::DataIndexType;
pub trait DataSummary: Sized + Send + Sync + Clone {
const INDEX_NAME: &'static str;
const INDEX_TYPE_CODE: DataIndexType;
fn i... | true |
5f9125feefca7a6501313cb8ab313c932bcc7b75 | Rust | michelepagot/granchiettimarini | /src/arrays.rs | UTF-8 | 645 | 3.953125 | 4 | [] | no_license | pub fn run(){
// Fixed in size and type
let mut numbers: [i64; 5] = [1111111, 222222222, 33333333, 44444444, 555555555];
// Change an element value
numbers[3] = 0;
println!("{:?}", numbers);
// Get a single value
println!("Single value 2: {}", numbers[2]);
// Get length
println!... | true |
ecf22caa9afc08652765292f629fd5f9815dd5af | Rust | carsin/rust_projects | /age_100_calculator/src/main.rs | UTF-8 | 1,003 | 3.703125 | 4 | [] | no_license | use std::io;
use std::io::Write;
extern crate chrono;
use chrono::prelude::*;
fn main() {
let name = input(("What is your name? ").to_string());
let age = input(format!("How old are you, {}? ", name))
.parse().expect("Failed converting age to number");
let centennial_year = calculate_year_of_cent... | true |
1e72bdf21a0dfd2969801fd760fb740ea2d3f8a7 | Rust | jsonprima/jsonprima | /src/validate_string.rs | UTF-8 | 10,809 | 3.34375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::error::{Error, ErrorType};
use crate::json::{general_tokens::*, ParseTokens, StackTokens, JSON};
use crate::scanner::Scanner;
// Given the json_document structure where the iterator index is in the
// start of a Unicode escape sequence values, i.e. X in \uXXXX,
// get the decimal representation of the escap... | true |
95d21c51978e7ef92451b957dfdef5b1abf456af | Rust | flix477/rustyboy | /packages/core/src/video/memory/sprite_attribute_table.rs | UTF-8 | 3,862 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::bus::{Readable, Writable};
use crate::util::bits::get_bit;
use crate::util::savestate::{read_savestate_byte, LoadSavestateError, Savestate};
#[derive(Clone)]
pub struct SpriteAttributeTable {
table: [OAMEntry; 40],
}
impl SpriteAttributeTable {
pub fn new() -> Self {
Self::default()
}
... | true |
ee04d43eb367376cd6655f2156b31e9b95d26837 | Rust | emk/rust-cld2 | /src/detection.rs | UTF-8 | 5,428 | 2.703125 | 3 | [
"Apache-2.0",
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | //! Interfaces to the detector itself.
use std::sync::Mutex;
use std::ffi::{CString, CStr};
use std::str::from_utf8;
use std::default::Default;
use std::ptr::{null, null_mut};
use libc::{c_int, c_double, c_char};
use ffi::{CLDHints, Encoding, CLD2_ExtDetectLanguageSummary4,
CLD2_DetectLanguageVersion};
use ... | true |
23ce322564b371b65f89f76677d36ea3f9efeadf | Rust | contlist/contlist | /src/domain_model/entities/contact.rs | UTF-8 | 872 | 2.6875 | 3 | [] | no_license | use crate::domain_model::phone_number::PhoneNumber;
use getset::{Getters, MutGetters};
use rocket_okapi::JsonSchema;
use serde::Serialize;
use std::error::Error as StdError;
use thiserror::Error;
#[derive(Serialize, Clone, Getters, MutGetters, JsonSchema, Debug)]
#[getset(get = "pub", get_mut = "pub")]
pub struct Cont... | true |
45a772581b155d545b874325960be8b24bae0ec1 | Rust | charliejeynes/arc | /legacy/post/panda/pipe/mod.rs | UTF-8 | 3,561 | 2.53125 | 3 | [] | no_license | //! Rendering pipe sub-module.
use crate::{
geom::Ray,
sim::panda::{lighting, Cell, ShaderSettings},
};
use nalgebra::Point3;
use palette::Gradient;
use palette::{LinSrgba, Srgba};
use rand::rngs::ThreadRng;
/// Determine the colour of a given ray.
#[inline]
#[must_use]
pub fn colour(
sett: &ShaderSetting... | true |
6bfcedfb4ae6bc51975d1f34f26ca37bfe92d1bf | Rust | takenta/feedforward_demo | /src/tools/feed_forward.rs | UTF-8 | 4,281 | 3.171875 | 3 | [] | no_license | use tools::dual_number::DualNumber;
pub struct FeedForward<'a> {
weights: Vec<f64>,
len_row: usize,
bias: Vec<f64>,
func: &'a Box<Fn(DualNumber) -> DualNumber>,
}
impl<'a> FeedForward<'a> {
pub fn new(weights: Vec<f64>, len_row: usize, bias: Vec<f64>, func: &'a Box<Fn(DualNumber) -> Dual... | true |
9790efc40aa36910e5011b853941a82106421451 | Rust | Microsvuln/tlspuffin | /src/variable_data.rs | UTF-8 | 6,891 | 3.03125 | 3 | [] | no_license | //! Definition of the VariableData trait. A VariableData can contain any data which has a `'static`
//! type. This is true for [`rustls::msgs::message::Message`] for example.
use std::any::{Any, TypeId};
use crate::error::Error;
use rustls::msgs::handshake::ServerKeyExchangePayload;
use rustls::{
internal::msgs::... | true |
d8a16cb3ce95e32cc42eba0cd0d7577dfb7de639 | Rust | emergent/rust-sound-programming | /src/bin/ex2_1_sine_wave.rs | UTF-8 | 704 | 2.75 | 3 | [] | no_license | extern crate sound_lib;
use sound_lib::MonoPcm;
use std::f64::consts::PI;
fn main() {
let fs = 44100;
let bits = 16;
let length = fs * 1;
let mut sdata = Vec::with_capacity(length as usize * 1);
// sine wave
let a = 0.1; // amplitude
let f = vec![
261.63, 293.66, 329.63, 349.23, 39... | true |
8beb0bbb54c9a61c3261647e91f1169357617b6c | Rust | nklizhe/aoc2020 | /src/day8.rs | UTF-8 | 2,919 | 3.140625 | 3 | [] | no_license | use super::utils;
use std::collections::HashMap;
use std::mem;
#[derive(Clone, Debug, PartialEq)]
enum OpCode {
Nop,
Acc,
Jmp,
}
#[derive(Clone, Debug)]
struct Op(OpCode, i32);
fn parse_line(line: &str) -> (OpCode, i32) {
let tmp: Vec<&str> = line.split(" ").collect();
let v: i32 = tmp[1].parse::... | true |
41eb6750eee52ca062fb2a1d1c38edf9aa7e73a2 | Rust | forkkit/polars | /polars/polars-core/src/chunked_array/trusted_len.rs | UTF-8 | 3,469 | 2.515625 | 3 | [
"MIT"
] | permissive | use crate::chunked_array::upstream_traits::PolarsAsRef;
use crate::prelude::*;
use crate::utils::{CustomIterTools, FromTrustedLenIterator, NoNull};
use arrow::buffer::Buffer;
use std::borrow::Borrow;
impl<T> FromTrustedLenIterator<Option<T::Native>> for ChunkedArray<T>
where
T: PolarsPrimitiveType,
{
fn from_i... | true |
9f9a02d6d8594eb70a30d3521427a434ae5b1ec0 | Rust | aatxe/awebot-plugins | /tell/src/lib.rs | UTF-8 | 7,883 | 2.75 | 3 | [] | no_license | extern crate irc;
extern crate serde;
extern crate time;
use irc::client::prelude::*;
use irc::error;
use irc::proto::Command::PRIVMSG;
#[no_mangle]
pub extern fn process(server: &IrcServer, message: &Message) -> error::Result<()> {
process_internal(server, message)
}
pub fn process_internal<S>(server: &S, msg:... | true |
bc80878dbd4a706ba634baa86d8696b4d3833e4f | Rust | JorgenPo/rust-text-rpg | /src/game/mod.rs | UTF-8 | 4,955 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt::Debug;
use crate::render;
use std::time::Duration;
use std::io::Write;
use termion::raw::IntoRawMode;
use termion::screen;
use log::{info, error};
use crate::widgets::label::Label;
use crate::render::Coordinate;
use std::panic::PanicInfo;
use std::any::TypeId;
use backtrace::Back... | true |
bdcdc879ead5a14c077a4b45ab3d76626436ee02 | Rust | jafow/simplefs | /simplefs/src/sb.rs | UTF-8 | 2,955 | 3.53125 | 4 | [] | no_license | use zerocopy::{AsBytes, FromBytes};
/// The first block of the file system storing information critical for mounting
/// the file system and verifying the underlying disk is formatted correctly.
///
/// Keeps the size of the file system by tracking the number of blocks allocated
/// to the inode and data block groups.... | true |
1267b5ff97e1fd98f42e8daea508f20c7284256f | Rust | haljin/advent-of-code | /advent_of_code_2018/src/day3.rs | UTF-8 | 4,293 | 3.125 | 3 | [] | no_license | use std::collections::HashSet;
use std::fs::File;
use std::io::prelude::*;
pub struct Cut {
id: i64,
x: i64,
y: i64,
width: i64,
height: i64,
}
pub fn read_data() -> Vec<Cut> {
let mut f = File::open("./data/day3").unwrap();
let mut contents = String::new();
f.read_to_string(&mut cont... | true |
898f656e05e4354ea0044f450556f96a958bbf03 | Rust | FreddieRidell/hypertask | /rust/render_simple_cli_table/src/lib.rs | UTF-8 | 2,059 | 2.859375 | 3 | [] | no_license | use ansi_term::Style;
use std::collections::HashMap;
use std::fmt::{Display, Write};
use std::hash::Hash;
const GUTTER_WIDTH: usize = 2;
pub fn render_table<
Header: Display + Eq + Hash,
Value: Display + Default,
Hasher: ::std::hash::BuildHasher,
>(
headers: &[Header],
header_style: &Style,
ro... | true |
356d4841f46749403cdd37e29c8794e7cb087c57 | Rust | azriel91/autexousious | /crate/asset_gfx_gen/src/sprite_gen_params.rs | UTF-8 | 549 | 3.125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | /// Parameters to generate a sprite.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct SpriteGenParams {
/// Texture width.
pub image_w: u32,
/// Texture height.
pub image_h: u32,
/// Individual sprite width.
pub sprite_w: u32,
/// Individual sprite height.
pub sprite_h: u32,
... | true |
6231cf2c5f6798682dcb328a16ecd0cf9d6aeaf3 | Rust | kennykerr/com-rs | /src/ptr.rs | UTF-8 | 4,093 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::sys::{E_NOINTERFACE, E_POINTER, FAILED};
use crate::{interfaces::IUnknown, ComInterface, ComRc, IID};
use std::ffi::c_void;
use std::marker::PhantomData;
use std::ptr::NonNull;
/// A transparent ptr to a COM interface.
///
/// This is normally _not_ the correct way to interact with an interface. Normally
/... | true |
73dda1735ee891db610d6e7299702d929e8f1500 | Rust | shmuga/nadn2tetris | /src/assembler/src/lexer.rs | UTF-8 | 2,333 | 3.21875 | 3 | [
"MIT"
] | permissive | use crate::token::{Instruction, A, C};
use crate::token::Instruction::Label;
use crate::symbol_table::SymbolTable;
#[derive(Debug)]
pub struct Lexer<'a> {
counter: u16,
pub table: &'a mut SymbolTable,
pub tokens: Vec<Instruction<'a>>,
}
fn is_digit(x: &Option<char>) -> bool {
x.map(|x| x == '_' || '0'... | true |
bdc0a792a7d58aa0d41aecd63e90cec0f108728e | Rust | LuciEngine/Lucien | /render/src/light.rs | UTF-8 | 3,236 | 2.890625 | 3 | [] | no_license | use glam::{vec3, Vec3};
use crate::buffer::uniform_buffer;
use crate::gpu_data::*;
// Point Light
#[derive(Debug)]
pub struct PointLight {
pub position: Vec3,
// set a bound?
pub color: Vec3,
pub intensity: f32,
pub buffer: wgpu::Buffer,
pub bind_group_layout: wgpu::BindGroupLayout,
pub bi... | true |
f30c03a7772c5184663cef3308ef230877b84220 | Rust | supersriver/rust-clippy | /tests/ui/vec.rs | UTF-8 | 1,344 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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 http://opensource.org/licenses/MIT>,... | true |
23b409d3f3e854cc57ccddce5e546e88c42313ab | Rust | IThawk/rust-project | /rust-master/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs | UTF-8 | 832 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![feature(slice_patterns)]
fn a<'a>() -> &'a [isize] {
let vec = vec![1, 2, 3, 4];
let vec: &[isize] = &vec;
let tail = match vec {
&[_, ref tail @ ..] => tail,
_ => panic!("a")
};
tail //~ ERROR cannot return value referencing local variable `vec`
}
fn b<'a>() -> &'a [isize] {
... | true |
b1d005893bac69dac6865df58ce0a34fe3b34c49 | Rust | scottgeigel/DCMake | /src/dc_make.rs | UTF-8 | 9,367 | 2.65625 | 3 | [
"MIT"
] | permissive | //MIT License
//
//Copyright (c) 2016 Scott Geigel
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merg... | true |
96e0fe9c13af3d00f06c18d1d916faefbceba88f | Rust | ngotchac/openapi-rust-generator | /test/src/models/io_file_system_entry_info.rs | UTF-8 | 648 | 2.6875 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct IoFileSystemEntryInfo {
#[serde(rename(deserialize = "Name"))]
pub name: String,
#[serde(rename(deserialize = "Path"))]
pub path: String,
#[serde(rename(deserialize = "Type"))]
pub _type: ... | true |
194e8126b516fa1fee2a245021597981db12529d | Rust | mathstuf/rust-bus | /src/interface.rs | UTF-8 | 27,326 | 2.5625 | 3 | [] | no_license | // Distributed under the OSI-approved BSD 3-Clause License.
// See accompanying LICENSE file for details.
use crates::core::ops::DerefMut;
use crates::machine_id::MachineId;
use arguments::Arguments;
use connection::Connection;
use error::*;
use message::{Message, MessageType};
use value::{BasicValue, Dictionary, Sig... | true |
96b03a3fd847ed66569f6da4d47c7ab5337aa533 | Rust | pandaman64/Heap | /src/binary.rs | UTF-8 | 1,738 | 3.390625 | 3 | [] | no_license | use heap::Heap;
pub struct BinaryHeap<T> {
buffer: Vec<T>,
}
impl<T: Clone + Ord + Default> BinaryHeap<T> {
pub fn new() -> Self {
BinaryHeap { buffer: vec![Default::default()] }
}
fn size(&self) -> usize {
self.buffer.len() - 1
}
fn upheap(&mut self, idx: usize) {
if... | true |
878325d29529dd4ac19c4326ea8e60e48792a804 | Rust | ansome22/Ansome-AI-Collection | /src/TaticalAnalyses/convolve.rs | UTF-8 | 956 | 2.609375 | 3 | [] | no_license | // Performs a convolution of the matrix on the source.
fn convolve(matrix: Matrix, source: Matrix, destination: Matrix){
// Find the size of the matrix.
matrixLength: int = matrix.length();
size: int = (matrixLength - 1) / 2;
// Find the dimensions of the source.
height: int = source.length();
... | true |
9ccf5b68bfd09315c9b5282b86f73e9ed90ff6f7 | Rust | shepmaster/snafu | /tests/module.rs | UTF-8 | 2,284 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | pub mod inner {
use snafu::Snafu;
#[derive(Debug)]
pub struct Dummy0;
#[derive(Debug)]
pub struct Dummy1;
#[derive(Debug)]
pub struct Dummy2;
#[derive(Debug)]
pub struct Dummy3;
#[derive(Debug, Snafu)]
#[snafu(module, visibility(pub))]
pub enum PubError {
Var... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.